View | Details | Raw Unified | Return to bug 157847 | Differences between
and this patch

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java (+3 lines)
Lines 905-910 Link Here
905
	// cached info is array of already created wildcard  types for this type
905
	// cached info is array of already created wildcard  types for this type
906
	if (genericType == null) // pseudo wildcard denoting composite bounds for lub computation
906
	if (genericType == null) // pseudo wildcard denoting composite bounds for lub computation
907
		genericType = ReferenceBinding.LUB_GENERIC;
907
		genericType = ReferenceBinding.LUB_GENERIC;
908
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=157847 don't allow '? super <null>' or '? extends <null>'
909
	if (bound == null && boundKind != Wildcard.UNBOUND)
910
		return null;
908
	WildcardBinding[] cachedInfo = (WildcardBinding[])this.uniqueWildcardBindings.get(genericType);
911
	WildcardBinding[] cachedInfo = (WildcardBinding[])this.uniqueWildcardBindings.get(genericType);
909
	boolean needToGrow = false;
912
	boolean needToGrow = false;
910
	int index = 0;
913
	int index = 0;
(-)src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java (+60 lines)
Lines 2133-2137 Link Here
2133
			element
2133
			element
2134
		);
2134
		);
2135
	}
2135
	}
2136
	/**
2137
	 * Ensures that we don't create internally inconsistent wildcard
2138
	 * bindings of the form '? extends <null>' or '? super <null>'
2139
	 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=157847" 
2140
	 */
2141
	public void testWildcard2() throws CoreException {
2142
		String filePath = "/P/src/Bug157847.java";
2143
		try {
2144
			String contents =
2145
				"public class Bug157847<T> {\n" +
2146
				"	void add(Y<? super T> l) {}\n" +
2147
				"}\n"+
2148
                "interface Y<T> {}\n";
2149
			createFile(filePath, contents);
2150
2151
			BindingRequestor requestor = new BindingRequestor();
2152
			String[] bindingKeys = new String[] {"LBug157847~Y<LBug157847~Y;{0}-!LBug157847;{0}*54;>;"};
2153
			resolveASTs(
2154
				new ICompilationUnit[] {},
2155
				bindingKeys,
2156
				requestor,
2157
				getJavaProject("P"),
2158
				this.workingCopy.getOwner()
2159
			);
2160
			IBinding[] bindings = requestor.getBindings(bindingKeys);
2161
			assertTrue("Constructed bogus wildcard", bindings.length == 0);
2162
		} finally {
2163
			deleteFile(filePath);
2164
		}
2165
	}
2166
	/**
2167
	 * Ensures that we don't create internally inconsistent wildcard
2168
	 * bindings of the form '? extends <null>' or '? super <null>'
2169
	 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=157847" 
2170
	 */
2171
	public void testWildcard3() throws CoreException {
2172
		String filePath = "/P/src/Bug157847B.java";
2173
		try {
2174
			String contents =
2175
				"public class Bug157847B<T> {\n" +
2176
				"	void add(Y<? extends T> l) {}\n" +
2177
				"}\n"+
2178
                "interface Y<T> {}\n";
2179
			createFile(filePath, contents);
2180
2181
			BindingRequestor requestor = new BindingRequestor();
2182
			String[] bindingKeys = new String[] {"LBug157847B~Y<LBug157847B~Y;{0}+!LBug157847B;{0}*54;>;"};
2183
			resolveASTs(
2184
				new ICompilationUnit[] {},
2185
				bindingKeys,
2186
				requestor,
2187
				getJavaProject("P"),
2188
				this.workingCopy.getOwner()
2189
			);
2190
			IBinding[] bindings = requestor.getBindings(bindingKeys);
2191
			assertTrue("Constructed bogus wildcard", bindings.length == 0);
2192
		} finally {
2193
			deleteFile(filePath);
2194
		}
2195
	}
2136
2196
2137
}
2197
}

Return to bug 157847