Example #1
0
 /**
  * A member type of the type with actual type arguments to the receiving type and invocation.
  *
  * @param member the declaration of a member type of this type
  * @param typeArguments the type arguments of the invocation
  */
 public ProducedType getTypeMember(TypeDeclaration member, List<ProducedType> typeArguments) {
   ProducedType declaringType = getSupertype((TypeDeclaration) member.getContainer());
   ProducedType pt = new ProducedType();
   pt.setDeclaration(member);
   pt.setQualifyingType(declaringType);
   Map<TypeParameter, ProducedType> map = arguments(member, declaringType, typeArguments);
   // map.putAll(sub(map));
   pt.setTypeArguments(map);
   return pt;
 }
Example #2
0
 private ProducedType substitutedType(
     Declaration dec, ProducedType pt, Map<TypeParameter, ProducedType> substitutions) {
   ProducedType type = new ProducedType();
   type.setDeclaration(dec);
   ProducedType qt = pt.getQualifyingType();
   if (qt != null) {
     type.setQualifyingType(substitute(qt, substitutions));
   }
   type.setTypeArguments(substitutedTypeArguments(pt, substitutions));
   return type;
 }
 /**
  * Get a produced type for this declaration by binding explicit or inferred type arguments and
  * type arguments of the type of which this declaration is a member, in the case that this is a
  * nested type.
  *
  * @param qualifyingType the qualifying produced type or null if this is not a nested type dec
  * @param typeArguments arguments to the type parameters of this declaration
  */
 public ProducedType getProducedType(
     ProducedType qualifyingType, List<ProducedType> typeArguments) {
   if (qualifyingType != null && qualifyingType.isNothing()) {
     return qualifyingType;
   }
   ProducedType pt = new ProducedType();
   pt.setDeclaration(this);
   pt.setQualifyingType(qualifyingType);
   pt.setTypeArguments(getTypeArgumentMap(this, qualifyingType, typeArguments));
   return pt;
 }
 @Override
 public ProducedType getReference() {
   ProducedType pt = new ProducedType();
   if (isMember()) {
     pt.setQualifyingType(((ClassOrInterface) getContainer()).getType());
   }
   pt.setDeclaration(this);
   pt.setTypeArguments(
       getTypeArgumentMap(this, pt.getQualifyingType(), Collections.<ProducedType>emptyList()));
   return pt;
 }
 /**
  * The type of the declaration as seen from within the body of the declaration itself.
  *
  * <p>Note that for certain special types which we happen to know don't have type arguments, we
  * use this as a convenience method to quickly get a produced type for use outside the body of the
  * declaration, but this is not really correct!
  */
 public ProducedType getType() {
   ProducedType type = new ProducedType();
   if (isMember()) {
     type.setQualifyingType(((ClassOrInterface) getContainer()).getType());
   }
   type.setDeclaration(this);
   // each type parameter is its own argument
   List<TypeParameter> typeParameters = getTypeParameters();
   if (typeParameters.isEmpty()) {
     type.setTypeArguments(Collections.<TypeParameter, ProducedType>emptyMap());
   } else {
     Map<TypeParameter, ProducedType> map = new HashMap<TypeParameter, ProducedType>();
     for (TypeParameter p : typeParameters) {
       ProducedType pta = new ProducedType();
       pta.setDeclaration(p);
       map.put(p, pta);
     }
     type.setTypeArguments(map);
   }
   return type;
 }
Example #6
0
 private ProducedType qualifiedByDeclaringType() {
   ProducedType qt = getQualifyingType();
   if (qt == null) {
     return this;
   } else {
     ProducedType pt = new ProducedType();
     pt.setDeclaration(getDeclaration());
     pt.setTypeArguments(getTypeArguments());
     // replace the qualifying type with
     // the supertype of the qualifying
     // type that declares this nested
     // type, substituting type arguments
     ProducedType declaringType =
         qt.getSupertype((TypeDeclaration) getDeclaration().getContainer());
     pt.setQualifyingType(declaringType);
     return pt;
   }
 }