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 92491 Details for
Bug 216930
[1.5][compiler] Wrong compiler error when using static method with same signature as non static one but with variable arguments
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]
Proposed patch with testcase
patch.txt (text/plain), 4.92 KB, created by
Kent Johnson
on 2008-03-13 14:58:47 EDT
(
hide
)
Description:
Proposed patch with testcase
Filename:
MIME Type:
Creator:
Kent Johnson
Created:
2008-03-13 14:58:47 EDT
Size:
4.92 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java,v >retrieving revision 1.59 >diff -u -r1.59 StaticImportTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java 28 Jan 2008 21:53:50 -0000 1.59 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java 13 Mar 2008 18:58:22 -0000 >@@ -2099,5 +2099,27 @@ > " ^^^^\n" + > "The method getZ() is undefined for the type X<T>\n" + > "----------\n"); >- } >+ } >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=216930 >+ public void test058() { >+ this.runConformTest( >+ new String[] { >+ "p/X.java", >+ "package p;\n" + >+ "import static p.A.a;\n" + >+ "public class X {\n" + >+ " void foo(W w) { a(w).a(w); }\n" + >+ "}\n", >+ "p/A.java", >+ "package p;\n" + >+ "public class A {\n" + >+ " public static A a(W... w) { return null; }\n" + >+ " public A a(W w) { return null; }\n" + >+ "}\n", >+ "p/W.java", >+ "package p;\n" + >+ "public class W {}\n" >+ }, >+ ""); >+ } > } >#P org.eclipse.jdt.core >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.324 >diff -u -r1.324 Scope.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 22 Feb 2008 09:49:37 -0000 1.324 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 13 Mar 2008 18:58:23 -0000 >@@ -1045,6 +1045,11 @@ > > // Internal use only - use findMethod() > public MethodBinding findMethod(ReferenceBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite) { >+ return findMethod(receiverType, selector, argumentTypes, invocationSite, false); >+ } >+ >+ // Internal use only - use findMethod() >+ public MethodBinding findMethod(ReferenceBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite, boolean inStaticContext) { > ReferenceBinding currentType = receiverType; > boolean receiverTypeIsInterface = receiverType.isInterface(); > ObjectVector found = new ObjectVector(3); >@@ -1257,6 +1262,18 @@ > } > } > >+ if (inStaticContext) { >+ MethodBinding[] staticCandidates = new MethodBinding[visiblesCount]; >+ int staticCount = 0; >+ for (int i = 0; i < visiblesCount; i++) >+ if (candidates[i].isStatic()) >+ staticCandidates[staticCount++] = candidates[i]; >+ if (staticCount == 1) >+ return staticCandidates[0]; >+ if (staticCount > 1) >+ return mostSpecificMethodBinding(staticCandidates, staticCount, argumentTypes, invocationSite, receiverType); >+ } >+ > MethodBinding mostSpecificMethod = mostSpecificMethodBinding(candidates, visiblesCount, argumentTypes, invocationSite, receiverType); > if (searchForDefaultAbstractMethod) { // search interfaces for a better match > if (mostSpecificMethod.isValidBinding()) >@@ -1909,13 +1926,13 @@ > if (importBinding.onDemand) { > if (!skipOnDemand && resolvedImport instanceof ReferenceBinding) > // answers closest approximation, may not check argumentTypes or visibility >- possible = findMethod((ReferenceBinding) resolvedImport, selector, argumentTypes, invocationSite); >+ possible = findMethod((ReferenceBinding) resolvedImport, selector, argumentTypes, invocationSite, true); > } else { > if (resolvedImport instanceof MethodBinding) { > MethodBinding staticMethod = (MethodBinding) resolvedImport; > if (CharOperation.equals(staticMethod.selector, selector)) > // answers closest approximation, may not check argumentTypes or visibility >- possible = findMethod(staticMethod.declaringClass, selector, argumentTypes, invocationSite); >+ possible = findMethod(staticMethod.declaringClass, selector, argumentTypes, invocationSite, true); > } else if (resolvedImport instanceof FieldBinding) { > // check to see if there are also methods with the same name > FieldBinding staticField = (FieldBinding) resolvedImport; >@@ -1925,7 +1942,7 @@ > TypeBinding referencedType = getType(importName, importName.length - 1); > if (referencedType != null) > // answers closest approximation, may not check argumentTypes or visibility >- possible = findMethod((ReferenceBinding) referencedType, selector, argumentTypes, invocationSite); >+ possible = findMethod((ReferenceBinding) referencedType, selector, argumentTypes, invocationSite, true); > } > } > }
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 216930
: 92491