system/src/sc/lang/java/ModelUtil.java
public static Object resolveTypeParameter(Object srcType, Object resultType, Object typeParam) {
      String typeParamName = ModelUtil.getTypeParameterName(typeParam);
      int srcIx = ModelUtil.getTypeParameterPosition(srcType, typeParamName);
      if (srcIx == -1) {
         System.err.println("*** Unresolveable type parameter!");
         return null;
      }
      List<Object> extTypes = getExtendsJavaTypePath(srcType, resultType);
      if (extTypes == null || extTypes.size() == 0) {
         return getTypeParameters(srcType).get(srcIx);
      }

      Object res = typeParam;

      Object nextType;
      for (int i = extTypes.size()-1; i >= 0; i--) {
         Object ext = extTypes.get(i);
         List<?> typeArgs = ModelUtil.getTypeArguments(ext);
         if (typeArgs == null)
            return null;
         Object typeArg = typeArgs.get(srcIx);
         if (typeArg instanceof JavaType)
            typeArg = ((JavaType) typeArg).getTypeDeclaration();
         if (ModelUtil.isTypeVariable(typeArg)) {
            res = typeArg;
            typeParamName = ModelUtil.getTypeParameterName(res);

            if (i == 0)
               nextType = resultType;
            else {
               nextType = extTypes.get(i-1);
               if (nextType instanceof JavaType)
                  nextType = ((JavaType) nextType).getTypeDeclaration();
            }

            srcIx = ModelUtil.getTypeParameterPosition(nextType, typeParamName);
         }
         else if (typeArg instanceof ExtendsType.LowerBoundsTypeDeclaration)
            System.out.println("*** Unknown lower bounds type 2");
         else
            return typeArg;
      }
      return res;
   }
/**
    * Computes the type parameter in type 'resultType' that corresponds to "typeParam" you provide for the base type srcType.
    * In other words, it lets you determine the value of a base type's type parameter when evaluated in the context of the sub-type.
    * So List&lt;E&gt; - you provide List.class, E, and the resultType of MySubType implements List&lt;Integer&gt; and it will return Integer.class
    * This "typeParam" should be one of the type variables srcType was defined with, and srcType should be a baseType of resultType.
    */
Computes the type parameter in type 'resultType' that corresponds to "typeParam" you provide for the base type srcType.
In other words, it lets you determine the value of a base type's type parameter when evaluated in the context of the sub-type.
So List<E> - you provide List.class, E, and the resultType of MySubType implements List<Integer> and it will return Integer.class
This "typeParam" should be one of the type variables srcType was defined with, and srcType should be a baseType of resultType.
Computes the type parameter in type ' resultType ' that corresponds to " typeParam " you provide for the base type srcType . In other words it lets you determine the value of a base type ' s type parameter when evaluated in the context of the sub - type . So List<E > - you provide List . class E and the resultType of MySubType implements List<Integer > and it will return Integer . class This " typeParam " should be one of the type variables srcType was defined with and srcType should be a baseType of resultType .
public static Object resolveTypeParameter(Object srcType, Object resultType, Object typeParam) {
      String typeParamName = ModelUtil.getTypeParameterName(typeParam);
      int srcIx = ModelUtil.getTypeParameterPosition(srcType, typeParamName);
      if (srcIx == -1) {
         System.err.println("*** Unresolveable type parameter!");
         return null;
      }
      List<Object> extTypes = getExtendsJavaTypePath(srcType, resultType);
      if (extTypes == null || extTypes.size() == 0) {
         return getTypeParameters(srcType).get(srcIx);
      }
      Object res = typeParam;
      Object nextType;
      for (int i = extTypes.size()-1; i >= 0; i--) {
         Object ext = extTypes.get(i);
         List<?> typeArgs = ModelUtil.getTypeArguments(ext);
         if (typeArgs == null)
            return null;
         Object typeArg = typeArgs.get(srcIx);
         if (typeArg instanceof JavaType)
            typeArg = ((JavaType) typeArg).getTypeDeclaration();
         if (ModelUtil.isTypeVariable(typeArg)) {
            res = typeArg;
            typeParamName = ModelUtil.getTypeParameterName(res);
            if (i == 0)
               nextType = resultType;
            else {
               nextType = extTypes.get(i-1);
               if (nextType instanceof JavaType)
                  nextType = ((JavaType) nextType).getTypeDeclaration();
            }
            srcIx = ModelUtil.getTypeParameterPosition(nextType, typeParamName);
         }
         else if (typeArg instanceof ExtendsType.LowerBoundsTypeDeclaration)
            System.out.println("*** Unknown lower bounds type 2");
         else
            return typeArg;
      }
      return res;
   }
public static Object resolveTypeParameter ( Object srcType , Object resultType , Object typeParam ) { String typeParamName = ModelUtil . getTypeParameterName ( typeParam ) ; int srcIx = ModelUtil . getTypeParameterPosition ( srcType , typeParamName ) ; if ( srcIx == - 1 ) { System . err . println ( "*** Unresolveable type parameter!" ) ; return null ; } List < Object > extTypes = getExtendsJavaTypePath ( srcType , resultType ) ; if ( extTypes == null || extTypes . size ( ) == 0 ) { return getTypeParameters ( srcType ) . get ( srcIx ) ; } Object res = typeParam ; Object nextType ; for ( int i = extTypes . size ( ) - 1 ; i >= 0 ; i -- ) { Object ext = extTypes . get ( i ) ; List < ? > typeArgs = ModelUtil . getTypeArguments ( ext ) ; if ( typeArgs == null ) return null ; Object typeArg = typeArgs . get ( srcIx ) ; if ( typeArg instanceof JavaType ) typeArg = ( ( JavaType ) typeArg ) . getTypeDeclaration ( ) ; if ( ModelUtil . isTypeVariable ( typeArg ) ) { res = typeArg ; typeParamName = ModelUtil . getTypeParameterName ( res ) ; if ( i == 0 ) nextType = resultType ; else { nextType = extTypes . get ( i - 1 ) ; if ( nextType instanceof JavaType ) nextType = ( ( JavaType ) nextType ) . getTypeDeclaration ( ) ; } srcIx = ModelUtil . getTypeParameterPosition ( nextType , typeParamName ) ; } else if ( typeArg instanceof ExtendsType . LowerBoundsTypeDeclaration ) System . out . println ( "*** Unknown lower bounds type 2" ) ; else return typeArg ; } return res ; }
Computes the type parameter in type 'resultType' that corresponds to "typeParam" you provide for the base type srcType.
Computes the type parameter in type ' resultType ' that corresponds to " typeParam " you provide for the base type srcType .