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 82430 Details for
Bug 209054
[search] for references to method finds wrong interface call
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
v00.txt (text/plain), 4.26 KB, created by
Frederic Fusier
on 2007-11-08 07:54:24 EST
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2007-11-08 07:54:24 EST
Size:
4.26 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java,v >retrieving revision 1.77 >diff -u -r1.77 MethodLocator.java >--- search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java 6 Nov 2007 11:07:49 -0000 1.77 >+++ search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java 8 Nov 2007 12:30:14 -0000 >@@ -635,7 +635,7 @@ > if (method.declaringClass == null || this.allSuperDeclaringTypeNames == null) { > declaringLevel = INACCURATE_MATCH; > } else { >- if (resolveLevelAsSuperInvocation(methodReceiverType)) { >+ if (resolveLevelAsSuperInvocation(methodReceiverType, method.parameters)) { > declaringLevel = methodLevel // since this is an ACCURATE_MATCH so return the possibly weaker match > | SUPER_INVOCATION_FLAVOR; // this is an overridden method => add flavor to returned level > } >@@ -723,7 +723,7 @@ > * Return whether the given type binding or one of its possible super interfaces > * matches a type in the declaring type names hierarchy. > */ >-protected boolean resolveLevelAsSuperInvocation(ReferenceBinding type) { >+protected boolean resolveLevelAsSuperInvocation(ReferenceBinding type, TypeBinding[] argumentTypes) { > char[][] compoundName = type.compoundName; > for (int i = 0, max = this.allSuperDeclaringTypeNames.length; i < max; i++) { > if (CharOperation.equals(this.allSuperDeclaringTypeNames[i], compoundName)) { >@@ -736,8 +736,25 @@ > ReferenceBinding[] interfaces = type.superInterfaces(); > if (interfaces == null) return false; > for (int i = 0; i < interfaces.length; i++) { >- if (resolveLevelAsSuperInvocation(interfaces[i])) { >- return true; >+ // need to verify if method may be overridden >+ MethodBinding[] methods = interfaces[i].getMethods(this.pattern.selector); >+ for (int j=0, length=methods.length; j<length; j++) { >+ MethodBinding method = methods[j]; >+ TypeBinding[] parameters = method.parameters; >+ if (argumentTypes.length == parameters.length) { >+ boolean found = true; >+ for (int k=0,l=parameters.length; k<l; k++) { >+ if (parameters[k].erasure() != argumentTypes[k].erasure()) { >+ found = false; >+ break; >+ } >+ } >+ if (found) { // current method match in hierarchy >+ if (resolveLevelAsSuperInvocation(interfaces[i], argumentTypes)) { >+ return true; >+ } >+ } >+ } > } > } > } >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java,v >retrieving revision 1.128 >diff -u -r1.128 JavaSearchBugsTests.java >--- src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 6 Nov 2007 11:07:51 -0000 1.128 >+++ src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 8 Nov 2007 12:30:20 -0000 >@@ -9141,4 +9141,29 @@ > javaProject.setRawClasspath(originalRawClasspath, null); > } > } >+ >+/** >+ * @bug 209054: [search] for references to method finds wrong interface call >+ * @test Ensure that searching method reference does not find wrong interface call >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=209054" >+ */ >+public void testBug209054() throws CoreException { >+ workingCopies = new ICompilationUnit[1]; >+ workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/xy/Try.java", >+ "package xy;\n" + >+ "public class Try implements IReferenceUpdating {\n" + >+ " IMovePolicy fInter;\n" + >+ " boolean canDo() { // find references\n" + >+ " return fInter.canDo(); // not a reference\n" + >+ " }\n" + >+ "}\n" + >+ "interface IMovePolicy extends IReferenceUpdating {\n" + >+ " boolean canDo();\n" + >+ "}\n" + >+ "interface IReferenceUpdating {}" >+ ); >+ IMethod method = workingCopies[0].getType("Try").getMethod("canDo", new String[0]); >+ search(method, REFERENCES); >+ assertSearchResults(""); >+} > } >\ No newline at end of file
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 209054
:
82430
|
82454