### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java,v retrieving revision 1.105 diff -u -r1.105 LookupEnvironment.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java 9 Feb 2010 05:14:15 -0000 1.105 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java 7 May 2010 13:06:45 -0000 @@ -905,6 +905,9 @@ // cached info is array of already created wildcard types for this type if (genericType == null) // pseudo wildcard denoting composite bounds for lub computation genericType = ReferenceBinding.LUB_GENERIC; + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=157847 don't allow '? super ' or '? extends ' + if (bound == null && boundKind != Wildcard.UNBOUND) + return null; WildcardBinding[] cachedInfo = (WildcardBinding[])this.uniqueWildcardBindings.get(genericType); boolean needToGrow = false; int index = 0; #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java,v retrieving revision 1.63 diff -u -r1.63 ASTModelBridgeTests.java --- src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java 14 Dec 2009 18:46:07 -0000 1.63 +++ src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java 7 May 2010 13:06:50 -0000 @@ -2133,5 +2133,65 @@ element ); } + /** + * Ensures that we don't create internally inconsistent wildcard + * bindings of the form '? extends ' or '? super ' + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=157847" + */ + public void testWildcard2() throws CoreException { + String filePath = "/P/src/Bug157847.java"; + try { + String contents = + "public class Bug157847 {\n" + + " void add(Y l) {}\n" + + "}\n"+ + "interface Y {}\n"; + createFile(filePath, contents); + + BindingRequestor requestor = new BindingRequestor(); + String[] bindingKeys = new String[] {"LBug157847~Y;"}; + resolveASTs( + new ICompilationUnit[] {}, + bindingKeys, + requestor, + getJavaProject("P"), + this.workingCopy.getOwner() + ); + IBinding[] bindings = requestor.getBindings(bindingKeys); + assertTrue("Constructed bogus wildcard", bindings.length == 0); + } finally { + deleteFile(filePath); + } + } + /** + * Ensures that we don't create internally inconsistent wildcard + * bindings of the form '? extends ' or '? super ' + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=157847" + */ + public void testWildcard3() throws CoreException { + String filePath = "/P/src/Bug157847B.java"; + try { + String contents = + "public class Bug157847B {\n" + + " void add(Y l) {}\n" + + "}\n"+ + "interface Y {}\n"; + createFile(filePath, contents); + + BindingRequestor requestor = new BindingRequestor(); + String[] bindingKeys = new String[] {"LBug157847B~Y;"}; + resolveASTs( + new ICompilationUnit[] {}, + bindingKeys, + requestor, + getJavaProject("P"), + this.workingCopy.getOwner() + ); + IBinding[] bindings = requestor.getBindings(bindingKeys); + assertTrue("Constructed bogus wildcard", bindings.length == 0); + } finally { + deleteFile(filePath); + } + } }