Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 226292 Details for
Bug 399263
[1.8][compiler][internal] Turn MethodVerifier15.doesMethodOverride into a static method.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Untested patch from Anirbhan
apatch.txt (text/plain), 29.96 KB, created by
Srikanth Sankaran
on 2013-01-29 22:56:58 EST
(
hide
)
Description:
Untested patch from Anirbhan
Filename:
MIME Type:
Creator:
Srikanth Sankaran
Created:
2013-01-29 22:56:58 EST
Size:
29.96 KB
patch
obsolete
>diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ImplicitNullAnnotationVerifier.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ImplicitNullAnnotationVerifier.java >index 664455c..4666891 100644 >--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ImplicitNullAnnotationVerifier.java >+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ImplicitNullAnnotationVerifier.java >@@ -364,11 +364,11 @@ > } > } > > // ==== minimal set of utility methods previously from MethodVerifier15: ==== > >- boolean areParametersEqual(MethodBinding one, MethodBinding two) { >+ static boolean areParametersEqual(MethodBinding one, MethodBinding two) { > TypeBinding[] oneArgs = one.parameters; > TypeBinding[] twoArgs = two.parameters; > if (oneArgs == twoArgs) return true; > > int length = oneArgs.length; >@@ -408,11 +408,11 @@ > return false; // no remaining parameter can be a Parameterized type (if one has been converted then all RAW types must be converted) > } > } > return true; > } >- boolean areTypesEqual(TypeBinding one, TypeBinding two) { >+ static boolean areTypesEqual(TypeBinding one, TypeBinding two) { > if (one == two) return true; > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=329584 > switch(one.kind()) { > case Binding.TYPE: > switch (two.kind()) { >diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java >index 1827194..4b2f5f8 100644 >--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java >+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java >@@ -65,13 +65,29 @@ > this.environment = environment; > this.allowCompatibleReturnTypes = > environment.globalOptions.complianceLevel >= ClassFileConstants.JDK1_5 > && environment.globalOptions.sourceLevel < ClassFileConstants.JDK1_5; > } >-boolean areMethodsCompatible(MethodBinding one, MethodBinding two) { >- return isParameterSubsignature(one, two) && areReturnTypesCompatible(one, two); >+//boolean areMethodsCompatible(MethodBinding one, MethodBinding two) { >+// return isParameterSubsignature(one, two) && areReturnTypesCompatible(one, two); >+//} >+ >+static boolean areMethodsCompatible(MethodBinding one, MethodBinding two, LookupEnvironment localEnvironment) { >+ // use the original methods to test compatibility, but do not check visibility, etc >+ one = one.original(); >+ two = one.findOriginalInheritedMethod(two); >+ >+ if (two == null) >+ return false; // method's declaringClass does not inherit from inheritedMethod's >+ >+ return isParameterSubsignature(one, two, localEnvironment); > } >+ >+boolean areMethodsCompatible(MethodBinding one, MethodBinding two) { >+ return areMethodsCompatible(one, two, this.environment); >+} >+ > boolean areReturnTypesCompatible(MethodBinding one, MethodBinding two) { > if (one.returnType == two.returnType) return true; > > if (areTypesEqual(one.returnType, two.returnType)) return true; > >@@ -465,90 +481,10 @@ > compare concrete's exceptions against each abstract method > else > complain about missing implementation only if type is NOT an interface or abstract > */ > abstract void checkMethods(); >-private void _unusedCheckMethods() { >- boolean mustImplementAbstractMethods = mustImplementAbstractMethods(); >- boolean skipInheritedMethods = mustImplementAbstractMethods && canSkipInheritedMethods(); // have a single concrete superclass so only check overridden methods >- boolean isOrEnclosedByPrivateType = this.type.isOrEnclosedByPrivateType(); >- char[][] methodSelectors = this.inheritedMethods.keyTable; >- nextSelector : for (int s = methodSelectors.length; --s >= 0;) { >- if (methodSelectors[s] == null) continue nextSelector; >- >- MethodBinding[] current = (MethodBinding[]) this.currentMethods.get(methodSelectors[s]); >- MethodBinding[] inherited = (MethodBinding[]) this.inheritedMethods.valueTable[s]; >- >- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=296660, if current type is exposed, >- // inherited methods of super classes are too. current != null case handled below. >- if (current == null && !isOrEnclosedByPrivateType) { >- int length = inherited.length; >- for (int i = 0; i < length; i++){ >- inherited[i].original().modifiers |= ExtraCompilerModifiers.AccLocallyUsed; >- } >- } >- >- if (current == null && skipInheritedMethods) >- continue nextSelector; >- >- if (inherited.length == 1 && current == null) { // handle the common case >- if (mustImplementAbstractMethods && inherited[0].isAbstract()) >- checkAbstractMethod(inherited[0]); >- continue nextSelector; >- } >- >- int index = -1; >- MethodBinding[] matchingInherited = new MethodBinding[inherited.length]; >- if (current != null) { >- for (int i = 0, length1 = current.length; i < length1; i++) { >- MethodBinding currentMethod = current[i]; >- for (int j = 0, length2 = inherited.length; j < length2; j++) { >- MethodBinding inheritedMethod = computeSubstituteMethod(inherited[j], currentMethod); >- if (inheritedMethod != null) { >- if (isParameterSubsignature(currentMethod, inheritedMethod)) { >- matchingInherited[++index] = inheritedMethod; >- inherited[j] = null; // do not want to find it again >- } >- } >- } >- if (index >= 0) { >- checkAgainstInheritedMethods(currentMethod, matchingInherited, index + 1, inherited); // pass in the length of matching >- while (index >= 0) matchingInherited[index--] = null; // clear the contents of the matching methods >- } >- } >- } >- >- for (int i = 0, length = inherited.length; i < length; i++) { >- MethodBinding inheritedMethod = inherited[i]; >- if (inheritedMethod == null) continue; >- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=296660, if current type is exposed, >- // inherited methods of super classes are too. current == null case handled already. >- if (!isOrEnclosedByPrivateType && current != null) { >- inheritedMethod.original().modifiers |= ExtraCompilerModifiers.AccLocallyUsed; >- } >- matchingInherited[++index] = inheritedMethod; >- for (int j = i + 1; j < length; j++) { >- MethodBinding otherInheritedMethod = inherited[j]; >- if (canSkipInheritedMethods(inheritedMethod, otherInheritedMethod)) >- continue; >- otherInheritedMethod = computeSubstituteMethod(otherInheritedMethod, inheritedMethod); >- if (otherInheritedMethod != null) { >- if (isParameterSubsignature(inheritedMethod, otherInheritedMethod)) { >- matchingInherited[++index] = otherInheritedMethod; >- inherited[j] = null; // do not want to find it again >- } >- } >- } >- if (index == -1) continue; >- if (index > 0) >- checkInheritedMethods(matchingInherited, index + 1, null/*FIXME: required value not provided*/); // pass in the length of matching >- else if (mustImplementAbstractMethods && matchingInherited[0].isAbstract()) >- checkAbstractMethod(matchingInherited[0]); >- while (index >= 0) matchingInherited[index--] = null; // clear the contents of the matching methods >- } >- } >-} > > void checkPackagePrivateAbstractMethod(MethodBinding abstractMethod) { > // check that the inherited abstract method (package private visibility) is implemented within the same package > PackageBinding necessaryPackage = abstractMethod.declaringClass.fPackage; > if (necessaryPackage == this.type.fPackage) return; // not a problem >@@ -755,12 +691,69 @@ > MethodBinding computeSubstituteMethod(MethodBinding inheritedMethod, MethodBinding currentMethod) { > if (inheritedMethod == null) return null; > if (currentMethod.parameters.length != inheritedMethod.parameters.length) return null; // no match > return inheritedMethod; > } >+static MethodBinding computeSubstituteMethod(MethodBinding inheritedMethod, MethodBinding currentMethod, LookupEnvironment localEnvironment) { >+ if (inheritedMethod == null) return null; >+ if (currentMethod.parameters.length != inheritedMethod.parameters.length) return null; // no match > >-boolean couldMethodOverride(MethodBinding method, MethodBinding inheritedMethod) { >+ // due to hierarchy & compatibility checks, we need to ensure these 2 methods are resolved >+ if (currentMethod.declaringClass instanceof BinaryTypeBinding) >+ ((BinaryTypeBinding) currentMethod.declaringClass).resolveTypesFor(currentMethod); >+ if (inheritedMethod.declaringClass instanceof BinaryTypeBinding) >+ ((BinaryTypeBinding) inheritedMethod.declaringClass).resolveTypesFor(inheritedMethod); >+ >+ TypeVariableBinding[] inheritedTypeVariables = inheritedMethod.typeVariables; >+ int inheritedLength = inheritedTypeVariables.length; >+ if (inheritedLength == 0) return inheritedMethod; // no substitution needed >+ TypeVariableBinding[] typeVariables = currentMethod.typeVariables; >+ int length = typeVariables.length; >+ if (length == 0) >+ return inheritedMethod.asRawMethod(localEnvironment); >+ if (length != inheritedLength) >+ return inheritedMethod; // no match JLS 8.4.2 >+ >+ // interface I { <T> void foo(T t); } >+ // class X implements I { public <T extends I> void foo(T t) {} } >+ // for the above case, we do not want to answer the substitute method since its not a match >+ TypeBinding[] arguments = new TypeBinding[length]; >+ System.arraycopy(typeVariables, 0, arguments, 0, length); >+ ParameterizedGenericMethodBinding substitute = >+ localEnvironment.createParameterizedGenericMethod(inheritedMethod, arguments); >+ for (int i = 0; i < inheritedLength; i++) { >+ TypeVariableBinding inheritedTypeVariable = inheritedTypeVariables[i]; >+ TypeBinding argument = arguments[i]; >+ if (argument instanceof TypeVariableBinding) { >+ TypeVariableBinding typeVariable = (TypeVariableBinding) argument; >+ if (typeVariable.firstBound == inheritedTypeVariable.firstBound) { >+ if (typeVariable.firstBound == null) >+ continue; // both are null >+ } else if (typeVariable.firstBound != null && inheritedTypeVariable.firstBound != null) { >+ if (typeVariable.firstBound.isClass() != inheritedTypeVariable.firstBound.isClass()) >+ return inheritedMethod; // not a match >+ } >+ if (Scope.substitute(substitute, inheritedTypeVariable.superclass) != typeVariable.superclass) >+ return inheritedMethod; // not a match >+ int interfaceLength = inheritedTypeVariable.superInterfaces.length; >+ ReferenceBinding[] interfaces = typeVariable.superInterfaces; >+ if (interfaceLength != interfaces.length) >+ return inheritedMethod; // not a match >+ next : for (int j = 0; j < interfaceLength; j++) { >+ TypeBinding superType = Scope.substitute(substitute, inheritedTypeVariable.superInterfaces[j]); >+ for (int k = 0; k < interfaceLength; k++) >+ if (superType == interfaces[k]) >+ continue next; >+ return inheritedMethod; // not a match >+ } >+ } else if (inheritedTypeVariable.boundCheck(substitute, argument) != TypeConstants.OK) { >+ return inheritedMethod; >+ } >+ } >+ return substitute; >+} >+static boolean couldMethodOverride(MethodBinding method, MethodBinding inheritedMethod) { > if (!org.eclipse.jdt.core.compiler.CharOperation.equals(method.selector, inheritedMethod.selector)) > return false; > if (method == inheritedMethod || method.isStatic() || inheritedMethod.isStatic()) > return false; > if (inheritedMethod.isPrivate()) >@@ -774,23 +767,17 @@ > return false; > } > return true; > } > >-// Answer whether the method overrides the inheritedMethod >-// Check the necessary visibility rules & inheritance from the inheritedMethod's declaringClass >-// See isMethodSubsignature() for parameter comparisons >+ >+public static boolean doesMethodOverride(MethodBinding method, MethodBinding inheritedMethod, LookupEnvironment localEnvironment) { >+ return couldMethodOverride(method, inheritedMethod) && areMethodsCompatible(method, inheritedMethod, localEnvironment); >+} >+ > public boolean doesMethodOverride(MethodBinding method, MethodBinding inheritedMethod) { >- if (!couldMethodOverride(method, inheritedMethod)) >- return false; >- >- inheritedMethod = inheritedMethod.original(); >- TypeBinding match = method.declaringClass.findSuperTypeOriginatingFrom(inheritedMethod.declaringClass); >- if (!(match instanceof ReferenceBinding)) >- return false; // method's declaringClass does not inherit from inheritedMethod's >- >- return isParameterSubsignature(method, inheritedMethod); >+ return doesMethodOverride(method, inheritedMethod) && areMethodsCompatible(method, inheritedMethod, this.environment); > } > > SimpleSet findSuperinterfaceCollisions(ReferenceBinding superclass, ReferenceBinding[] superInterfaces) { > return null; // noop in 1.4 > } >@@ -881,16 +868,19 @@ > return areParametersEqual(existingMethod, inheritedMethod) && existingMethod.declaringClass.implementsInterface(superType, true); > } > > public boolean isMethodSubsignature(MethodBinding method, MethodBinding inheritedMethod) { > return org.eclipse.jdt.core.compiler.CharOperation.equals(method.selector, inheritedMethod.selector) >- && isParameterSubsignature(method, inheritedMethod); >+ && isParameterSubsignature(method, inheritedMethod, this.environment); > } >- >-boolean isParameterSubsignature(MethodBinding method, MethodBinding inheritedMethod) { >- return areParametersEqual(method, inheritedMethod); >+static boolean isParameterSubsignature(MethodBinding method, MethodBinding inheritedMethod, LookupEnvironment localEnvironment) { >+ MethodBinding substitute = computeSubstituteMethod(inheritedMethod, method, localEnvironment); >+ return substitute != null && isSubstituteParameterSubsignature(method, substitute, localEnvironment); > } >+//boolean isParameterSubsignature(MethodBinding method, MethodBinding inheritedMethod) { >+// return areParametersEqual(method, inheritedMethod); >+//} > > boolean isSameClassOrSubclassOf(ReferenceBinding testClass, ReferenceBinding superclass) { > do { > if (testClass == superclass) return true; > } while ((testClass = testClass.superclass()) != null); >@@ -986,6 +976,54 @@ > buffer.append('\n'); > buffer.append("\t-inherited methods: "); //$NON-NLS-1$ > buffer.append(this.inheritedMethods); > return buffer.toString(); > } >+ >+protected static boolean isSubstituteParameterSubsignature(MethodBinding method, MethodBinding substituteMethod, LookupEnvironment environment) { >+ if (!areParametersEqual(method, substituteMethod)) { >+ // method can still override substituteMethod in cases like : >+ // <U extends Number> void c(U u) {} >+ // @Override void c(Number n) {} >+ // but method cannot have a "generic-enabled" parameter type >+ if (substituteMethod.hasSubstitutedParameters() && method.areParameterErasuresEqual(substituteMethod)) >+ return method.typeVariables == Binding.NO_TYPE_VARIABLES && !hasGenericParameter(method); >+ >+ // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=279836 >+ if (method.declaringClass.isRawType() && substituteMethod.declaringClass.isRawType()) >+ if (method.hasSubstitutedParameters() && substituteMethod.hasSubstitutedParameters()) >+ return areMethodsCompatible(method, substituteMethod, environment); >+ >+ return false; >+ } >+ >+ if (substituteMethod instanceof ParameterizedGenericMethodBinding) { >+ if (method.typeVariables != Binding.NO_TYPE_VARIABLES) >+ return !((ParameterizedGenericMethodBinding) substituteMethod).isRaw; >+ // since substituteMethod has substituted type variables, method cannot have a generic signature AND no variables -> its a name clash if it does >+ return !hasGenericParameter(method); >+ } >+ >+ // if method has its own variables, then substituteMethod failed bounds check in computeSubstituteMethod() >+ return method.typeVariables == Binding.NO_TYPE_VARIABLES; >+} >+ >+protected boolean isSubstituteParameterSubsignature(MethodBinding method, MethodBinding substituteMethod) { >+ return isSubstituteParameterSubsignature(method, substituteMethod, this.environment); >+} >+ >+static boolean hasGenericParameter(MethodBinding method) { >+ if (method.genericSignature() == null) return false; >+ >+ // may be only the return type that is generic, need to check parameters >+ TypeBinding[] params = method.parameters; >+ for (int i = 0, l = params.length; i < l; i++) { >+ TypeBinding param = params[i].leafComponentType(); >+ if (param instanceof ReferenceBinding) { >+ int modifiers = ((ReferenceBinding) param).modifiers; >+ if ((modifiers & ExtraCompilerModifiers.AccGenericSignature) != 0) >+ return true; >+ } >+ } >+ return false; >+} > } >diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java >index a52430d..4467fac 100644 >--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java >+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java >@@ -38,20 +38,11 @@ > class MethodVerifier15 extends MethodVerifier { > > MethodVerifier15(LookupEnvironment environment) { > super(environment); > } >-boolean areMethodsCompatible(MethodBinding one, MethodBinding two) { >- // use the original methods to test compatibility, but do not check visibility, etc >- one = one.original(); >- two = one.findOriginalInheritedMethod(two); > >- if (two == null) >- return false; // method's declaringClass does not inherit from inheritedMethod's >- >- return isParameterSubsignature(one, two); >-} > boolean areReturnTypesCompatible(MethodBinding one, MethodBinding two) { > if (one.returnType == two.returnType) return true; > if (this.type.scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5) { > return areReturnTypesCompatible0(one, two); > } else { >@@ -598,11 +589,11 @@ > skip[idx] = true; > isOverridden[idx] = true; > return true; > } > } else if (specificIsInterface == generalIsInterface) { >- if (isParameterSubsignature(specific, general)) { >+ if (isParameterSubsignature(specific, general, this.environment)) { > skip[idx] = true; > isOverridden[idx] = specific.declaringClass.isCompatibleWith(general.declaringClass); > return true; > } > } >@@ -680,67 +671,13 @@ > } > } > } > } > MethodBinding computeSubstituteMethod(MethodBinding inheritedMethod, MethodBinding currentMethod) { >- if (inheritedMethod == null) return null; >- if (currentMethod.parameters.length != inheritedMethod.parameters.length) return null; // no match >- >- // due to hierarchy & compatibility checks, we need to ensure these 2 methods are resolved >- if (currentMethod.declaringClass instanceof BinaryTypeBinding) >- ((BinaryTypeBinding) currentMethod.declaringClass).resolveTypesFor(currentMethod); >- if (inheritedMethod.declaringClass instanceof BinaryTypeBinding) >- ((BinaryTypeBinding) inheritedMethod.declaringClass).resolveTypesFor(inheritedMethod); >- >- TypeVariableBinding[] inheritedTypeVariables = inheritedMethod.typeVariables; >- int inheritedLength = inheritedTypeVariables.length; >- if (inheritedLength == 0) return inheritedMethod; // no substitution needed >- TypeVariableBinding[] typeVariables = currentMethod.typeVariables; >- int length = typeVariables.length; >- if (length == 0) >- return inheritedMethod.asRawMethod(this.environment); >- if (length != inheritedLength) >- return inheritedMethod; // no match JLS 8.4.2 >- >- // interface I { <T> void foo(T t); } >- // class X implements I { public <T extends I> void foo(T t) {} } >- // for the above case, we do not want to answer the substitute method since its not a match >- TypeBinding[] arguments = new TypeBinding[length]; >- System.arraycopy(typeVariables, 0, arguments, 0, length); >- ParameterizedGenericMethodBinding substitute = >- this.environment.createParameterizedGenericMethod(inheritedMethod, arguments); >- for (int i = 0; i < inheritedLength; i++) { >- TypeVariableBinding inheritedTypeVariable = inheritedTypeVariables[i]; >- TypeBinding argument = arguments[i]; >- if (argument instanceof TypeVariableBinding) { >- TypeVariableBinding typeVariable = (TypeVariableBinding) argument; >- if (typeVariable.firstBound == inheritedTypeVariable.firstBound) { >- if (typeVariable.firstBound == null) >- continue; // both are null >- } else if (typeVariable.firstBound != null && inheritedTypeVariable.firstBound != null) { >- if (typeVariable.firstBound.isClass() != inheritedTypeVariable.firstBound.isClass()) >- return inheritedMethod; // not a match >- } >- if (Scope.substitute(substitute, inheritedTypeVariable.superclass) != typeVariable.superclass) >- return inheritedMethod; // not a match >- int interfaceLength = inheritedTypeVariable.superInterfaces.length; >- ReferenceBinding[] interfaces = typeVariable.superInterfaces; >- if (interfaceLength != interfaces.length) >- return inheritedMethod; // not a match >- next : for (int j = 0; j < interfaceLength; j++) { >- TypeBinding superType = Scope.substitute(substitute, inheritedTypeVariable.superInterfaces[j]); >- for (int k = 0; k < interfaceLength; k++) >- if (superType == interfaces[k]) >- continue next; >- return inheritedMethod; // not a match >- } >- } else if (inheritedTypeVariable.boundCheck(substitute, argument) != TypeConstants.OK) { >- return inheritedMethod; >- } >- } >- return substitute; >+ return computeSubstituteMethod(inheritedMethod, currentMethod, this.environment); > } >+ > boolean detectInheritedNameClash(MethodBinding inherited, MethodBinding otherInherited) { > if (!inherited.areParameterErasuresEqual(otherInherited)) > return false; > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=322001 > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=323693 >@@ -797,13 +734,11 @@ > original = inherited.original(); // For error reporting use, inherited.original() > problemReporter(current).methodNameClash(current, inherited.declaringClass.isRawType() ? inherited : original, severity); > if (severity == ProblemSeverities.Warning) return false; > return true; > } >-public boolean doesMethodOverride(MethodBinding method, MethodBinding inheritedMethod) { >- return couldMethodOverride(method, inheritedMethod) && areMethodsCompatible(method, inheritedMethod); >-} >+ > boolean doTypeVariablesClash(MethodBinding one, MethodBinding substituteTwo) { > // one has type variables and substituteTwo did not pass bounds check in computeSubstituteMethod() > return one.typeVariables != Binding.NO_TYPE_VARIABLES && !(substituteTwo instanceof ParameterizedGenericMethodBinding); > } > SimpleSet findSuperinterfaceCollisions(ReferenceBinding superclass, ReferenceBinding[] superInterfaces) { >@@ -873,25 +808,10 @@ > } > } > } > return copy; > } >-boolean hasGenericParameter(MethodBinding method) { >- if (method.genericSignature() == null) return false; >- >- // may be only the return type that is generic, need to check parameters >- TypeBinding[] params = method.parameters; >- for (int i = 0, l = params.length; i < l; i++) { >- TypeBinding param = params[i].leafComponentType(); >- if (param instanceof ReferenceBinding) { >- int modifiers = ((ReferenceBinding) param).modifiers; >- if ((modifiers & ExtraCompilerModifiers.AccGenericSignature) != 0) >- return true; >- } >- } >- return false; >-} > boolean isAcceptableReturnTypeOverride(MethodBinding currentMethod, MethodBinding inheritedMethod) { > // called when currentMethod's return type is compatible with inheritedMethod's return type > > if (inheritedMethod.declaringClass.isRawType()) > return true; // since the inheritedMethod comes from a raw type, the return type is always acceptable >@@ -931,44 +851,11 @@ > // need to switch back to the original if the method is from a ParameterizedType > if (method.declaringClass.isParameterizedType()) > method = method.original(); > > MethodBinding inheritedOriginal = method.findOriginalInheritedMethod(inheritedMethod); >- return isParameterSubsignature(method, inheritedOriginal == null ? inheritedMethod : inheritedOriginal); >-} >-boolean isParameterSubsignature(MethodBinding method, MethodBinding inheritedMethod) { >- MethodBinding substitute = computeSubstituteMethod(inheritedMethod, method); >- return substitute != null && isSubstituteParameterSubsignature(method, substitute); >-} >-// if method "overrides" substituteMethod then we can skip over substituteMethod while resolving a message send >-// if it does not then a name clash error is likely >-boolean isSubstituteParameterSubsignature(MethodBinding method, MethodBinding substituteMethod) { >- if (!areParametersEqual(method, substituteMethod)) { >- // method can still override substituteMethod in cases like : >- // <U extends Number> void c(U u) {} >- // @Override void c(Number n) {} >- // but method cannot have a "generic-enabled" parameter type >- if (substituteMethod.hasSubstitutedParameters() && method.areParameterErasuresEqual(substituteMethod)) >- return method.typeVariables == Binding.NO_TYPE_VARIABLES && !hasGenericParameter(method); >- >- // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=279836 >- if (method.declaringClass.isRawType() && substituteMethod.declaringClass.isRawType()) >- if (method.hasSubstitutedParameters() && substituteMethod.hasSubstitutedParameters()) >- return areMethodsCompatible(method, substituteMethod); >- >- return false; >- } >- >- if (substituteMethod instanceof ParameterizedGenericMethodBinding) { >- if (method.typeVariables != Binding.NO_TYPE_VARIABLES) >- return !((ParameterizedGenericMethodBinding) substituteMethod).isRaw; >- // since substituteMethod has substituted type variables, method cannot have a generic signature AND no variables -> its a name clash if it does >- return !hasGenericParameter(method); >- } >- >- // if method has its own variables, then substituteMethod failed bounds check in computeSubstituteMethod() >- return method.typeVariables == Binding.NO_TYPE_VARIABLES; >+ return isParameterSubsignature(method, inheritedOriginal == null ? inheritedMethod : inheritedOriginal, this.environment); > } > boolean isUnsafeReturnTypeOverride(MethodBinding currentMethod, MethodBinding inheritedMethod) { > // called when currentMethod's return type is NOT compatible with inheritedMethod's return type > > // JLS 3 �8.4.5: more are accepted, with an unchecked conversion >diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemReasons.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemReasons.java >index 4373687..2af704e 100644 >--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemReasons.java >+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemReasons.java >@@ -26,6 +26,7 @@ > final int ParameterizedMethodTypeMismatch = 12; // for generic method > final int TypeArgumentsForRawGenericMethod = 13; // for generic method > final int InvalidTypeForStaticImport = 14; > final int InvalidTypeForAutoManagedResource = 15; > final int VarargsElementTypeNotVisible = 16; >+ final int NoSuchSingleAbstractMethod = 17; > } >diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java >index 73e01bd..febfe4a 100644 >--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java >+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java >@@ -1572,6 +1572,20 @@ > if (CharOperation.equals(this.compoundName, TypeConstants.OTHER_WRAPPER_CLOSEABLES[i])) > return TypeIds.BitWrapperCloseable; > } > return 0; > } >+ >+public MethodBinding getSingleAbstractMethod() { >+ if (this.isInterface()) { >+ MethodBinding [] methodArray = methods(); >+ if(methodArray != null && methodArray.length == 1){ >+ return methodArray[0]; >+ } >+ else >+ return new ProblemMethodBinding(CharOperation.NO_CHAR, null, ProblemReasons.NoSuchSingleAbstractMethod); >+ } >+ else >+ return null; >+ >+} > } >diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java >index 3d8930d..fbff8a0 100644 >--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java >+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java >@@ -1369,11 +1369,11 @@ > // BUT we can also ignore any overridden method since we already know the better match (fixes 80028) > for (int j = 0, max = found.size; j < max; j++) { > MethodBinding matchingMethod = (MethodBinding) found.elementAt(j); > MethodBinding matchingOriginal = matchingMethod.original(); > MethodBinding currentOriginal = matchingOriginal.findOriginalInheritedMethod(currentMethod); >- if (currentOriginal != null && verifier.isParameterSubsignature(matchingOriginal, currentOriginal)) { >+ if (currentOriginal != null && verifier.isParameterSubsignature(matchingOriginal, currentOriginal, this.environment())) { > if (isCompliant15) { > if (matchingMethod.isBridge() && !currentMethod.isBridge()) > continue nextMethod; // keep inherited methods to find concrete method over a bridge method > } > currentLength--; >@@ -3944,11 +3944,11 @@ > > original2 = original.findOriginalInheritedMethod(original2); > if (original2 == null) > continue nextSpecific; // current's declaringClass is not a subtype of next's declaringClass > if (current.hasSubstitutedParameters() || original.typeVariables != Binding.NO_TYPE_VARIABLES) { >- if (!environment().methodVerifier().isParameterSubsignature(original, original2)) >+ if (!environment().methodVerifier().isParameterSubsignature(original, original2, environment())) > continue nextSpecific; // current does not override next > } > } else if (receiverType != null) { // should not be null if original isAbstract, but be safe > TypeBinding superType = receiverType.findSuperTypeOriginatingFrom(original.declaringClass.erasure()); > if (original.declaringClass == superType || !(superType instanceof ReferenceBinding)) { >diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java >index 10d3e48..3ad5a71 100644 >--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java >+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java >@@ -1223,6 +1223,10 @@ > } > > public TypeVariableBinding[] typeVariables() { > return Binding.NO_TYPE_VARIABLES; > } >+ >+public MethodBinding getSingleAbstractMethod() { >+ return null; >+} > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 399263
: 226292