public UnresolvedType lookupType(String name, IHasPosition location) { for (int i = 0; i < typeVariableNames.length; i++) { if (typeVariableNames[i].equals(name)) { if (typeVarTypeXs[i] == null) { typeVarTypeXs[i] = new UnresolvedTypeVariableReferenceType(new TypeVariable(name)); } return typeVarTypeXs[i]; } } return delegateScope.lookupType(name, location); }
private static TypeVariable formalTypeParameter2TypeVariable(GenericSignature.FormalTypeParameter aFormalTypeParameter, GenericSignature.FormalTypeParameter[] typeParams, World world, Map<GenericSignature.FormalTypeParameter, ReferenceType> inProgressTypeVariableResolutions) throws GenericSignatureFormatException { UnresolvedType upperBound = fieldTypeSignature2TypeX(aFormalTypeParameter.classBound, typeParams, world, inProgressTypeVariableResolutions); UnresolvedType[] ifBounds = new UnresolvedType[aFormalTypeParameter.interfaceBounds.length]; for (int i = 0; i < ifBounds.length; i++) { ifBounds[i] = fieldTypeSignature2TypeX(aFormalTypeParameter.interfaceBounds[i], typeParams, world, inProgressTypeVariableResolutions); } return new TypeVariable(aFormalTypeParameter.identifier, upperBound, ifBounds); }
private static ResolvedType typeVariableSignature2TypeX(GenericSignature.TypeVariableSignature aTypeVarSig, GenericSignature.FormalTypeParameter[] typeParams, World world, Map<GenericSignature.FormalTypeParameter, ReferenceType> inProgressTypeVariableResolutions) throws GenericSignatureFormatException { GenericSignature.FormalTypeParameter typeVarBounds = null; for (int i = 0; i < typeParams.length; i++) { if (typeParams[i].identifier.equals(aTypeVarSig.typeVariableName)) { typeVarBounds = typeParams[i]; break; } } if (typeVarBounds == null) { // blowing up here breaks the situation with ITDs where the type variable is mentioned in the // declaring type and used somewhere in the signature. Temporary change to allow it to return just a // 'dumb' typevariablereference. return new TypeVariableReferenceType(new TypeVariable(aTypeVarSig.typeVariableName), world); // throw new GenericSignatureFormatException("Undeclared type variable in signature: " + aTypeVarSig.typeVariableName); } if (inProgressTypeVariableResolutions.containsKey(typeVarBounds)) { return inProgressTypeVariableResolutions.get(typeVarBounds); } inProgressTypeVariableResolutions.put(typeVarBounds, new FTPHolder(typeVarBounds, world)); ReferenceType ret = new TypeVariableReferenceType(formalTypeParameter2TypeVariable(typeVarBounds, typeParams, world, inProgressTypeVariableResolutions), world); inProgressTypeVariableResolutions.put(typeVarBounds, ret); return ret; }
public static UnresolvedType forGenericTypeSignature(String sig, String declaredGenericSig) { UnresolvedType ret = UnresolvedType.forSignature(sig); ret.typeKind = TypeKind.GENERIC; ClassSignature csig = new GenericSignatureParser().parseAsClassSignature(declaredGenericSig); GenericSignature.FormalTypeParameter[] ftps = csig.formalTypeParameters; ret.typeVariables = new TypeVariable[ftps.length]; for (int i = 0; i < ftps.length; i++) { GenericSignature.FormalTypeParameter parameter = ftps[i]; if (parameter.classBound instanceof GenericSignature.ClassTypeSignature) { GenericSignature.ClassTypeSignature cts = (GenericSignature.ClassTypeSignature) parameter.classBound; ret.typeVariables[i] = new TypeVariable(ftps[i].identifier, UnresolvedType.forSignature(cts.outerType.identifier + ";")); } else if (parameter.classBound instanceof GenericSignature.TypeVariableSignature) { GenericSignature.TypeVariableSignature tvs = (GenericSignature.TypeVariableSignature) parameter.classBound; UnresolvedTypeVariableReferenceType utvrt = new UnresolvedTypeVariableReferenceType(new TypeVariable( tvs.typeVariableName)); ret.typeVariables[i] = new TypeVariable(ftps[i].identifier, utvrt); } else { throw new BCException( "UnresolvedType.forGenericTypeSignature(): Do not know how to process type variable bound of type '" + parameter.classBound.getClass() + "'. Full signature is '" + sig + "'"); } } ret.signatureErasure = sig; ret.signature = ret.signatureErasure; return ret; }
public static TypeVariable read(VersionedDataInputStream s) throws IOException { // if (s.getMajorVersion()>=AjAttribute.WeaverVersionInfo.WEAVER_VERSION_MAJOR_AJ150) { String name = s.readUTF(); UnresolvedType ubound = UnresolvedType.read(s); int iboundcount = s.readInt(); UnresolvedType[] ibounds = UnresolvedType.NONE; if (iboundcount > 0) { ibounds = new UnresolvedType[iboundcount]; for (int i = 0; i < iboundcount; i++) { ibounds[i] = UnresolvedType.read(s); } } TypeVariable newVariable = new TypeVariable(name, ubound, ibounds); return newVariable; }
typeVariableName = typeVariableName.substring(0, typeVariableName.length() - 1); return new UnresolvedTypeVariableReferenceType(new TypeVariable(typeVariableName)); } else if (firstChar == '[') { int dims = 0;
TypeVariable rt_tv = new TypeVariable(tv.getName()); TypeVariableReferenceType tvrt = new TypeVariableReferenceType(rt_tv, getWorld());
rTypeVariables[i] = new TypeVariable(tVars[i].getName());