View | Details | Raw Unified | Return to bug 147381
Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java (+22 lines)
Lines 31748-31751 Link Here
31748
		},
31748
		},
31749
		"");
31749
		"");
31750
}
31750
}
31751
// 
31752
public void test1007() {
31753
	this.runNegativeTest(
31754
		new String[] {
31755
			"GenericsProblem.java",
31756
			"public class GenericsProblem {\n" + 
31757
			"	public <T> void test(T val) {\n" + 
31758
			"		GenericsProblem gp = new GenericsProblem();\n" + 
31759
			"		// this is fine with both\n" + 
31760
			"		Class<? extends GenericsProblem> cl2 = gp.getClass();\n" + 
31761
			"		// This fails on Sun\'s compiler\n" + 
31762
			"		Class<? extends T> cl = val.getClass();\n" + 
31763
			"	}\n" + 
31764
			"}\n",
31765
		},
31766
		"----------\n" + 
31767
		"1. ERROR in GenericsProblem.java (at line 7)\n" + 
31768
		"	Class<? extends T> cl = val.getClass();\n" + 
31769
		"	                        ^^^^^^^^^^^^^^\n" + 
31770
		"Type mismatch: cannot convert from Class<capture-of ? extends Object> to Class<? extends T>\n" + 
31771
		"----------\n");
31772
}		
31751
}
31773
}
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedMethodBinding.java (-1 / +1 lines)
Lines 216-222 Link Here
216
		method.thrownExceptions = originalMethod.thrownExceptions;
216
		method.thrownExceptions = originalMethod.thrownExceptions;
217
		ReferenceBinding genericClassType = scope.getJavaLangClass();
217
		ReferenceBinding genericClassType = scope.getJavaLangClass();
218
		LookupEnvironment environment = scope.environment();
218
		LookupEnvironment environment = scope.environment();
219
		TypeBinding rawType = environment.convertToRawType(receiverType);
219
		TypeBinding rawType = environment.convertToRawType(receiverType.erasure());
220
		method.returnType = environment.createParameterizedType(
220
		method.returnType = environment.createParameterizedType(
221
			genericClassType,
221
			genericClassType,
222
			new TypeBinding[] {  environment.createWildcard(genericClassType, 0, rawType, null /*no extra bound*/, Wildcard.EXTENDS) },
222
			new TypeBinding[] {  environment.createWildcard(genericClassType, 0, rawType, null /*no extra bound*/, Wildcard.EXTENDS) },

Return to bug 147381