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 81493 Details for
Bug 111093
More problems with IMethodBinding#isSubsignature(..)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
patch.txt (text/plain), 31.09 KB, created by
Kent Johnson
on 2007-10-29 15:26:29 EDT
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Kent Johnson
Created:
2007-10-29 15:26:29 EDT
Size:
31.09 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: dom/org/eclipse/jdt/core/dom/MethodBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodBinding.java,v >retrieving revision 1.86 >diff -u -r1.86 MethodBinding.java >--- dom/org/eclipse/jdt/core/dom/MethodBinding.java 24 Sep 2007 22:49:54 -0000 1.86 >+++ dom/org/eclipse/jdt/core/dom/MethodBinding.java 29 Oct 2007 19:20:17 -0000 >@@ -22,7 +22,6 @@ > import org.eclipse.jdt.core.compiler.CharOperation; > import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers; > import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment; >-import org.eclipse.jdt.internal.compiler.lookup.MethodVerifier; > import org.eclipse.jdt.internal.compiler.lookup.ParameterizedGenericMethodBinding; > import org.eclipse.jdt.internal.compiler.lookup.RawTypeBinding; > import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; >@@ -453,10 +452,9 @@ > > public boolean isSubsignature(IMethodBinding otherMethod) { > try { >- org.eclipse.jdt.internal.compiler.lookup.MethodBinding other = ((MethodBinding) otherMethod).binding; >- if (!CharOperation.equals(this.binding.selector, other.selector)) >- return false; >- return this.binding.areParameterErasuresEqual(other) && this.binding.areTypeVariableErasuresEqual(other); >+ LookupEnvironment lookupEnvironment = this.resolver.lookupEnvironment(); >+ return lookupEnvironment != null >+ && lookupEnvironment.methodVerifier().isMethodSubsignature(this.binding, ((MethodBinding) otherMethod).binding); > } catch (AbortCompilation e) { > // don't surface internal exception to clients > // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=143013 >@@ -474,37 +472,10 @@ > /** > * @see IMethodBinding#overrides(IMethodBinding) > */ >- public boolean overrides(IMethodBinding overridenMethod) { >- try { >- org.eclipse.jdt.internal.compiler.lookup.MethodBinding overridenCompilerBinding = ((MethodBinding) overridenMethod).binding; >- if (this.binding == overridenCompilerBinding >- || overridenCompilerBinding.isStatic() >- || overridenCompilerBinding.isPrivate() >- || this.binding.isStatic()) >- return false; >- char[] selector = this.binding.selector; >- if (!CharOperation.equals(selector, overridenCompilerBinding.selector)) >- return false; >- TypeBinding match = this.binding.declaringClass.findSuperTypeOriginatingFrom(overridenCompilerBinding.declaringClass); >- if (!(match instanceof ReferenceBinding)) return false; >- >- org.eclipse.jdt.internal.compiler.lookup.MethodBinding[] superMethods = ((ReferenceBinding)match).getMethods(selector); >- for (int i = 0, length = superMethods.length; i < length; i++) { >- if (superMethods[i].original() == overridenCompilerBinding) { >- LookupEnvironment lookupEnvironment = this.resolver.lookupEnvironment(); >- if (lookupEnvironment == null) return false; >- MethodVerifier methodVerifier = lookupEnvironment.methodVerifier(); >- org.eclipse.jdt.internal.compiler.lookup.MethodBinding superMethod = superMethods[i]; >- return !(superMethod.isDefault() && (superMethod.declaringClass.getPackage()) != this.binding.declaringClass.getPackage()) >- && methodVerifier.doesMethodOverride(this.binding, superMethod); >- } >- } >- return false; >- } catch (AbortCompilation e) { >- // don't surface internal exception to clients >- // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=143013 >- return false; >- } >+ public boolean overrides(IMethodBinding otherMethod) { >+ LookupEnvironment lookupEnvironment = this.resolver.lookupEnvironment(); >+ return lookupEnvironment != null >+ && lookupEnvironment.methodVerifier().doesMethodOverride(this.binding, ((MethodBinding) otherMethod).binding); > } > > /** >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java,v >retrieving revision 1.82 >diff -u -r1.82 MethodVerifier15.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java 1 Oct 2007 14:54:14 -0000 1.82 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java 29 Oct 2007 19:20:16 -0000 >@@ -21,7 +21,7 @@ > } > boolean areMethodsCompatible(MethodBinding one, MethodBinding two) { > MethodBinding sub = computeSubstituteMethod(two, one); >- return sub != null && doesSubstituteMethodOverride(one, sub) && areReturnTypesCompatible(one, sub); >+ return sub != null && isSubstituteParameterSubsignature(one, sub) && areReturnTypesCompatible(one, sub); > } > boolean areParametersEqual(MethodBinding one, MethodBinding two) { > TypeBinding[] oneArgs = one.parameters; >@@ -224,7 +224,7 @@ > MethodBinding[] methods = superType.getMethods(currentMethod.selector); > for (int m = 0, n = methods.length; m < n; m++) { > MethodBinding substitute = computeSubstituteMethod(methods[m], currentMethod); >- if (substitute != null && !doesSubstituteMethodOverride(currentMethod, substitute) && detectNameClash(currentMethod, substitute)) >+ if (substitute != null && !isSubstituteParameterSubsignature(currentMethod, substitute) && detectNameClash(currentMethod, substitute)) > return; > } > if ((itsInterfaces = superType.superInterfaces()) != Binding.NO_SUPERINTERFACES) { >@@ -252,7 +252,7 @@ > MethodBinding[] methods = superType.getMethods(currentMethod.selector); > for (int m = 0, n = methods.length; m < n; m++){ > MethodBinding substitute = computeSubstituteMethod(methods[m], currentMethod); >- if (substitute != null && !doesSubstituteMethodOverride(currentMethod, substitute) && detectNameClash(currentMethod, substitute)) >+ if (substitute != null && !isSubstituteParameterSubsignature(currentMethod, substitute) && detectNameClash(currentMethod, substitute)) > return; > } > if ((itsInterfaces = superType.superInterfaces()) != Binding.NO_SUPERINTERFACES) { >@@ -424,7 +424,7 @@ > for (int j = 0, length2 = inherited.length; j < length2; j++) { > MethodBinding inheritedMethod = computeSubstituteMethod(inherited[j], currentMethod); > if (inheritedMethod != null) { >- if (foundMatch[j] == 0 && doesSubstituteMethodOverride(currentMethod, inheritedMethod)) { >+ if (foundMatch[j] == 0 && isSubstituteParameterSubsignature(currentMethod, inheritedMethod)) { > matchingInherited[++index] = inheritedMethod; > foundMatch[j] = 1; // cannot null out inherited methods > } else { >@@ -454,7 +454,7 @@ > otherInheritedMethod = computeSubstituteMethod(otherInheritedMethod, inheritedMethod); > if (otherInheritedMethod != null) { > if (inheritedMethod.declaringClass != otherInheritedMethod.declaringClass >- && doesSubstituteMethodOverride(inheritedMethod, otherInheritedMethod)) { >+ && isSubstituteParameterSubsignature(inheritedMethod, otherInheritedMethod)) { > matchingInherited[++index] = otherInheritedMethod; > foundMatch[j] = 1; // cannot null out inherited methods > } else { >@@ -491,7 +491,7 @@ > if (canSkipInheritedMethods(inheritedMethod, otherInheritedMethod)) > continue; > otherInheritedMethod = computeSubstituteMethod(otherInheritedMethod, inheritedMethod); >- if (otherInheritedMethod != null && doesSubstituteMethodOverride(inheritedMethod, otherInheritedMethod)) { >+ if (otherInheritedMethod != null && isSubstituteParameterSubsignature(inheritedMethod, otherInheritedMethod)) { > matchingInherited[++index] = otherInheritedMethod; > inherited[j] = null; // do not want to find it again > } >@@ -586,29 +586,22 @@ > return true; > } > public boolean doesMethodOverride(MethodBinding method, MethodBinding inheritedMethod) { >- MethodBinding substitute = computeSubstituteMethod(inheritedMethod, method); >- return substitute != null && doesSubstituteMethodOverride(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 doesSubstituteMethodOverride(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); >+ if (!couldMethodOverride(method, inheritedMethod)) > return false; >- } > >- if (substituteMethod instanceof ParameterizedGenericMethodBinding) { >- // 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) && method.typeVariables == Binding.NO_TYPE_VARIABLES); >+ 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 >+ >+ if (match != inheritedMethod.declaringClass) { >+ MethodBinding[] superMethods = ((ReferenceBinding) match).getMethods(inheritedMethod.selector); >+ for (int i = 0, length = superMethods.length; i < length; i++) >+ if (superMethods[i].original() == inheritedMethod) >+ return isParameterSubsignature(method, superMethods[i]); > } > >- // if method has its own variables, then substituteMethod failed bounds check in computeSubstituteMethod() >- return method.typeVariables == Binding.NO_TYPE_VARIABLES; >+ return isParameterSubsignature(method, inheritedMethod); > } > boolean hasGenericParameter(MethodBinding method) { > if (method.genericSignature() == null) return false; >@@ -708,6 +701,46 @@ > && inheritedMethod.returnType == existingMethod.returnType // keep around to produce bridge methods > && super.isInterfaceMethodImplemented(inheritedMethod, existingMethod, superType); > } >+public boolean isMethodSubsignature(MethodBinding method, MethodBinding inheritedMethod) { >+ if (!org.eclipse.jdt.core.compiler.CharOperation.equals(method.selector, inheritedMethod.selector)) >+ return false; >+ >+ inheritedMethod = inheritedMethod.original(); >+ TypeBinding match = method.declaringClass.findSuperTypeOriginatingFrom(inheritedMethod.declaringClass); >+ if ((match instanceof ReferenceBinding) && match != inheritedMethod.declaringClass) { >+ MethodBinding[] superMethods = ((ReferenceBinding) match).getMethods(inheritedMethod.selector); >+ for (int i = 0, length = superMethods.length; i < length; i++) >+ if (superMethods[i].original() == inheritedMethod) >+ return isParameterSubsignature(method, superMethods[i]); >+ } >+ >+ return isParameterSubsignature(method, inheritedMethod); >+} >+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); >+ return false; >+ } >+ >+ if (substituteMethod instanceof ParameterizedGenericMethodBinding) { >+ // 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) && method.typeVariables == Binding.NO_TYPE_VARIABLES); >+ } >+ >+ // if method has its own variables, then substituteMethod failed bounds check in computeSubstituteMethod() >+ return method.typeVariables == Binding.NO_TYPE_VARIABLES; >+} > boolean isUnsafeReturnTypeOverride(MethodBinding currentMethod, MethodBinding inheritedMethod) { > // JLS 3 ยง8.4.5: more are accepted, with an unchecked conversion > if (currentMethod.returnType == inheritedMethod.returnType.erasure()) { >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java,v >retrieving revision 1.318 >diff -u -r1.318 Scope.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 16 Oct 2007 10:24:16 -0000 1.318 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 29 Oct 2007 19:20:17 -0000 >@@ -706,7 +706,7 @@ > if (compatibleMethod != null) { > if (compatibleMethod.isValidBinding()) { > if (concreteMatch != null && concreteMatch.declaringClass.findSuperTypeOriginatingFrom(compatibleMethod.declaringClass) != null) >- if (environment().methodVerifier().doesMethodOverride(concreteMatch, compatibleMethod)) >+ if (environment().methodVerifier().isParameterSubsignature(concreteMatch, compatibleMethod)) > continue; // can skip this method since concreteMatch overrides it > if (candidatesCount == 0) { > candidates = new MethodBinding[foundSize - startFoundSize + 1]; >@@ -1086,7 +1086,7 @@ > // 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); >- if (verifier.doesMethodOverride(matchingMethod.original(), currentMethod.original())) { >+ if (verifier.isParameterSubsignature(matchingMethod.original(), currentMethod.original())) { > if (isCompliant15) { > if (matchingMethod.isBridge() && !currentMethod.isBridge()) > continue nextMethod; // keep inherited methods to find concrete method over a bridge method >@@ -3420,7 +3420,7 @@ > } > } > } >- if (!environment().methodVerifier().doesMethodOverride(original, original2)) >+ if (!environment().methodVerifier().isParameterSubsignature(original, original2)) > continue nextSpecific; // current does not override next > } > } else if (receiverType != null) { // should not be null if original isAbstract, but be safe >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java,v >retrieving revision 1.89 >diff -u -r1.89 MethodVerifier.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java 26 Jun 2007 19:39:34 -0000 1.89 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java 29 Oct 2007 19:20:16 -0000 >@@ -51,7 +51,7 @@ > && environment.globalOptions.sourceLevel < ClassFileConstants.JDK1_5; > } > boolean areMethodsCompatible(MethodBinding one, MethodBinding two) { >- return doesMethodOverride(one, two) && areReturnTypesCompatible(one, two); >+ return isParameterSubsignature(one, two) && areReturnTypesCompatible(one, two); > } > boolean areParametersEqual(MethodBinding one, MethodBinding two) { > TypeBinding[] oneArgs = one.parameters; >@@ -348,7 +348,7 @@ > for (int j = 0, length2 = inherited.length; j < length2; j++) { > MethodBinding inheritedMethod = computeSubstituteMethod(inherited[j], currentMethod); > if (inheritedMethod != null) { >- if (doesMethodOverride(currentMethod, inheritedMethod)) { >+ if (isParameterSubsignature(currentMethod, inheritedMethod)) { > matchingInherited[++index] = inheritedMethod; > inherited[j] = null; // do not want to find it again > } >@@ -372,7 +372,7 @@ > continue; > otherInheritedMethod = computeSubstituteMethod(otherInheritedMethod, inheritedMethod); > if (otherInheritedMethod != null) { >- if (doesMethodOverride(inheritedMethod, otherInheritedMethod)) { >+ if (isParameterSubsignature(inheritedMethod, otherInheritedMethod)) { > matchingInherited[++index] = otherInheritedMethod; > inherited[j] = null; // do not want to find it again > } >@@ -591,8 +591,36 @@ > if (currentMethod.parameters.length != inheritedMethod.parameters.length) return null; // no match > return inheritedMethod; > } >+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()) >+ return false; >+ if (inheritedMethod.isDefault() && method.declaringClass.getPackage() != inheritedMethod.declaringClass.getPackage()) >+ return false; >+ if (!method.isPublic()) { // inheritedMethod is either public or protected & method is less than public >+ if (inheritedMethod.isPublic()) >+ return false; >+ if (inheritedMethod.isProtected() && !method.isProtected()) >+ 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 boolean doesMethodOverride(MethodBinding method, MethodBinding inheritedMethod) { >- return areParametersEqual(method, 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); > } > SimpleSet findSuperinterfaceCollisions(ReferenceBinding superclass, ReferenceBinding[] superInterfaces) { > return null; // noop in 1.4 >@@ -662,6 +690,13 @@ > // skip interface method with the same signature if visible to its declaringClass > 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); >+} >+boolean isParameterSubsignature(MethodBinding method, MethodBinding inheritedMethod) { >+ return areParametersEqual(method, inheritedMethod); >+} > boolean isSameClassOrSubclassOf(ReferenceBinding testClass, ReferenceBinding superclass) { > do { > if (testClass == superclass) return true; >Index: codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java,v >retrieving revision 1.346 >diff -u -r1.346 CompletionEngine.java >--- codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 25 Oct 2007 11:06:17 -0000 1.346 >+++ codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 29 Oct 2007 19:20:16 -0000 >@@ -5615,13 +5615,13 @@ > > if (CharOperation.equals(method.selector, otherMethod.selector, true)) { > if (receiverType == otherReceiverType) { >- if (lookupEnvironment.methodVerifier().doesMethodOverride(otherMethod, method)) { >+ if (lookupEnvironment.methodVerifier().isMethodSubsignature(otherMethod, method)) { > if (!superCall || !otherMethod.declaringClass.isInterface()) { > continue next; > } > } > } else { >- if (lookupEnvironment.methodVerifier().doesMethodOverride(otherMethod, method)) { >+ if (lookupEnvironment.methodVerifier().isMethodSubsignature(otherMethod, method)) { > if(receiverType.isAnonymousType()) continue next; > > if(!superCall) { >@@ -5921,7 +5921,7 @@ > if (method == otherMethod) continue next; > > if (CharOperation.equals(method.selector, otherMethod.selector, true)) { >- if (lookupEnvironment.methodVerifier().doesMethodOverride(otherMethod, method)) { >+ if (lookupEnvironment.methodVerifier().isMethodSubsignature(otherMethod, method)) { > continue next; > } > } >@@ -6216,7 +6216,7 @@ > continue next; > > if (CharOperation.equals(method.selector, otherMethod.selector, true)) { >- if (lookupEnvironment.methodVerifier().doesMethodOverride(otherMethod, method)) { >+ if (lookupEnvironment.methodVerifier().isMethodSubsignature(otherMethod, method)) { > continue next; > } > } >@@ -6541,7 +6541,7 @@ > continue next; > > if (CharOperation.equals(method.selector, otherMethod.selector, true) >- && lookupEnvironment.methodVerifier().doesMethodOverride(otherMethod, method)) { >+ && lookupEnvironment.methodVerifier().isMethodSubsignature(otherMethod, method)) { > continue next; > } > } >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/dom/CompatibilityRulesTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/CompatibilityRulesTests.java,v >retrieving revision 1.18 >diff -u -r1.18 CompatibilityRulesTests.java >--- src/org/eclipse/jdt/core/tests/dom/CompatibilityRulesTests.java 13 Aug 2007 14:33:26 -0000 1.18 >+++ src/org/eclipse/jdt/core/tests/dom/CompatibilityRulesTests.java 29 Oct 2007 19:20:17 -0000 >@@ -784,4 +784,274 @@ > assertTrue("Y#foo() should not override X#foo()", !bindings[0].overrides(bindings[1])); > } > >+ /* >+ * Ensures that a method with different paramter types is not a subsignature of its super method. >+ * (regression test for bug 111093 More problems with IMethodBinding#isSubsignature(..)) >+ */ >+ public void test035() throws JavaModelException { >+ IMethodBinding[] bindings = createMethodBindings( >+ new String[] { >+ "/P/p1/A.java", >+ "package p1;\n" + >+ "public class A<T> {\n" + >+ " public void o1_xoo2(A<?> s) {\n" + >+ " }\n" + >+ "}\n" + >+ "class B<S> extends A<S> {\n" + >+ " @Override\n" + >+ " public void o1_xoo2(A<Object> s) {\n" + >+ " }\n" + >+ "}", >+ }, >+ new String[] { >+ "Lp1/A;.o1_xoo2(Lp1/A<*>;)V", >+ "Lp1/A~B;.o1_xoo2(Lp1/A<Ljava/lang/Object;>;)V" >+ }); >+ assertFalse("B#o1_xoo2() should not be a subsignature of A#o1_xoo2()", bindings[1].isSubsignature(bindings[0])); >+ } >+ >+ /* >+ * Ensures that a method with different paramter types is not a subsignature of its super method. >+ * (regression test for bug 111093 More problems with IMethodBinding#isSubsignature(..)) >+ */ >+ public void test036() throws JavaModelException { >+ IMethodBinding[] bindings = createMethodBindings( >+ new String[] { >+ "/P/p1/A.java", >+ "package p1;\n" + >+ "public class A<T> {\n" + >+ " public void o1_xoo3(A<? extends T> s) {\n" + >+ " }\n" + >+ "}\n" + >+ "class B<S> extends A<S> {\n" + >+ " @Override\n" + >+ " public void o1_xoo3(A<? super S> s) {\n" + >+ " }\n" + >+ "}", >+ }, >+ new String[] { >+ "Lp1/A;.o1_xoo3(Lp1/A<+TT;>;)V", >+ "Lp1/A~B;.o1_xoo3(Lp1/A<-TS;>;)V" >+ }); >+ assertFalse("B#o1_xoo3() should not be a subsignature of A#o1_xoo3()", bindings[1].isSubsignature(bindings[0])); >+ } >+ >+ /* >+ * Ensures that a method with different paramter types is not a subsignature of its super method. >+ * (regression test for bug 111093 More problems with IMethodBinding#isSubsignature(..)) >+ */ >+ public void test037() throws JavaModelException { >+ IMethodBinding[] bindings = createMethodBindings( >+ new String[] { >+ "/P/p1/A.java", >+ "package p1;\n" + >+ "public class A<S, T> {\n" + >+ " public void o2_xoo1(List<? extends T> t) {\n" + >+ " }\n" + >+ "}\n" + >+ "class B<V, W> extends A<W, V> {\n" + >+ " @Override\n" + >+ " public void o2_xoo1(List<? extends W> t) {\n" + >+ " }\n" + >+ "}\n" + >+ "class List<T> {\n" + >+ "}", >+ }, >+ new String[] { >+ "Lp1/A;.o2_xoo1(Lp1/List<+TT;>;)V", >+ "Lp1/A~B;.o2_xoo1(Lp1/List<+TW;>;)V" >+ }); >+ assertFalse("B#o1_xoo1() should not be a subsignature of A#o1_xoo1()", bindings[1].isSubsignature(bindings[0])); >+ } >+ >+ /* >+ * Ensures that a method with different paramter types is not a subsignature of its super method. >+ * (regression test for bug 111093 More problems with IMethodBinding#isSubsignature(..)) >+ */ >+ public void test038() throws JavaModelException { >+ IMethodBinding[] bindings = createMethodBindings( >+ new String[] { >+ "/P/p1/A.java", >+ "package p1;\n" + >+ "public class A {\n" + >+ " public void o3_xoo1(List t) {\n" + >+ " }\n" + >+ "}\n" + >+ "class B extends A {\n" + >+ " @Override\n" + >+ " public void o3_xoo1(List<Object> t) {\n" + >+ " }\n" + >+ "}\n" + >+ "class List<T> {\n" + >+ "}", >+ }, >+ new String[] { >+ "Lp1/A;.o3_xoo1(Lp1/List;)V", >+ "Lp1/A~B;.o3_xoo1(Lp1/List<Ljava/lang/Object;>;)V" >+ }); >+ assertFalse("B#o3_xoo1() should not be a subsignature of A#o3_xoo1()", bindings[1].isSubsignature(bindings[0])); >+ } >+ >+ /* >+ * Ensures that a method with different paramter types is not a subsignature of its super method. >+ * (regression test for bug 111093 More problems with IMethodBinding#isSubsignature(..)) >+ */ >+ public void test039() throws JavaModelException { >+ IMethodBinding[] bindings = createMethodBindings( >+ new String[] { >+ "/P/p1/A.java", >+ "package p1;\n" + >+ "public class A<T> {\n" + >+ " public void o4_xoo1(T t) {\n" + >+ " }\n" + >+ "}\n" + >+ "class B extends A<List<String>> {\n" + >+ " @Override\n" + >+ " public void o4_xoo1(List<?> t) {\n" + >+ " }\n" + >+ "}\n" + >+ "class List<T> {\n" + >+ "}", >+ }, >+ new String[] { >+ "Lp1/A;.o4_xoo1(TT;)V", >+ "Lp1/A~B;.o4_xoo1(Lp1/List<*>;)V" >+ }); >+ assertFalse("B#o4_xoo1() should not be a subsignature of A#o4_xoo1()", bindings[1].isSubsignature(bindings[0])); >+ } >+ >+ /* >+ * Ensures that a method with different paramter types is not a subsignature of its super method. >+ * (regression test for bug 111093 More problems with IMethodBinding#isSubsignature(..)) >+ */ >+ public void test040() throws JavaModelException { >+ IMethodBinding[] bindings = createMethodBindings( >+ new String[] { >+ "/P/p1/A.java", >+ "package p1;\n" + >+ "public class A<S> {\n" + >+ " public <X, Y> void tp1_xoo3(X x, Y y) {\n" + >+ " }\n" + >+ "}\n" + >+ "class B extends A<String> {\n" + >+ " @Override\n" + >+ " public <W, V> void tp1_xoo3(V x, W y) {\n" + >+ " }\n" + >+ "}", >+ }, >+ new String[] { >+ "Lp1/A;.tp1_xoo3<X:Ljava/lang/Object;Y:Ljava/lang/Object;>(TX;TY;)V", >+ "Lp1/A~B;.tp1_xoo3<W:Ljava/lang/Object;V:Ljava/lang/Object;>(TV;TW;)V" >+ }); >+ assertFalse("B#tp1_xoo3() should not be a subsignature of A#tp1_xoo3()", bindings[1].isSubsignature(bindings[0])); >+ } >+ >+ /* >+ * Ensures that a method with different paramter types is not a subsignature of its super method. >+ * (regression test for bug 111093 More problems with IMethodBinding#isSubsignature(..)) >+ */ >+ public void test041() throws JavaModelException { >+ IMethodBinding[] bindings = createMethodBindings( >+ new String[] { >+ "/P/p1/A.java", >+ "package p1;\n" + >+ "public class A<S> {\n" + >+ " public <X, Y> void tp1_foo2(S s, X x, Y y) {\n" + >+ " }\n" + >+ "}\n" + >+ "class B extends A<String> {\n" + >+ " @Override\n" + >+ " public void tp1_foo2(String s, Object x, Object y) {\n" + >+ " }\n" + >+ "}", >+ }, >+ new String[] { >+ "Lp1/A;.tp1_foo2<X:Ljava/lang/Object;Y:Ljava/lang/Object;>(TS;TX;TY;)V", >+ "Lp1/A~B;.tp1_foo2(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V" >+ }); >+ assertTrue("B#tp1_foo2() should be a subsignature of A#tp1_foo2()", bindings[1].isSubsignature(bindings[0])); >+ } >+ >+ /* >+ * Ensures that a method with different paramter types is not a subsignature of its super method. >+ * (regression test for bug 111093 More problems with IMethodBinding#isSubsignature(..)) >+ */ >+ public void test042() throws JavaModelException { >+ IMethodBinding[] bindings = createMethodBindings( >+ new String[] { >+ "/P/p1/A.java", >+ "package p1;\n" + >+ "public abstract class A<T> {\n" + >+ " void g2 (T t) {\n" + >+ " }\n" + >+ "}\n" + >+ "class B extends A<List<Number>> {\n" + >+ " void g2 (List<Number> t) {\n" + >+ " }\n" + >+ "}\n" + >+ "class List<T> {\n" + >+ "}\n" + >+ "class Number {\n" + >+ "}", >+ }, >+ new String[] { >+ "Lp1/A~B;.g2(Lp1/List<Lp1/Number;>;)V" >+ }); >+ ITypeBinding superType = bindings[0].getDeclaringClass().getSuperclass(); // parameterized type >+ IMethodBinding ag2 = superType.getDeclaredMethods()[1]; >+ assertTrue("B#g2() should be a subsignature of A#g2()", bindings[0].isSubsignature(ag2)); >+ } >+ >+ /* >+ * Ensures that a method with same signature in a different hierarchy doesn't overide another one >+ */ >+ public void test043() throws JavaModelException { >+ IMethodBinding[] bindings = createMethodBindings( >+ new String[] { >+ "/P/p1/X.java", >+ "package p1;\n" + >+ "public class X {\n" + >+ " void foo() {\n" + >+ " }\n" + >+ "}", >+ "/P/p1/Y.java", >+ "package p1;\n" + >+ "public class Y {\n" + >+ " void foo() {\n" + >+ " }\n" + >+ "}", >+ }, >+ new String[] { >+ "Lp1/X;.foo()V", >+ "Lp1/Y;.foo()V" >+ }); >+ assertFalse("Y#foo() should not override X#foo()", bindings[1].overrides(bindings[0])); >+ } >+ >+ /* >+ * Ensures that a method is a subsignature of the same method in a different hierarchy >+ */ >+ public void test044() throws JavaModelException { >+ IMethodBinding[] bindings = createMethodBindings( >+ new String[] { >+ "/P/p1/X.java", >+ "package p1;\n" + >+ "public class X {\n" + >+ " void foo() {\n" + >+ " }\n" + >+ "}", >+ "/P/p1/Y.java", >+ "package p1;\n" + >+ "public class Y {\n" + >+ " void foo() {\n" + >+ " }\n" + >+ "}", >+ }, >+ new String[] { >+ "Lp1/X;.foo()V", >+ "Lp1/Y;.foo()V" >+ }); >+ assertTrue("Y#foo() should be a subsignature of X#foo()", bindings[1].isSubsignature(bindings[0])); >+ } >+ > }
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 111093
:
80030
|
80133
|
80344
|
81493
|
81523
|
81635