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

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties (-2 / +2 lines)
Lines 471-478 Link Here
471
543 = Bound mismatch: The generic method {0}({1}) of type {2} is not applicable for the arguments ({3}). The inferred type {4} is not a valid substitute for the bounded parameter <{5} extends {6}>
471
543 = Bound mismatch: The generic method {0}({1}) of type {2} is not applicable for the arguments ({3}). The inferred type {4} is not a valid substitute for the bounded parameter <{5} extends {6}>
472
544 = Bound mismatch: The generic constructor {0}({1}) of type {2} is not applicable for the arguments ({3}). The inferred type {4} is not a valid substitute for the bounded parameter <{5} extends {6}>
472
544 = Bound mismatch: The generic constructor {0}({1}) of type {2} is not applicable for the arguments ({3}). The inferred type {4} is not a valid substitute for the bounded parameter <{5} extends {6}>
473
545 = Type safety: Unchecked cast from {0} to {1}
473
545 = Type safety: Unchecked cast from {0} to {1}
474
546 = Cannot perform instanceof check against parameterized type {0}. Use instead its raw form {1} since generic type information will be erased at runtime
474
546 = Cannot perform instanceof check against parameterized type {0}. Use the form {1} instead since further generic type information will be erased at runtime
475
547 = Cannot perform instanceof check against type parameter {0}. Use instead its erasure {1} since generic type information will be erased at runtime
475
547 = Cannot perform instanceof check against type parameter {0}. Use instead its erasure {1} instead since further generic type information will be erased at runtime
476
548 = The method {0}({1}) of type {2} is not generic; it cannot be parameterized with arguments <{3}>
476
548 = The method {0}({1}) of type {2} is not generic; it cannot be parameterized with arguments <{3}>
477
549 = Incorrect number of type arguments for generic method <{3}>{0}({1}) of type {2}; it cannot be parameterized with arguments <{4}>
477
549 = Incorrect number of type arguments for generic method <{3}>{0}({1}) of type {2}; it cannot be parameterized with arguments <{4}>
478
550 = The parameterized method <{3}>{0}({1}) of type {2} is not applicable for the arguments ({4})
478
550 = The parameterized method <{3}>{0}({1}) of type {2} is not applicable for the arguments ({4})
(-)compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java (-4 / +19 lines)
Lines 2071-2089 Link Here
2071
		location.sourceEnd);
2071
		location.sourceEnd);
2072
}
2072
}
2073
public void illegalInstanceOfGenericType(TypeBinding checkedType, ASTNode location) {
2073
public void illegalInstanceOfGenericType(TypeBinding checkedType, ASTNode location) {
2074
	TypeBinding erasedType = checkedType.erasure();
2075
	StringBuffer recommendedFormBuffer = new StringBuffer(10);
2076
	recommendedFormBuffer.append(erasedType.sourceName());
2077
	int count = erasedType.typeVariables().length;
2078
	if (count > 0) {
2079
		recommendedFormBuffer.append('<');
2080
		for (int i = 0; i < count; i++) {
2081
			if (i > 0) {
2082
				recommendedFormBuffer.append(',');
2083
			}
2084
			recommendedFormBuffer.append('?');
2085
		}
2086
		recommendedFormBuffer.append('>');
2087
	}
2088
	String recommendedForm = recommendedFormBuffer.toString();
2074
	if (checkedType.isTypeVariable()) {
2089
	if (checkedType.isTypeVariable()) {
2075
		this.handle(
2090
		this.handle(
2076
		IProblem.IllegalInstanceofTypeParameter,
2091
		IProblem.IllegalInstanceofTypeParameter,
2077
			new String[] { new String(checkedType.readableName()), new String(checkedType.erasure().readableName())},
2092
		new String[] { new String(checkedType.readableName()), recommendedForm, },
2078
			new String[] { new String(checkedType.shortReadableName()), new String(checkedType.erasure().shortReadableName())},
2093
		new String[] { new String(checkedType.shortReadableName()), recommendedForm, },
2079
			location.sourceStart,
2094
			location.sourceStart,
2080
			location.sourceEnd);
2095
			location.sourceEnd);
2081
		return;
2096
		return;
2082
	}
2097
	}
2083
	this.handle(
2098
	this.handle(
2084
		IProblem.IllegalInstanceofParameterizedType,
2099
		IProblem.IllegalInstanceofParameterizedType,
2085
		new String[] { new String(checkedType.readableName()), new String(checkedType.erasure().sourceName())},
2100
		new String[] { new String(checkedType.readableName()), recommendedForm, },
2086
		new String[] { new String(checkedType.shortReadableName()), new String(checkedType.erasure().sourceName())},
2101
		new String[] { new String(checkedType.shortReadableName()), recommendedForm, },
2087
		location.sourceStart,
2102
		location.sourceStart,
2088
		location.sourceEnd);
2103
		location.sourceEnd);
2089
}
2104
}
(-)src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java (+43 lines)
Lines 48262-48265 Link Here
48262
			"Type mismatch: cannot convert from Class<capture#6-of ? extends YYY> to Class<? extends YYY<? extends B>>\n" + 
