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());
    }
  }
Example #2
0
    @Override
    protected String getCommonSuperClass(String type1, String type2) {
      IType t1 = TypeSystem.getByFullNameIfValid(type1.replace('/', '.').replace('$', '.'));
      IType t2 = TypeSystem.getByFullNameIfValid(type2.replace('/', '.').replace('$', '.'));
      if (t1 != null && t2 != null) {
        if (t1.isAssignableFrom(t2)) {
          return type1;
        }
        if (t2.isAssignableFrom(t1)) {
          return type2;
        }
        if (t1.isInterface() || t2.isInterface()) {
          return "java/lang/Object";
        }
      }
      IType fromT1 = findCommonClass(t1, t2);
      IType fromT2 = findCommonClass(t2, t1);
      IType commonSuper;
      if (fromT1.isAssignableFrom(fromT2)) {
        commonSuper = fromT2;
      } else {
        commonSuper = fromT1;
      }

      String superTypeName;
      if (commonSuper instanceof IJavaBackedTypeData) {
        // Ensure we use the backing Java class's name e.g., entity types use a different name
        superTypeName =
            IRTypeResolver.getDescriptor(((IJavaBackedTypeData) commonSuper).getBackingClassInfo())
                .getSlashName();
      } else {
        superTypeName = IRTypeResolver.getDescriptor(commonSuper).getSlashName();
      }
      return superTypeName;
    }
  private static IRType getTrueOwningType(IConstructorInfo mi) {
    if (mi instanceof IJavaConstructorInfo) {
      // We have to get the owner type from the method because it may be different from the owning
      // type e.g., entity aspects see ContactGosuAspect.AllAdresses
      IJavaClassConstructor m = ((IJavaConstructorInfo) mi).getJavaConstructor();
      if (m != null) {
        return IRTypeResolver.getDescriptor(m.getEnclosingClass());
      }
    }

    return IRTypeResolver.getDescriptor(mi.getOwnersType());
  }
 private void addImplicitOuterParamType(IType owningType, List<IRType> paramTypes) {
   // Outer 'this'
   if (AbstractElementTransformer.isNonStaticInnerClass(owningType)) {
     paramTypes.add(
         IRTypeResolver.getDescriptor(
             AbstractElementTransformer.getRuntimeEnclosingType(owningType)));
   }
 }
 // TODO - AHK - Duplicate of method in AbstractElementTransformer
 public IRType getTargetRootIRType() {
   IRType owner = getOwningIRType();
   if (owner instanceof GosuClassIRType
       && ((GosuClassIRType) owner).getType() instanceof IGosuEnhancement) {
     return IRTypeResolver.getDescriptor(
         ((IGosuEnhancement) ((GosuClassIRType) owner).getType()).getEnhancedType());
   } else {
     return owner;
   }
 }
  private void addImplicitCapturedSymbolParamTypes(IType owningType, List<IRType> paramTypes) {
    // Captured symbols
    // Don't attempt to get captured symbols if the type isn't valid; it'll just throw and result in
    // a cascading break
    if (owningType instanceof IGosuClassInternal
        && owningType.isValid()) // && ((IGosuClassInternal)type).isAnonymous() )
    {
      Map<String, ICapturedSymbol> capturedSymbols =
          ((IGosuClassInternal) owningType).getCapturedSymbols();
      if (capturedSymbols != null) {
        for (ICapturedSymbol sym : capturedSymbols.values()) {
          paramTypes.add(IRTypeResolver.getDescriptor(sym.getType().getArrayType()));
        }
      }
    }

    // The external symbols are always treated as captured
    if (AbstractElementTransformer.requiresExternalSymbolCapture(owningType)) {
      paramTypes.add(IRTypeResolver.getDescriptor(IExternalSymbolMap.class));
    }
  }
 private List<IRType> getBoundedParamTypesFromProxiedClass(IReducedDynamicFunctionSymbol dfs) {
   Constructor m = getJavaConstructorFromProxy(dfs);
   return IRTypeResolver.getDescriptors(m.getParameterTypes());
 }