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); }
public String toDebugString() { return getDisplayName(); }
public TypeVariableReferenceType(TypeVariable typeVariable, World world) { super(typeVariable.getGenericSignature(), typeVariable.getErasureSignature(), world); this.typeVariable = typeVariable; }
public void setTypeVariable(TypeVariable aTypeVariable) { this.signature = "T" + aTypeVariable.getName() + ";"; // aTypeVariable.getUpperBound().getSignature(); this.signatureErasure = aTypeVariable.getFirstBound().getErasureSignature(); this.typeVariable = aTypeVariable; this.typeKind = TypeKind.TYPE_VARIABLE; }
rTypeVariables[i] = new TypeVariable(tVars[i].getName()); TypeVariableReferenceType tvrt = ((TypeVariableReferenceType) typeConverter.fromType(tVars[i])); TypeVariable tv = tvrt.getTypeVariable(); rTypeVariables[i].setSuperclass(tv.getSuperclass()); rTypeVariables[i].setAdditionalInterfaceBounds(tv.getSuperInterfaces()); rTypeVariables[i].setDeclaringElement(tv.getDeclaringElement()); rTypeVariables[i].setDeclaringElementKind(tv.getDeclaringElementKind()); rTypeVariables[i].setRank(tv.getRank());
@Override public String toString() { return typeVariable.getName(); }
public String getErasureSignature() { return getFirstBound().getErasureSignature(); }
TypeVariable rt_tv = new TypeVariable(tv.getName()); TypeVariableReferenceType tvrt = new TypeVariableReferenceType(rt_tv, getWorld()); System.arraycopy(resBounds, 1, additionalBounds, 0, additionalBounds.length); rt_tv.setUpperBound(upperBound); rt_tv.setAdditionalInterfaceBounds(additionalBounds);
.getTypeVariable(); boolean b = mtv .canBeBoundTo((ResolvedType) ttps[ii]); if (!b) {// TODO incomplete testing here boolean b = myTV.canBeBoundTo(theirParameters[i]); if (!b) {// TODO incomplete testing here I think parametersAssignable = false; TypeVariable aVar = ((TypeVariableReference) this) .getTypeVariable(); return aVar.resolve(world).canBeBoundTo(other); return ((TypeVariableReference) this) .getTypeVariable() .resolve(world) .canBeBoundTo( otherType.getTypeVariable().getFirstBound() .getFirstBound().resolve(world));
@Override public ResolvedType resolve(World world) { TypeVariableDeclaringElement typeVariableScope = world.getTypeVariableLookupScope(); TypeVariable resolvedTypeVariable = null; TypeVariableReferenceType tvrt = null; if (typeVariableScope == null) { // throw new BCException("There is no scope in which to lookup type variables!"); // FIXME asc correct thing to do is go bang, but to limp along, lets cope with the scope missing resolvedTypeVariable = typeVariable.resolve(world); tvrt = new TypeVariableReferenceType(resolvedTypeVariable, world); } else { boolean foundOK = false; resolvedTypeVariable = typeVariableScope.getTypeVariableNamed(typeVariable.getName()); // FIXME asc remove this when the shared type var stuff is sorted if (resolvedTypeVariable == null) { resolvedTypeVariable = typeVariable.resolve(world); } else { foundOK = true; } tvrt = new TypeVariableReferenceType(resolvedTypeVariable, world); } return tvrt; }
TypeVariableReferenceType tvrt = (TypeVariableReferenceType) myTypeParameters[i]; TypeVariable tv = tvrt.getTypeVariable(); tv.resolve(world); if (!tv.canBeBoundTo(theirTypeParameters[i])) { return false; TypeVariableReferenceType tvrt = (TypeVariableReferenceType) theirTypeParameters[i]; TypeVariable tv = tvrt.getTypeVariable(); tv.resolve(world); if (!tv.canBeBoundTo(myTypeParameters[i])) { return false;
if (continueCheck && !tvs[i].canBeBoundTo(ut.resolve(scope.getWorld()))) { parameterName = ((TypeVariableReference) ut).getTypeVariable().getDisplayName(); new Integer(i + 1), tvs[i].getDisplayName(), genericType.getName()); if (requireExactType) { scope.message(MessageUtil.error(msg, sLoc));
b = ((ResolvedType) upperBound).isParameterizedWithTypeVariable(); } else if (upperBound.isTypeVariableReference() && ((TypeVariableReference) upperBound).getTypeVariable().getDeclaringElementKind() == TypeVariable.METHOD) { b = true; b = ((ResolvedType) lowerBound).isParameterizedWithTypeVariable(); } else if (lowerBound.isTypeVariableReference() && ((TypeVariableReference) lowerBound).getTypeVariable().getDeclaringElementKind() == TypeVariable.METHOD) { b = true;
public UnresolvedTypeVariableReferenceType(TypeVariable aTypeVariable) { super("T" + aTypeVariable.getName() + ";", aTypeVariable.getFirstBound().getErasureSignature());//aTypeVariable.getFirstBound().getSignature()); this.typeVariable = aTypeVariable; }
@Override public String toDebugString() { return typeVariable.getName(); }
@Override public String getErasureSignature() { return typeVariable.getFirstBound().getSignature(); }
TypeVariable[] tVars = rd.getTypeVariables(); for (int i = 0; i < tVars.length; i++) { if (tVars[i].getName().equals(getName())) { resolvedTVar = tVars[i]; break; TypeVariable[] tvrts = declaring.getTypeVariables(); for (int i = 0; i < tvrts.length; i++) { if (tvrts[i].getName().equals(getName())) { resolvedTVar = tvrts[i]; firstbound = getFirstBound().resolve(world);
@Override public String toString() { if (typeVariable == null) { return "<type variable not set!>"; } else { return "T" + typeVariable.getName() + ";"; } }
public String getDisplayName() { StringBuffer ret = new StringBuffer(); ret.append(name); if (!getFirstBound().getName().equals("java.lang.Object")) { ret.append(" extends "); ret.append(getFirstBound().getName()); if (superInterfaces != null) { for (int i = 0; i < superInterfaces.length; i++) { if (!getFirstBound().equals(superInterfaces[i])) { ret.append(" & "); ret.append(superInterfaces[i].getName()); } } } } return ret.toString(); }
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); }