public ReferenceBinding findGroundTargetTypeForElidedLambda(BlockScope blockScope, ParameterizedTypeBinding withWildCards) { // non-wildcard parameterization (9.8) of the target type TypeBinding[] types = withWildCards.getNonWildcardParameterization(blockScope); if (types == null) return null; ReferenceBinding genericType = withWildCards.genericType(); return blockScope.environment().createParameterizedType(genericType, types, withWildCards.enclosingType()); }
@Override public TypeBinding clone(TypeBinding outerType) { return new ParameterizedTypeBinding(this.type, this.arguments, (ReferenceBinding) outerType, this.environment); }
public boolean hasTypeBit(int bit) { TypeBinding erasure = erasure(); if (erasure instanceof ReferenceBinding) return ((ReferenceBinding) erasure).hasTypeBit(bit); return false; }
if (this.hasTypeAnnotations()) { return annotatedDebugName(); buffer.append(debugName()); } else { if (isDeprecated()) buffer.append("deprecated "); //$NON-NLS-1$ if (isPublic()) buffer.append("public "); //$NON-NLS-1$ if (isProtected()) buffer.append("protected "); //$NON-NLS-1$ if (isPrivate()) buffer.append("private "); //$NON-NLS-1$ if (isAbstract() && isClass()) buffer.append("abstract "); //$NON-NLS-1$ if (isStatic() && isNestedType()) buffer.append("static "); //$NON-NLS-1$ if (isFinal()) buffer.append("final "); //$NON-NLS-1$ if (isEnum()) buffer.append("enum "); //$NON-NLS-1$ else if (isAnnotationType()) buffer.append("@interface "); //$NON-NLS-1$ else if (isClass()) buffer.append("class "); //$NON-NLS-1$ else buffer.append("interface "); //$NON-NLS-1$ buffer.append(debugName()); if (enclosingType() != null) { buffer.append("\n\tenclosing type : "); //$NON-NLS-1$ buffer.append(enclosingType().debugName());
this.singleAbstractMethod = new MethodBinding[2]; if (!isValidBinding()) return null; final ReferenceBinding genericType = genericType(); MethodBinding theAbstractMethod = genericType.getSingleAbstractMethod(scope, replaceWildcards); if (theAbstractMethod == null || !theAbstractMethod.isValidBinding()) TypeBinding [] types = this.arguments; if (replaceWildcards) { types = getNonWildcardParameterization(scope); if (types == null) return this.singleAbstractMethod[index] = new ProblemMethodBinding(TypeConstants.ANONYMOUS_METHOD, null, ProblemReasons.NotAWellFormedParameterizedType); return this.singleAbstractMethod[index] = new ProblemMethodBinding(TypeConstants.ANONYMOUS_METHOD, null, ProblemReasons.NotAWellFormedParameterizedType); ReferenceBinding substitutedDeclaringType = (ReferenceBinding) declaringType.findSuperTypeOriginatingFrom(theAbstractMethod.declaringClass); MethodBinding [] choices = substitutedDeclaringType.getMethods(theAbstractMethod.selector); for (int i = 0, length = choices.length; i < length; i++) {
for (int i = 0, length = parameterizedTypeBindings == null ? 0 : parameterizedTypeBindings.length; i < length; i++) { ParameterizedTypeBinding parameterizedType = parameterizedTypeBindings[i]; if (parameterizedType.actualType() != genericTypeToMatch) { //$IDENTITY-COMPARISON$ continue; if (parameterizedType.enclosingType() != enclosingTypeToMatch //$IDENTITY-COMPARISON$ || !Util.effectivelyEqual(parameterizedType.typeArguments(), typeArgumentsToMatch)) continue; if (Util.effectivelyEqual(annotations, parameterizedType.getTypeAnnotations())) return parameterizedType;
public void checkBounds(Scope scope) { if (this.resolvedType == null) return; if (this.resolvedType.leafComponentType() instanceof ParameterizedTypeBinding) { ParameterizedTypeBinding parameterizedType = (ParameterizedTypeBinding) this.resolvedType.leafComponentType(); ReferenceBinding currentType = parameterizedType.genericType(); TypeVariableBinding[] typeVariables = currentType.typeVariables(); TypeBinding[] argTypes = parameterizedType.arguments; if (argTypes != null && typeVariables != null) { // may be null in error cases parameterizedType.boundCheck(scope, this.typeArguments); } } } /**
public TypeBinding[] inferElidedTypes(ParameterizedTypeBinding parameterizedType, final Scope scope) { ReferenceBinding genericType = parameterizedType.genericType(); ReferenceBinding enclosingType = parameterizedType.enclosingType(); ParameterizedTypeBinding allocationType = scope.environment().createParameterizedType(genericType, genericType.typeVariables(), enclosingType); /* Given the allocation type and the arguments to the constructor, see if we can synthesize a generic static factory method that would, given the argument types and the invocation site, manufacture a parameterized object of type allocationType. If we are successful then by design and construction, the parameterization of the return type of the factory method is identical to the types elided in the <>. */ MethodBinding factory = scope.getStaticFactory(allocationType, enclosingType, this.argumentTypes, this); if (factory instanceof ParameterizedGenericMethodBinding && factory.isValidBinding()) { ParameterizedGenericMethodBinding genericFactory = (ParameterizedGenericMethodBinding) factory; this.inferredReturnType = genericFactory.inferredReturnType; return ((ParameterizedTypeBinding)factory.returnType).arguments; } return null; }
ParameterizedTypeBinding cachedType = cachedInfo[index]; if (cachedType == null) break nextCachedType; if (cachedType.actualType() != genericType) continue nextCachedType; // remain of unresolved type if (cachedType.enclosingType() != enclosingType) continue nextCachedType; TypeBinding[] cachedArguments = cachedType.arguments; int cachedArgLength = cachedArguments == null ? 0 : cachedArguments.length; ParameterizedTypeBinding parameterizedType = new ParameterizedTypeBinding(genericType,typeArguments, enclosingType, this); cachedInfo[index] = parameterizedType; return parameterizedType;
ParameterizedTypeBinding paramType = (ParameterizedTypeBinding) this; ParameterizedTypeBinding otherParamType = (ParameterizedTypeBinding) otherType; if (paramType.actualType() != otherParamType.actualType()) return false; if (!paramType.isStatic()) { // static member types do not compare their enclosing ReferenceBinding enclosing = enclosingType(); if (enclosing != null) { ReferenceBinding otherEnclosing = otherParamType .enclosingType(); if (otherEnclosing == null) return false; return false; } else { if (!enclosing.isEquivalentTo(otherParamType.enclosingType())) return false;
/** * @see org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding#syntheticOuterLocalVariables() */ @Override public SyntheticArgumentBinding[] syntheticOuterLocalVariables() { return genericType().syntheticOuterLocalVariables(); }
/** * @see org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding#getField(char[], boolean) */ public FieldBinding getField(char[] fieldName, boolean needResolve) { fields(); // ensure fields have been initialized... must create all at once unlike methods return ReferenceBinding.binarySearch(fieldName, this.fields); }
/** * @see org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding#createParameterizedMethod(org.eclipse.jdt.internal.compiler.lookup.MethodBinding) */ public ParameterizedMethodBinding createParameterizedMethod(MethodBinding originalMethod) { if (originalMethod.typeVariables == Binding.NO_TYPE_VARIABLES || originalMethod.isStatic()) { return super.createParameterizedMethod(originalMethod); } return this.environment.createParameterizedGenericMethod(originalMethod, this); }
public ParameterizedTypeBinding getParameterizedType(ReferenceBinding genericType, TypeBinding[] typeArguments, ReferenceBinding enclosingType, AnnotationBinding [] annotations) { if (genericType.hasTypeAnnotations()) // @NonNull (List<String>) and not (@NonNull List)<String> throw new IllegalStateException(); ParameterizedTypeBinding parameterizedType = this.parameterizedTypes.get(genericType, typeArguments, enclosingType, annotations); if (parameterizedType != null) return parameterizedType; ParameterizedTypeBinding nakedType = super.getParameterizedType(genericType, typeArguments, enclosingType); if (!haveTypeAnnotations(genericType, enclosingType, typeArguments, annotations)) return nakedType; parameterizedType = new ParameterizedTypeBinding(genericType, typeArguments, enclosingType, this.environment); parameterizedType.id = nakedType.id; parameterizedType.setTypeAnnotations(annotations, this.isAnnotationBasedNullAnalysisEnabled); this.parameterizedTypes.put(genericType, typeArguments, enclosingType, parameterizedType); return (ParameterizedTypeBinding) cacheDerivedType(genericType, nakedType, parameterizedType); }
@Override public void checkBounds(Scope scope) { if (this.resolvedType == null) return; if (this.resolvedType.leafComponentType() instanceof ParameterizedTypeBinding) { ParameterizedTypeBinding parameterizedType = (ParameterizedTypeBinding) this.resolvedType.leafComponentType(); TypeBinding[] argTypes = parameterizedType.arguments; if (argTypes != null) { // may be null in error cases parameterizedType.boundCheck(scope, this.typeArguments); } } }
case TypeConstants.CONSTRAINT_SUPER : default: formalEquivalent = this.findSuperTypeOriginatingFrom(actualType); if (formalEquivalent == null) return; actualEquivalent = actualType;
if (this.hasTypeAnnotations()) { return annotatedDebugName(); buffer.append(debugName()); } else { if (isDeprecated()) buffer.append("deprecated "); //$NON-NLS-1$ if (isPublic()) buffer.append("public "); //$NON-NLS-1$ if (isProtected()) buffer.append("protected "); //$NON-NLS-1$ if (isPrivate()) buffer.append("private "); //$NON-NLS-1$ if (isAbstract() && isClass()) buffer.append("abstract "); //$NON-NLS-1$ if (isStatic() && isNestedType()) buffer.append("static "); //$NON-NLS-1$ if (isFinal()) buffer.append("final "); //$NON-NLS-1$ if (isEnum()) buffer.append("enum "); //$NON-NLS-1$ else if (isAnnotationType()) buffer.append("@interface "); //$NON-NLS-1$ else if (isClass()) buffer.append("class "); //$NON-NLS-1$ else buffer.append("interface "); //$NON-NLS-1$ buffer.append(debugName()); if (enclosingType() != null) { buffer.append("\n\tenclosing type : "); //$NON-NLS-1$ buffer.append(enclosingType().debugName());
this.singleAbstractMethod = new MethodBinding[2]; if (!isValidBinding()) return null; final ReferenceBinding genericType = genericType(); MethodBinding theAbstractMethod = genericType.getSingleAbstractMethod(scope, replaceWildcards); if (theAbstractMethod == null || !theAbstractMethod.isValidBinding()) TypeBinding [] types = this.arguments; if (replaceWildcards) { types = getNonWildcardParameterization(scope); if (types == null) return this.singleAbstractMethod[index] = new ProblemMethodBinding(TypeConstants.ANONYMOUS_METHOD, null, ProblemReasons.NotAWellFormedParameterizedType); return this.singleAbstractMethod[index] = new ProblemMethodBinding(TypeConstants.ANONYMOUS_METHOD, null, ProblemReasons.NotAWellFormedParameterizedType); ReferenceBinding substitutedDeclaringType = (ReferenceBinding) declaringType.findSuperTypeOriginatingFrom(theAbstractMethod.declaringClass); MethodBinding [] choices = substitutedDeclaringType.getMethods(theAbstractMethod.selector); for (int i = 0, length = choices.length; i < length; i++) {
for (int i = 0, length = parameterizedTypeBindings == null ? 0 : parameterizedTypeBindings.length; i < length; i++) { ParameterizedTypeBinding parameterizedType = parameterizedTypeBindings[i]; if (parameterizedType.actualType() != genericTypeToMatch) { //$IDENTITY-COMPARISON$ continue; if (parameterizedType.enclosingType() != enclosingTypeToMatch //$IDENTITY-COMPARISON$ || !Util.effectivelyEqual(parameterizedType.typeArguments(), typeArgumentsToMatch)) continue; if (Util.effectivelyEqual(annotations, parameterizedType.getTypeAnnotations())) return parameterizedType;
public void checkBounds(Scope scope) { if (this.resolvedType == null) return; if (this.resolvedType.leafComponentType() instanceof ParameterizedTypeBinding) { ParameterizedTypeBinding parameterizedType = (ParameterizedTypeBinding) this.resolvedType.leafComponentType(); ReferenceBinding currentType = parameterizedType.genericType(); TypeVariableBinding[] typeVariables = currentType.typeVariables(); TypeBinding[] argTypes = parameterizedType.arguments; if (argTypes != null && typeVariables != null) { // may be null in error cases parameterizedType.boundCheck(scope, this.typeArguments); } } } /**