48262
			"Type mismatch: cannot convert from Class<capture#6-of ? extends YYY> to Class<? extends YYY<? extends B>>\n" + 
48263
			"----------\n");
48263
			"----------\n");
48264
}
48264
}
48265
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=258039
48266
public void test1426() {
48267
	this.runNegativeTest(
48268
			new String[] {
48269
				"X.java", //-----------------------------------------------------------------------
48270
				"import java.util.*;\n" + 
48271
				"public class X {\n" + 
48272
				"	boolean foo() {\n" + 
48273
				"		return null instanceof List<Object>;\n" + 
48274
				"	}\n" + 
48275
				"	<T extends List<Object>> boolean foo2() {\n" + 
48276
				"		return null instanceof T;\n" + 
48277
				"	}\n" + 
48278
				"	boolean foo3() {\n" + 
48279
				"		return null instanceof Map<Object,String>;\n" + 
48280
				"	}\n" + 
48281
				"	<T extends Map<Object,String>> boolean foo4() {\n" + 
48282
				"		return null instanceof T;\n" + 
48283
				"	}\n" + 
48284
				"}\n",//-----------------------------------------------------------------------
48285
			},
48286
			"----------\n" + 
48287
			"1. ERROR in X.java (at line 4)\n" + 
48288
			"	return null instanceof List<Object>;\n" + 
48289
			"	       ^^^^^^^^^^^^^^^^^^^^\n" + 
48290
			"Cannot perform instanceof check against parameterized type List<Object>. Use the form List<?> instead since further generic type information will be erased at runtime\n" + 
48291
			"----------\n" + 
48292
			"2. ERROR in X.java (at line 7)\n" + 
48293
			"	return null instanceof T;\n" + 
48294
			"	       ^^^^^^^^^^^^^^^^^\n" + 
48295
			"Cannot perform instanceof check against type parameter T. Use instead its erasure List<?> instead since further generic type information will be erased at runtime\n" + 
48296
			"----------\n" + 
48297
			"3. ERROR in X.java (at line 10)\n" + 
48298
			"	return null instanceof Map<Object,String>;\n" + 
48299
			"	       ^^^^^^^^^^^^^^^^^^^\n" + 
48300
			"Cannot perform instanceof check against parameterized type Map<Object,String>. Use the form Map<?,?> instead since further generic type information will be erased at runtime\n" + 
48301
			"----------\n" + 
48302
			"4. ERROR in X.java (at line 13)\n" + 
48303
			"	return null instanceof T;\n" + 
48304
			"	       ^^^^^^^^^^^^^^^^^\n" + 
48305
			"Cannot perform instanceof check against type parameter T. Use instead its erasure Map<?,?> instead since further generic type information will be erased at runtime\n" + 
48306
			"----------\n");
48307
}
48265
}
48308
}

Return to bug 258039