コード例 #1
0
  private List<IRType> getBoundedParameterTypeDescriptors(IConstructorInfo mi) {
    if (mi.getParameters().length == 0) {
      return Collections.emptyList();
    }

    if (mi instanceof IJavaConstructorInfo) {
      return IRTypeResolver.getDescriptors(
          ((IJavaConstructorInfo) mi).getJavaConstructor().getParameterTypes());
    } else if (mi instanceof IGosuConstructorInfo) {
      IReducedDynamicFunctionSymbol dfs = ((IGosuConstructorInfo) mi).getDfs();
      while (dfs instanceof ReducedParameterizedDynamicFunctionSymbol) {
        ReducedParameterizedDynamicFunctionSymbol pdfs =
            (ReducedParameterizedDynamicFunctionSymbol) dfs;
        dfs = pdfs.getBackingDfs();
      }

      List<IRType> boundedTypes = new ArrayList<IRType>(dfs.getArgs().size());
      if (IGosuClass.ProxyUtil.isProxy(dfs.getGosuClass())) {
        return getBoundedParamTypesFromProxiedClass(dfs);
      }

      for (int i = 0; i < dfs.getArgs().size(); i++) {
        boundedTypes.add(
            IRTypeResolver.getDescriptor(
                TypeLord.getDefaultParameterizedTypeWithTypeVars(dfs.getArgs().get(i).getType())));
      }
      return boundedTypes;
    } else {
      return getTypeDescriptors(mi.getParameters());
    }
  }
コード例 #2
0
  private Constructor getJavaConstructorFromProxy(IReducedDynamicFunctionSymbol dfs) {
    IType proxyType = dfs.getGosuClass();
    IJavaType javaType = (IJavaType) IGosuClass.ProxyUtil.getProxiedType(proxyType);

    IType[] boundedDfsParams = new IType[dfs.getArgs().size()];
    for (int i = 0; i < boundedDfsParams.length; i++) {
      IType param = dfs.getArgs().get(i).getType();
      if (param instanceof ITypeVariableType && param.getEnclosingType() instanceof IGosuClass) {
        param = ((ITypeVariableType) param).getBoundingType();
      }
      boundedDfsParams[i] = param;
    }

    javaType = (IJavaType) TypeLord.getDefaultParameterizedType(javaType);
    IJavaConstructorInfo jmi =
        (IJavaConstructorInfo)
            ((IRelativeTypeInfo) javaType.getTypeInfo()).getConstructor(javaType, boundedDfsParams);
    return jmi.getRawConstructor();
  }