List of usage examples for org.eclipse.jdt.internal.compiler.lookup Binding WILDCARD_TYPE
int WILDCARD_TYPE
To view the source code for org.eclipse.jdt.internal.compiler.lookup Binding WILDCARD_TYPE.
Click Source Link
From source file:org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.java
License:Open Source License
/** * Answer true if the receiver type can be assigned to the argument type (right) *///from ww w.j av a 2 s.c om private boolean isCompatibleWith0(TypeBinding otherType) { if (otherType == this) return true; if (otherType.id == TypeIds.T_JavaLangObject) return true; // equivalence may allow compatibility with array type through wildcard // bound if (isEquivalentTo(otherType)) return true; switch (otherType.kind()) { case Binding.WILDCARD_TYPE: case Binding.INTERSECTION_TYPE: return false; // should have passed equivalence check above if // wildcard case Binding.TYPE_PARAMETER: // check compatibility with capture of ? super X if (otherType.isCapture()) { CaptureBinding otherCapture = (CaptureBinding) otherType; TypeBinding otherLowerBound; if ((otherLowerBound = otherCapture.lowerBound) != null) { if (otherLowerBound.isArrayType()) return false; return isCompatibleWith(otherLowerBound); } } //$FALL-THROUGH$ case Binding.GENERIC_TYPE: case Binding.TYPE: case Binding.PARAMETERIZED_TYPE: case Binding.RAW_TYPE: switch (kind()) { case Binding.GENERIC_TYPE: case Binding.PARAMETERIZED_TYPE: case Binding.RAW_TYPE: if (erasure() == otherType.erasure()) return false; // should have passed equivalence check // above if same erasure } ReferenceBinding otherReferenceType = (ReferenceBinding) otherType; if (otherReferenceType.isInterface()) // could be annotation type return implementsInterface(otherReferenceType, true); if (isInterface()) // Explicit conversion from an interface // to a class is not allowed return false; return otherReferenceType.isSuperclassOf(this); default: return false; } }
From source file:org.eclipse.jdt.internal.compiler.lookup.Scope.java
License:Open Source License
/** * Returns a type where either all variables or specific ones got discarded. * e.g. List<E> (discarding <E extends Enum<E>) will return: List<? extends Enum<?>> *///from w w w.j a v a 2s . com public static TypeBinding convertEliminatingTypeVariables(TypeBinding originalType, ReferenceBinding genericType, int rank, Set eliminatedVariables) { if ((originalType.tagBits & TagBits.HasTypeVariable) != 0) { switch (originalType.kind()) { case Binding.ARRAY_TYPE: ArrayBinding originalArrayType = (ArrayBinding) originalType; TypeBinding originalLeafComponentType = originalArrayType.leafComponentType; TypeBinding substitute = convertEliminatingTypeVariables(originalLeafComponentType, genericType, rank, eliminatedVariables); // substitute could itself be array type if (substitute != originalLeafComponentType) { return originalArrayType.environment.createArrayType(substitute.leafComponentType(), substitute.dimensions() + originalArrayType.dimensions()); } break; case Binding.PARAMETERIZED_TYPE: ParameterizedTypeBinding paramType = (ParameterizedTypeBinding) originalType; ReferenceBinding originalEnclosing = paramType.enclosingType(); ReferenceBinding substitutedEnclosing = originalEnclosing; if (originalEnclosing != null) { substitutedEnclosing = (ReferenceBinding) convertEliminatingTypeVariables(originalEnclosing, genericType, rank, eliminatedVariables); } TypeBinding[] originalArguments = paramType.arguments; TypeBinding[] substitutedArguments = originalArguments; for (int i = 0, length = originalArguments == null ? 0 : originalArguments.length; i < length; i++) { TypeBinding originalArgument = originalArguments[i]; TypeBinding substitutedArgument = convertEliminatingTypeVariables(originalArgument, paramType.genericType(), i, eliminatedVariables); if (substitutedArgument != originalArgument) { if (substitutedArguments == originalArguments) { System.arraycopy(originalArguments, 0, substitutedArguments = new TypeBinding[length], 0, i); } substitutedArguments[i] = substitutedArgument; } else if (substitutedArguments != originalArguments) { substitutedArguments[i] = originalArgument; } } if (originalEnclosing != substitutedEnclosing || originalArguments != substitutedArguments) { return paramType.environment.createParameterizedType(paramType.genericType(), substitutedArguments, substitutedEnclosing); } break; case Binding.TYPE_PARAMETER: if (genericType == null) { break; } TypeVariableBinding originalVariable = (TypeVariableBinding) originalType; if (eliminatedVariables != null && eliminatedVariables.contains(originalType)) { return originalVariable.environment.createWildcard(genericType, rank, null, null, Wildcard.UNBOUND); } TypeBinding originalUpperBound = originalVariable.upperBound(); if (eliminatedVariables == null) { eliminatedVariables = new HashSet(2); } eliminatedVariables.add(originalVariable); TypeBinding substitutedUpperBound = convertEliminatingTypeVariables(originalUpperBound, genericType, rank, eliminatedVariables); eliminatedVariables.remove(originalVariable); return originalVariable.environment.createWildcard(genericType, rank, substitutedUpperBound, null, Wildcard.EXTENDS); case Binding.RAW_TYPE: break; case Binding.GENERIC_TYPE: ReferenceBinding currentType = (ReferenceBinding) originalType; originalEnclosing = currentType.enclosingType(); substitutedEnclosing = originalEnclosing; if (originalEnclosing != null) { substitutedEnclosing = (ReferenceBinding) convertEliminatingTypeVariables(originalEnclosing, genericType, rank, eliminatedVariables); } originalArguments = currentType.typeVariables(); substitutedArguments = originalArguments; for (int i = 0, length = originalArguments == null ? 0 : originalArguments.length; i < length; i++) { TypeBinding originalArgument = originalArguments[i]; TypeBinding substitutedArgument = convertEliminatingTypeVariables(originalArgument, currentType, i, eliminatedVariables); if (substitutedArgument != originalArgument) { if (substitutedArguments == originalArguments) { System.arraycopy(originalArguments, 0, substitutedArguments = new TypeBinding[length], 0, i); } substitutedArguments[i] = substitutedArgument; } else if (substitutedArguments != originalArguments) { substitutedArguments[i] = originalArgument; } } if (originalEnclosing != substitutedEnclosing || originalArguments != substitutedArguments) { return ((TypeVariableBinding) originalArguments[0]).environment .createParameterizedType(genericType, substitutedArguments, substitutedEnclosing); } break; case Binding.WILDCARD_TYPE: WildcardBinding wildcard = (WildcardBinding) originalType; TypeBinding originalBound = wildcard.bound; TypeBinding substitutedBound = originalBound; if (originalBound != null) { substitutedBound = convertEliminatingTypeVariables(originalBound, genericType, rank, eliminatedVariables); if (substitutedBound != originalBound) { return wildcard.environment.createWildcard(wildcard.genericType, wildcard.rank, substitutedBound, null, wildcard.boundKind); } } break; case Binding.INTERSECTION_TYPE: WildcardBinding intersection = (WildcardBinding) originalType; originalBound = intersection.bound; substitutedBound = originalBound; if (originalBound != null) { substitutedBound = convertEliminatingTypeVariables(originalBound, genericType, rank, eliminatedVariables); } TypeBinding[] originalOtherBounds = intersection.otherBounds; TypeBinding[] substitutedOtherBounds = originalOtherBounds; for (int i = 0, length = originalOtherBounds == null ? 0 : originalOtherBounds.length; i < length; i++) { TypeBinding originalOtherBound = originalOtherBounds[i]; TypeBinding substitutedOtherBound = convertEliminatingTypeVariables(originalOtherBound, genericType, rank, eliminatedVariables); if (substitutedOtherBound != originalOtherBound) { if (substitutedOtherBounds == originalOtherBounds) { System.arraycopy(originalOtherBounds, 0, substitutedOtherBounds = new TypeBinding[length], 0, i); } substitutedOtherBounds[i] = substitutedOtherBound; } else if (substitutedOtherBounds != originalOtherBounds) { substitutedOtherBounds[i] = originalOtherBound; } } if (substitutedBound != originalBound || substitutedOtherBounds != originalOtherBounds) { return intersection.environment.createWildcard(intersection.genericType, intersection.rank, substitutedBound, substitutedOtherBounds, intersection.boundKind); } break; } } return originalType; }
From source file:org.eclipse.jdt.internal.compiler.lookup.Scope.java
License:Open Source License
/** * Returns a type, where original type was substituted using the receiver * parameterized type.//from www . j av a 2 s. com * In raw mode, all parameterized type denoting same original type are converted * to raw types. e.g. * class X <T> { * X<T> foo; * X<String> bar; * } when used in raw fashion, then type of both foo and bar is raw type X. * */ public static TypeBinding substitute(Substitution substitution, TypeBinding originalType) { if (originalType == null) return null; switch (originalType.kind()) { case Binding.TYPE_PARAMETER: return substitution.substitute((TypeVariableBinding) originalType); case Binding.PARAMETERIZED_TYPE: ParameterizedTypeBinding originalParameterizedType = (ParameterizedTypeBinding) originalType; ReferenceBinding originalEnclosing = originalType.enclosingType(); ReferenceBinding substitutedEnclosing = originalEnclosing; if (originalEnclosing != null) { substitutedEnclosing = (ReferenceBinding) substitute(substitution, originalEnclosing); } TypeBinding[] originalArguments = originalParameterizedType.arguments; TypeBinding[] substitutedArguments = originalArguments; if (originalArguments != null) { if (substitution.isRawSubstitution()) { return originalParameterizedType.environment .createRawType(originalParameterizedType.genericType(), substitutedEnclosing); } substitutedArguments = substitute(substitution, originalArguments); } if (substitutedArguments != originalArguments || substitutedEnclosing != originalEnclosing) { return originalParameterizedType.environment.createParameterizedType( originalParameterizedType.genericType(), substitutedArguments, substitutedEnclosing); } break; case Binding.ARRAY_TYPE: ArrayBinding originalArrayType = (ArrayBinding) originalType; TypeBinding originalLeafComponentType = originalArrayType.leafComponentType; TypeBinding substitute = substitute(substitution, originalLeafComponentType); // substitute could itself be array type if (substitute != originalLeafComponentType) { return originalArrayType.environment.createArrayType(substitute.leafComponentType(), substitute.dimensions() + originalType.dimensions()); } break; case Binding.WILDCARD_TYPE: case Binding.INTERSECTION_TYPE: WildcardBinding wildcard = (WildcardBinding) originalType; if (wildcard.boundKind != Wildcard.UNBOUND) { TypeBinding originalBound = wildcard.bound; TypeBinding substitutedBound = substitute(substitution, originalBound); TypeBinding[] originalOtherBounds = wildcard.otherBounds; TypeBinding[] substitutedOtherBounds = substitute(substitution, originalOtherBounds); if (substitutedBound != originalBound || originalOtherBounds != substitutedOtherBounds) { if (originalOtherBounds != null) { /* https://bugs.eclipse.org/bugs/show_bug.cgi?id=347145: the constituent intersecting types have changed in the last round of substitution. Reevaluate the composite intersection type, as there is a possibility of the intersection collapsing into one of the constituents, the other being fully subsumed. */ TypeBinding[] bounds = new TypeBinding[1 + substitutedOtherBounds.length]; bounds[0] = substitutedBound; System.arraycopy(substitutedOtherBounds, 0, bounds, 1, substitutedOtherBounds.length); TypeBinding[] glb = Scope.greaterLowerBound(bounds); // re-evaluate if (glb != null && glb != bounds) { substitutedBound = glb[0]; if (glb.length == 1) { substitutedOtherBounds = null; } else { System.arraycopy(glb, 1, substitutedOtherBounds = new TypeBinding[glb.length - 1], 0, glb.length - 1); } } } return wildcard.environment.createWildcard(wildcard.genericType, wildcard.rank, substitutedBound, substitutedOtherBounds, wildcard.boundKind); } } break; case Binding.TYPE: if (!originalType.isMemberType()) break; ReferenceBinding originalReferenceType = (ReferenceBinding) originalType; originalEnclosing = originalType.enclosingType(); substitutedEnclosing = originalEnclosing; if (originalEnclosing != null) { substitutedEnclosing = (ReferenceBinding) substitute(substitution, originalEnclosing); } // treat as if parameterized with its type variables (non generic type gets 'null' arguments) if (substitutedEnclosing != originalEnclosing) { return substitution.isRawSubstitution() ? substitution.environment().createRawType(originalReferenceType, substitutedEnclosing) : substitution.environment().createParameterizedType(originalReferenceType, null, substitutedEnclosing); } break; case Binding.GENERIC_TYPE: originalReferenceType = (ReferenceBinding) originalType; originalEnclosing = originalType.enclosingType(); substitutedEnclosing = originalEnclosing; if (originalEnclosing != null) { substitutedEnclosing = (ReferenceBinding) substitute(substitution, originalEnclosing); } if (substitution.isRawSubstitution()) { return substitution.environment().createRawType(originalReferenceType, substitutedEnclosing); } // treat as if parameterized with its type variables (non generic type gets 'null' arguments) originalArguments = originalReferenceType.typeVariables(); substitutedArguments = substitute(substitution, originalArguments); return substitution.environment().createParameterizedType(originalReferenceType, substitutedArguments, substitutedEnclosing); } return originalType; }
From source file:org.eclipse.jdt.internal.compiler.lookup.Scope.java
License:Open Source License
public FieldBinding findField(TypeBinding receiverType, char[] fieldName, InvocationSite invocationSite, boolean needResolve, boolean invisibleFieldsOk) { CompilationUnitScope unitScope = compilationUnitScope(); unitScope.recordTypeReference(receiverType); checkArrayField: {//from w w w . j a v a 2 s .c o m TypeBinding leafType; switch (receiverType.kind()) { case Binding.BASE_TYPE: return null; case Binding.WILDCARD_TYPE: case Binding.INTERSECTION_TYPE: case Binding.TYPE_PARAMETER: // capture TypeBinding receiverErasure = receiverType.erasure(); if (!receiverErasure.isArrayType()) break checkArrayField; leafType = receiverErasure.leafComponentType(); break; case Binding.ARRAY_TYPE: leafType = receiverType.leafComponentType(); break; default: break checkArrayField; } if (leafType instanceof ReferenceBinding) if (!((ReferenceBinding) leafType).canBeSeenBy(this)) return new ProblemFieldBinding((ReferenceBinding) leafType, fieldName, ProblemReasons.ReceiverTypeNotVisible); if (CharOperation.equals(fieldName, TypeConstants.LENGTH)) { if ((leafType.tagBits & TagBits.HasMissingType) != 0) { return new ProblemFieldBinding(ArrayBinding.ArrayLength, null, fieldName, ProblemReasons.NotFound); } return ArrayBinding.ArrayLength; } return null; } ReferenceBinding currentType = (ReferenceBinding) receiverType; if (!currentType.canBeSeenBy(this)) return new ProblemFieldBinding(currentType, fieldName, ProblemReasons.ReceiverTypeNotVisible); currentType.initializeForStaticImports(); FieldBinding field = currentType.getField(fieldName, needResolve); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=316456 boolean insideTypeAnnotations = this instanceof MethodScope && ((MethodScope) this).insideTypeAnnotation; if (field != null) { if (invisibleFieldsOk) { return field; } if (invocationSite == null || insideTypeAnnotations ? field.canBeSeenBy(getCurrentPackage()) : field.canBeSeenBy(currentType, invocationSite, this)) return field; return new ProblemFieldBinding(field /* closest match*/, field.declaringClass, fieldName, ProblemReasons.NotVisible); } // collect all superinterfaces of receiverType until the field is found in a supertype ReferenceBinding[] interfacesToVisit = null; int nextPosition = 0; FieldBinding visibleField = null; boolean keepLooking = true; FieldBinding notVisibleField = null; // we could hold onto the not visible field for extra error reporting while (keepLooking) { ReferenceBinding[] itsInterfaces = currentType.superInterfaces(); if (itsInterfaces != null && itsInterfaces != Binding.NO_SUPERINTERFACES) { if (interfacesToVisit == null) { interfacesToVisit = itsInterfaces; nextPosition = interfacesToVisit.length; } else { int itsLength = itsInterfaces.length; if (nextPosition + itsLength >= interfacesToVisit.length) System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[nextPosition + itsLength + 5], 0, nextPosition); nextInterface: for (int a = 0; a < itsLength; a++) { ReferenceBinding next = itsInterfaces[a]; for (int b = 0; b < nextPosition; b++) if (next == interfacesToVisit[b]) continue nextInterface; interfacesToVisit[nextPosition++] = next; } } } if ((currentType = currentType.superclass()) == null) break; unitScope.recordTypeReference(currentType); currentType.initializeForStaticImports(); currentType = (ReferenceBinding) currentType.capture(this, invocationSite == null ? 0 : invocationSite.sourceEnd()); if ((field = currentType.getField(fieldName, needResolve)) != null) { if (invisibleFieldsOk) { return field; } keepLooking = false; if (field.canBeSeenBy(receiverType, invocationSite, this)) { if (visibleField == null) visibleField = field; else return new ProblemFieldBinding(visibleField /* closest match*/, visibleField.declaringClass, fieldName, ProblemReasons.Ambiguous); } else { if (notVisibleField == null) notVisibleField = field; } } } // walk all visible interfaces to find ambiguous references if (interfacesToVisit != null) { ProblemFieldBinding ambiguous = null; done: for (int i = 0; i < nextPosition; i++) { ReferenceBinding anInterface = interfacesToVisit[i]; unitScope.recordTypeReference(anInterface); // no need to capture rcv interface, since member field is going to be static anyway if ((field = anInterface.getField(fieldName, true /*resolve*/)) != null) { if (invisibleFieldsOk) { return field; } if (visibleField == null) { visibleField = field; } else { ambiguous = new ProblemFieldBinding(visibleField /* closest match*/, visibleField.declaringClass, fieldName, ProblemReasons.Ambiguous); break done; } } else { ReferenceBinding[] itsInterfaces = anInterface.superInterfaces(); if (itsInterfaces != null && itsInterfaces != Binding.NO_SUPERINTERFACES) { int itsLength = itsInterfaces.length; if (nextPosition + itsLength >= interfacesToVisit.length) System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[nextPosition + itsLength + 5], 0, nextPosition); nextInterface: for (int a = 0; a < itsLength; a++) { ReferenceBinding next = itsInterfaces[a]; for (int b = 0; b < nextPosition; b++) if (next == interfacesToVisit[b]) continue nextInterface; interfacesToVisit[nextPosition++] = next; } } } } if (ambiguous != null) return ambiguous; } if (visibleField != null) return visibleField; if (notVisibleField != null) { return new ProblemFieldBinding(notVisibleField, currentType, fieldName, ProblemReasons.NotVisible); } return null; }
From source file:org.eclipse.jdt.internal.compiler.lookup.Scope.java
License:Open Source License
protected boolean isAcceptableMethod(MethodBinding one, MethodBinding two) { TypeBinding[] oneParams = one.parameters; TypeBinding[] twoParams = two.parameters; int oneParamsLength = oneParams.length; int twoParamsLength = twoParams.length; if (oneParamsLength == twoParamsLength) { /* Below 1.5, discard any generics we have left in for the method verifier's benefit, (so it can detect method overriding properly in the presence of generic super types.) This is so as to allow us to determine whether we have been handed an acceptable method in 1.4 terms without all the 1.5isms below kicking in and spoiling the party. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=331446 *///from ww w .jav a2 s . c o m boolean applyErasure = environment().globalOptions.sourceLevel < ClassFileConstants.JDK1_5; next: for (int i = 0; i < oneParamsLength; i++) { TypeBinding oneParam = applyErasure ? oneParams[i].erasure() : oneParams[i]; TypeBinding twoParam = applyErasure ? twoParams[i].erasure() : twoParams[i]; if (oneParam == twoParam || oneParam.isCompatibleWith(twoParam)) { if (two.declaringClass.isRawType()) continue next; TypeBinding leafComponentType = two.original().parameters[i].leafComponentType(); TypeBinding originalTwoParam = applyErasure ? leafComponentType.erasure() : leafComponentType; switch (originalTwoParam.kind()) { case Binding.TYPE_PARAMETER: if (((TypeVariableBinding) originalTwoParam).hasOnlyRawBounds()) continue next; //$FALL-THROUGH$ case Binding.WILDCARD_TYPE: case Binding.INTERSECTION_TYPE: case Binding.PARAMETERIZED_TYPE: TypeBinding originalOneParam = one.original().parameters[i].leafComponentType(); switch (originalOneParam.kind()) { case Binding.TYPE: case Binding.GENERIC_TYPE: TypeBinding inheritedTwoParam = oneParam.findSuperTypeOriginatingFrom(twoParam); if (inheritedTwoParam == null || !inheritedTwoParam.leafComponentType().isRawType()) break; return false; case Binding.TYPE_PARAMETER: if (!((TypeVariableBinding) originalOneParam).upperBound().isRawType()) break; return false; case Binding.RAW_TYPE: // originalOneParam is RAW so it cannot be more specific than a wildcard or parameterized type return false; } } } else { if (i == oneParamsLength - 1 && one.isVarargs() && two.isVarargs()) { TypeBinding eType = ((ArrayBinding) twoParam).elementsType(); if (oneParam == eType || oneParam.isCompatibleWith(eType)) return true; // special case to choose between 2 varargs methods when the last arg is Object[] } return false; } } return true; } if (one.isVarargs() && two.isVarargs()) { if (oneParamsLength > twoParamsLength) { // special case when autoboxing makes (int, int...) better than (Object...) but not (int...) or (Integer, int...) if (((ArrayBinding) twoParams[twoParamsLength - 1]).elementsType().id != TypeIds.T_JavaLangObject) return false; } // check that each parameter before the vararg parameters are compatible (no autoboxing allowed here) for (int i = (oneParamsLength > twoParamsLength ? twoParamsLength : oneParamsLength) - 2; i >= 0; i--) if (oneParams[i] != twoParams[i] && !oneParams[i].isCompatibleWith(twoParams[i])) return false; if (parameterCompatibilityLevel(one, twoParams) == NOT_COMPATIBLE && parameterCompatibilityLevel(two, oneParams) == VARARGS_COMPATIBLE) return true; } return false; }
From source file:org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.java
License:Open Source License
/** * Returns true if a type is identical to another one, * or for generic types, true if compared to its raw type. *//*from w ww .ja v a 2 s . c o m*/ public boolean isEquivalentTo(TypeBinding otherType) { if (this == otherType) return true; if (otherType == null) return false; switch (otherType.kind()) { case Binding.WILDCARD_TYPE: case Binding.INTERSECTION_TYPE: return ((WildcardBinding) otherType).boundCheck(this); case Binding.PARAMETERIZED_TYPE: if ((otherType.tagBits & TagBits.HasDirectWildcard) == 0 && (!isMemberType() || !otherType.isMemberType())) return false; // should have been identical ParameterizedTypeBinding otherParamType = (ParameterizedTypeBinding) otherType; if (this != otherParamType.genericType()) return false; if (!isStatic()) { // static member types do not compare their enclosing ReferenceBinding enclosing = enclosingType(); if (enclosing != null) { ReferenceBinding otherEnclosing = otherParamType.enclosingType(); if (otherEnclosing == null) return false; if ((otherEnclosing.tagBits & TagBits.HasDirectWildcard) == 0) { if (enclosing != otherEnclosing) return false; } else { if (!enclosing.isEquivalentTo(otherParamType.enclosingType())) return false; } } } int length = this.typeVariables == null ? 0 : this.typeVariables.length; TypeBinding[] otherArguments = otherParamType.arguments; int otherLength = otherArguments == null ? 0 : otherArguments.length; if (otherLength != length) return false; for (int i = 0; i < length; i++) if (!this.typeVariables[i].isTypeArgumentContainedBy(otherArguments[i])) return false; return true; case Binding.RAW_TYPE: return otherType.erasure() == this; } return false; }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.model.TypeModel.java
License:Open Source License
/** * Get all members which are not roles represented by their TypeModel. * Considers Ast or Bindings, whatever is more appropriate. * Note, that members could again be teams. * * @returns all non-role members for this Team. *///from w w w. j av a 2 s. c o m public TypeModel[] getMembers() { List<TypeModel> list = new LinkedList<TypeModel>(); if (this._ast == null) { if (this._binding.kind() == Binding.TYPE_PARAMETER || this._binding.kind() == Binding.WILDCARD_TYPE || this._binding.kind() == Binding.INTERSECTION_TYPE || this._binding.kind() == Binding.INTERSECTION_TYPE18) return new TypeModel[0]; // has no members //binary type assert this._binding.isBinaryBinding(); // don't used memberTypes() as not to trigger resolving unneeded members. // see tests.compiler.regegression.LookupTest.test044 ReferenceBinding[] memberBindings = ((BinaryTypeBinding) this._binding).unresolvedMemberTypes(); for (int i = 0; i < memberBindings.length; i++) { ReferenceBinding binding = memberBindings[i]; if (binding instanceof UnresolvedReferenceBinding) continue; // has no model yet cannot handle yet. if (binding.isTeam()) list.add(binding.getTeamModel()); else list.add(binding.model); } } else { TypeDeclaration[] members = this._ast.memberTypes; if (members != null) { for (int idx = 0; idx < members.length; idx++) { TypeDeclaration decl = members[idx]; if (decl.isTeam()) list.add(decl.getTeamModel()); else if (decl.isRole()) list.add(decl.getRoleModel()); else list.add(decl.getModel()); } } AbstractMethodDeclaration[] methods = this._ast.methods; if (methods != null) { for (int i = 0; i < methods.length; i++) { if (methods[i].scope != null) { ClassScope[] scopes = methods[i].scope.getAllLocalTypes(); for (int j = 0; j < scopes.length; j++) { TypeDeclaration type = scopes[j].referenceContext; if (type.isTeam()) // very unlikely ;-) list.add(type.getTeamModel()); else if (type.isRole()) list.add(type.getRoleModel()); else list.add(type.getModel()); } } // no scope could mean: // 1. it's a <clinit> // 2. we are before scope creation // (which happens in completeTypeBindings(), last step of beginToCompile). // This is ok, since then we only miss step RoleSplitter, but local types // cannot be teams with roles anyway. } } } return list.toArray(new TypeModel[list.size()]); }