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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java (-2 / +37 lines)
Lines 39409-39415 Link Here
39409
		"----------\n");
39409
		"----------\n");
39410
}
39410
}
39411
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=204534
39411
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=204534
39412
public void _test1181() {
39412
public void test1181() {
39413
	this.runNegativeTest(
39413
	this.runNegativeTest(
39414
		new String[] {
39414
		new String[] {
39415
			"X.java",
39415
			"X.java",
Lines 39430-39436 Link Here
39430
			"	}\n" + 
39430
			"	}\n" + 
39431
			"}\n", // =================
39431
			"}\n", // =================
39432
		},
39432
		},
39433
		"should not see errors like: R cannot be resolved to a type");
39433
		"----------\n" + 
39434
		"1. ERROR in X.java (at line 2)\n" + 
39435
		"	public static <S, T extends Comparable<S>, R extends S & T> R max(T arg1, S arg2) {\n" + 
39436
		"	                                                         ^\n" + 
39437
		"Cannot specify any additional bound T when first bound is a type parameter\n" + 
39438
		"----------\n" + 
39439
		"2. ERROR in X.java (at line 2)\n" + 
39440
		"	public static <S, T extends Comparable<S>, R extends S & T> R max(T arg1, S arg2) {\n" + 
39441
		"	                                                              ^^^^^^^^^^^^^^^^^^^\n" + 
39442
		"Method max(T, S) has the same erasure max(Comparable<T>, Object) as another method in type X\n" + 
39443
		"----------\n" + 
39444
		"3. WARNING in X.java (at line 3)\n" + 
39445
		"	return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" + 
39446
		"	       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
39447
		"Type safety: Unchecked cast from Object to R\n" + 
39448
		"----------\n" + 
39449
		"4. ERROR in X.java (at line 6)\n" + 
39450
		"	public static <T extends Comparable<S>, S, R extends S & Comparable<S>> R max(T arg1, S arg2) {\n" + 
39451
		"	                                                         ^^^^^^^^^^\n" + 
39452
		"Cannot specify any additional bound Comparable<S> when first bound is a type parameter\n" + 
39453
		"----------\n" + 
39454
		"5. ERROR in X.java (at line 6)\n" + 
39455
		"	public static <T extends Comparable<S>, S, R extends S & Comparable<S>> R max(T arg1, S arg2) {\n" + 
39456
		"	                                                                          ^^^^^^^^^^^^^^^^^^^\n" + 
39457
		"Method max(T, S) has the same erasure max(Comparable<T>, Object) as another method in type X\n" + 
39458
		"----------\n" + 
39459
		"6. WARNING in X.java (at line 7)\n" + 
39460
		"	return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" + 
39461
		"	       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
39462
		"Type safety: Unchecked cast from Object to R\n" + 
39463
		"----------\n" + 
39464
		"7. WARNING in X.java (at line 11)\n" + 
39465
		"	return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" + 
39466
		"	       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
39467
		"Type safety: Unchecked cast from Object to R\n" + 
39468
		"----------\n");
39434
}
39469
}
39435
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=204536
39470
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=204536
39436
public void test1182() {
39471
public void test1182() {
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java (-3 / +13 lines)
Lines 2271-2279 Link Here
2271
					case METHOD_SCOPE :
2271
					case METHOD_SCOPE :
2272
						MethodScope methodScope = (MethodScope) scope;
2272
						MethodScope methodScope = (MethodScope) scope;
2273
						AbstractMethodDeclaration methodDecl = methodScope.referenceMethod();
2273
						AbstractMethodDeclaration methodDecl = methodScope.referenceMethod();
2274
						if (methodDecl != null && methodDecl.binding != null) {
2274
						if (methodDecl != null) {
2275
							TypeVariableBinding typeVariable = methodDecl.binding.getTypeVariable(name);
2275
							if (methodDecl.binding != null) {
2276
							if (typeVariable != null)	return typeVariable;
2276
								TypeVariableBinding typeVariable = methodDecl.binding.getTypeVariable(name);
2277
								if (typeVariable != null)
2278
									return typeVariable;
2279
							} else {
2280
								// use the methodDecl's typeParameters to handle problem cases when the method binding doesn't exist
2281
								TypeParameter[] params = methodDecl.typeParameters();
2282
								for (int i = params == null ? 0 : params.length; --i >= 0;)
2283
									if (CharOperation.equals(params[i].name, name))
2284
										if (params[i].binding != null && params[i].binding.isValidBinding())
2285
											return params[i].binding;
2286
							}
2277
						}
2287
						}
2278
						insideStaticContext |= methodScope.isStatic;
2288
						insideStaticContext |= methodScope.isStatic;
2279
						insideTypeAnnotation = methodScope.insideTypeAnnotation;
2289
						insideTypeAnnotation = methodScope.insideTypeAnnotation;

Return to bug 204534