private TypeReference findBound(TypeBinding bound, TypeParameter parameter) { if (parameter.type != null && TypeBinding.equalsEquals(parameter.type.resolvedType, bound)) return parameter.type; TypeReference[] bounds = parameter.bounds; if (bounds != null) { for (int i = 0; i < bounds.length; i++) { if (TypeBinding.equalsEquals(bounds[i].resolvedType, bound)) return bounds[i]; } } return null; }
TypeBinding substituteInferenceVariable(InferenceVariable var, TypeBinding substituteType) { if (TypeBinding.equalsEquals(this, var)) return substituteType; return this; }
public boolean equals(Object obj) { if (!(obj instanceof InferenceVariable)) return false; InferenceVariable other = (InferenceVariable) obj; return this.rank == other.rank && this.site == other.site && TypeBinding.equalsEquals(this.typeParameter, other.typeParameter); }
/** Does this type mention any of the given type parameters, except the one at position 'idx'? */ public boolean mentionsAny(TypeBinding[] parameters, int idx) { for (int i = 0; i < parameters.length; i++) if (i != idx) if (TypeBinding.equalsEquals(parameters[i], this)) return true; return false; }
@Override public boolean equals(Object obj) { if (obj instanceof TypeBound) { TypeBound other = (TypeBound) obj; return (this.relation == other.relation) && TypeBinding.equalsEquals(this.left, other.left) && TypeBinding.equalsEquals(this.right, other.right); } return false; }
boolean canSkipInheritedMethods(MethodBinding one, MethodBinding two) { return two == null // already know one is not null || TypeBinding.equalsEquals(one.declaringClass, two.declaringClass); } void checkAbstractMethod(MethodBinding abstractMethod) {
boolean canSkipInheritedMethods(MethodBinding one, MethodBinding two) { return two == null // already know one is not null || TypeBinding.equalsEquals(one.declaringClass, two.declaringClass); } void checkAbstractMethod(MethodBinding abstractMethod) {
/** * Returns true if the type variable is directly bound to a given type */ public boolean isErasureBoundTo(TypeBinding type) { if (TypeBinding.equalsEquals(this.superclass.erasure(), type)) return true; for (int i = 0, length = this.superInterfaces.length; i < length; i++) { if (TypeBinding.equalsEquals(this.superInterfaces[i].erasure(), type)) return true; } return false; }
private ConstraintTypeFormula combineEqualSupers(TypeBound boundS, TypeBound boundT) { // more permutations of: S <: α and α <: T imply ⟨S <: T⟩ if (TypeBinding.equalsEquals(boundS.left, boundT.right)) // came in as: α REL S and T REL α imply ⟨T REL S⟩ return ConstraintTypeFormula.create(boundT.left, boundS.right, boundS.relation, boundT.isSoft||boundS.isSoft); if (TypeBinding.equalsEquals(boundS.right, boundT.left)) // came in as: S REL α and α REL T imply ⟨S REL T⟩ return ConstraintTypeFormula.create(boundS.left, boundT.right, boundS.relation, boundT.isSoft||boundS.isSoft); return null; }
public boolean equals(Object obj) { if (!(obj instanceof InferenceVariable)) return false; InferenceVariable other = (InferenceVariable) obj; return this.rank == other.rank && InferenceContext18.isSameSite(this.site, other.site) && TypeBinding.equalsEquals(this.typeParameter, other.typeParameter); }
@Override public boolean isSubtypeOf(TypeBinding other) { if (TypeBinding.equalsEquals(this, other)) return true; for (int i = 0; i < this.intersectingTypes.length; i++) { if (this.intersectingTypes[i].isSubtypeOf(other)) return true; } return false; }
private boolean siSubI(TypeBinding si, TypeBinding funcI) { if (TypeBinding.equalsEquals(si, funcI) || TypeBinding.equalsEquals(si.original(), funcI)) return true; TypeBinding[] superIfcs = si.superInterfaces(); if (superIfcs == null) return false; for (int i = 0; i < superIfcs.length; i++) { if (siSubI(superIfcs[i], funcI)) return true; } return false; }
private boolean siSuperI(TypeBinding si, TypeBinding funcI) { if (TypeBinding.equalsEquals(si, funcI) || TypeBinding.equalsEquals(si.original(), funcI)) return true; TypeBinding[] superIfcs = funcI.superInterfaces(); if (superIfcs == null) return false; for (int i = 0; i < superIfcs.length; i++) { if (siSuperI(si, superIfcs[i].original())) return true; } return false; }
boolean hasOnlyRawBounds() { if (this.superclass != null && TypeBinding.equalsEquals(this.firstBound, this.superclass)) if (!this.superclass.isRawType()) return false; if (this.superInterfaces != null) for (int i = 0, l = this.superInterfaces.length; i < l; i++) if (!this.superInterfaces[i].isRawType()) return false; return true; }
private boolean siSuperI(TypeBinding si, TypeBinding funcI) { if (TypeBinding.equalsEquals(si, funcI) || TypeBinding.equalsEquals(si.original(), funcI)) return true; TypeBinding[] superIfcs = funcI.superInterfaces(); if (superIfcs == null) return false; for (int i = 0; i < superIfcs.length; i++) { if (siSuperI(si, superIfcs[i].original())) return true; } return false; }
private boolean siSuperI(TypeBinding si, TypeBinding funcI) { if (TypeBinding.equalsEquals(si, funcI) || TypeBinding.equalsEquals(si.original(), funcI)) return true; TypeBinding[] superIfcs = funcI.superInterfaces(); if (superIfcs == null) return false; for (int i = 0; i < superIfcs.length; i++) { if (siSuperI(si, superIfcs[i].original())) return true; } return false; }
private void addDependencies(BoundSet boundSet, Set<InferenceVariable> variableSet, InferenceVariable currentVariable) { if (boundSet.isInstantiated(currentVariable)) return; // not added if (!variableSet.add(currentVariable)) return; // already present for (int j = 0; j < this.inferenceVariables.length; j++) { InferenceVariable nextVariable = this.inferenceVariables[j]; if (TypeBinding.equalsEquals(nextVariable, currentVariable)) continue; if (boundSet.dependsOnResolutionOf(currentVariable, nextVariable)) addDependencies(boundSet, variableSet, nextVariable); } }
@Override public boolean canBeSeenBy(Scope sco) { SourceTypeBinding invocationType = sco.enclosingSourceType(); if (TypeBinding.equalsEquals(invocationType, this)) return true; return ((this.environment.canTypeBeAccessed(this, sco)) && super.canBeSeenBy(sco)); } @Override
/** * Returns the type to use for generic cast, or null if none required */ public TypeBinding genericCast(TypeBinding targetType) { if (TypeBinding.equalsEquals(this, targetType)) return null; TypeBinding targetErasure = targetType.erasure(); // type var get replaced by upper bound if (erasure().findSuperTypeOriginatingFrom(targetErasure) != null) return null; return targetErasure; }
public boolean isBoxingCompatibleWith(TypeBinding expressionType, TypeBinding targetType) { LookupEnvironment environment = environment(); if (environment.globalOptions.sourceLevel < ClassFileConstants.JDK1_5 || expressionType.isBaseType() == targetType.isBaseType()) return false; // check if autoboxed type is compatible TypeBinding convertedType = environment.computeBoxingType(expressionType); return TypeBinding.equalsEquals(convertedType, targetType) || convertedType.isCompatibleWith(targetType, this); }