Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 339478 | Differences between
and this patch

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java (-16 / +140 lines)
Lines 17-28 Link Here
17
 *******************************************************************************/
17
 *******************************************************************************/
18
package org.eclipse.jdt.internal.compiler.ast;
18
package org.eclipse.jdt.internal.compiler.ast;
19
19
20
import org.eclipse.jdt.core.compiler.CharOperation;
20
import org.eclipse.jdt.internal.compiler.ASTVisitor;
21
import org.eclipse.jdt.internal.compiler.ASTVisitor;
21
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
22
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
22
import org.eclipse.jdt.internal.compiler.codegen.*;
23
import org.eclipse.jdt.internal.compiler.codegen.*;
23
import org.eclipse.jdt.internal.compiler.flow.*;
24
import org.eclipse.jdt.internal.compiler.flow.*;
24
import org.eclipse.jdt.internal.compiler.impl.Constant;
25
import org.eclipse.jdt.internal.compiler.impl.Constant;
25
import org.eclipse.jdt.internal.compiler.lookup.*;
26
import org.eclipse.jdt.internal.compiler.lookup.*;
27
import org.eclipse.jdt.internal.compiler.util.SimpleLookupTable;
26
28
27
public class AllocationExpression extends Expression implements InvocationSite {
29
public class AllocationExpression extends Expression implements InvocationSite {
28
30
Lines 260-270 Link Here
260
		// initialization of an enum constant
262
		// initialization of an enum constant
261
		this.resolvedType = scope.enclosingReceiverType();
263
		this.resolvedType = scope.enclosingReceiverType();
262
	} else {
264
	} else {
263
		if ((this.type.bits & ASTNode.IsDiamond) != 0) {
265
		this.resolvedType = this.type.resolveType(scope, true /* check bounds*/);
264
			this.resolvedType = null; // can be done only after type arguments and method arguments resolution.
265
		} else {
266
			this.resolvedType = this.type.resolveType(scope, true /* check bounds*/);
267
		}
268
		// check for parameterized allocation deferred to below.
266
		// check for parameterized allocation deferred to below.
269
	}
267
	}
270
	// will check for null after args are resolved
268
	// will check for null after args are resolved
Lines 338-346 Link Here
338
			return this.resolvedType;
336
			return this.resolvedType;
339
		}
337
		}
340
	}
338
	}
341
	if (this.type != null && (this.type.bits & ASTNode.IsDiamond) != 0) {
339
	if (this.resolvedType == null || !this.resolvedType.isValidBinding()) {
342
		// Perform diamond inference here. (Not done yet.) 
340
		return null;
343
		this.resolvedType = this.type.resolveType(scope, true /* check bounds*/);  // for now just do what we do for 1.6-
341
	}
342
343
	// null type denotes fake allocation for enum constant inits
344
	if (this.type != null && !this.resolvedType.canBeInstantiated()) {
345
		scope.problemReporter().cannotInstantiate(this.type, this.resolvedType);
346
		return this.resolvedType;
347
	}
348
	if (this.type != null && this.resolvedType != null && (this.type.bits & ASTNode.IsDiamond) != 0) {
349
		TypeBinding [] inferredTypes = inferElidedTypes(((ParameterizedTypeBinding) this.resolvedType).genericType(), argumentTypes, scope);
350
		this.resolvedType = this.type.resolvedType = scope.environment().createParameterizedType(((ParameterizedTypeBinding) this.resolvedType).genericType(), inferredTypes, ((ParameterizedTypeBinding) this.resolvedType).enclosingType());
344
	}
351
	}
345
	checkParameterizedAllocation: {
352
	checkParameterizedAllocation: {
346
		if (this.type instanceof ParameterizedQualifiedTypeReference) { // disallow new X<String>.Y<Integer>()
353
		if (this.type instanceof ParameterizedQualifiedTypeReference) { // disallow new X<String>.Y<Integer>()
Lines 360-374 Link Here
360
			}
367
			}
361
		}
368
		}
362
	}
369
	}
363
	if (this.resolvedType == null || !this.resolvedType.isValidBinding()) {
364
		return null;
365
	}
366
370
367
	// null type denotes fake allocation for enum constant inits
368
	if (this.type != null && !this.resolvedType.canBeInstantiated()) {
369
		scope.problemReporter().cannotInstantiate(this.type, this.resolvedType);
370
		return this.resolvedType;
371
	}
372
	ReferenceBinding allocationType = (ReferenceBinding) this.resolvedType;
371
	ReferenceBinding allocationType = (ReferenceBinding) this.resolvedType;
373
	if (!(this.binding = scope.getConstructor(allocationType, argumentTypes, this)).isValidBinding()) {
372
	if (!(this.binding = scope.getConstructor(allocationType, argumentTypes, this)).isValidBinding()) {
374
		if (this.binding.declaringClass == null) {
373
		if (this.binding.declaringClass == null) {
Lines 394-399 Link Here
394
	return allocationType;
393
	return allocationType;
395
}
394
}
396
395
396
private TypeBinding[] inferElidedTypes(ReferenceBinding allocationType, TypeBinding[] argumentTypes, final BlockScope scope) {
397
	TypeVariableBinding[] classTypeVariables = allocationType.typeVariables();
398
	int classTypeVariablesArity = classTypeVariables.length;
399
	TypeBinding [] inferredTypes = new TypeBinding[classTypeVariablesArity];
400
	for (int i = 0; i < classTypeVariablesArity; i++) {
401
		inferredTypes[i] = new ProblemReferenceBinding(CharOperation.NO_CHAR_CHAR, null, ProblemReasons.InferenceFailed);
402
	}
403
	MethodBinding[] methods = allocationType.getMethods(TypeConstants.INIT, argumentTypes.length);
404
	MethodBinding [] staticFactories = new MethodBinding[methods.length];
405
	int sfi = 0;
406
	for (int i = 0, length = methods.length; i < length; i++) {
407
		MethodBinding method = methods[i];
408
409
		TypeVariableBinding[] methodTypeVariables = method.typeVariables();
410
		int methodTypeVariablesArity = methodTypeVariables.length;
411
412
		if (this.genericTypeArguments != null && this.genericTypeArguments.length < methodTypeVariablesArity)
413
			continue; // wrong tree, don't bark.
414
		MethodBinding staticFactory = new MethodBinding(method.modifiers | ClassFileConstants.AccStatic, TypeConstants.SYNTHETIC_STATIC_FACTORY,
415
																	null, null, null, method.declaringClass);
416
		staticFactory.typeVariables = new TypeVariableBinding[classTypeVariablesArity + (this.genericTypeArguments == null ? methodTypeVariablesArity : 0)];
417
		final SimpleLookupTable map = new SimpleLookupTable(classTypeVariablesArity + methodTypeVariablesArity);
418
		// Rename each type variable T of the type to T'
419
		for (int j = 0; j < classTypeVariablesArity; j++) {
420
			map.put(classTypeVariables[j], staticFactory.typeVariables[j] = new TypeVariableBinding(CharOperation.concat(classTypeVariables[j].sourceName, "'".toCharArray()), //$NON-NLS-1$
421
																		staticFactory, j, scope.environment()));
422
		}
423
		// Rename each type variable U of method U to U'' if not explicitly parameterized. Otherwise use the parameterizing type.
424
		for (int j = classTypeVariablesArity, max = classTypeVariablesArity + methodTypeVariablesArity; j < max; j++) {
425
			map.put(methodTypeVariables[j - classTypeVariablesArity], 
426
					this.genericTypeArguments != null ? this.genericTypeArguments[j - classTypeVariablesArity] :
427
						(staticFactory.typeVariables[j] = new TypeVariableBinding(CharOperation.concat(methodTypeVariables[j - classTypeVariablesArity].sourceName, "''".toCharArray()), //$NON-NLS-1$
428
																		staticFactory, j, scope.environment())));
429
		}
430
		
431
		Substitution substitution = new Substitution() {
432
				public LookupEnvironment environment() {
433
					return scope.environment();
434
				}
435
				public boolean isRawSubstitution() {
436
					return false;
437
				}
438
				public TypeBinding substitute(TypeVariableBinding typeVariable) {
439
					return (TypeBinding) map.get(typeVariable);
440
				}
441
			};
442
443
			// initialize new variable bounds
444
			for (int j = 0, max = classTypeVariablesArity + methodTypeVariablesArity; j < max; j++) {
445
				TypeVariableBinding originalVariable = j < classTypeVariablesArity ? classTypeVariables[j] : methodTypeVariables[j - classTypeVariablesArity];
446
				TypeBinding substitutedType = (TypeBinding) map.get(originalVariable);
447
				if (substitutedType instanceof TypeVariableBinding) {
448
					TypeVariableBinding substitutedVariable = (TypeVariableBinding) substitutedType;
449
					TypeBinding substitutedSuperclass = Scope.substitute(substitution, originalVariable.superclass);
450
					ReferenceBinding[] substitutedInterfaces = Scope.substitute(substitution, originalVariable.superInterfaces);
451
					if (originalVariable.firstBound != null) {
452
						substitutedVariable.firstBound = originalVariable.firstBound == originalVariable.superclass
453
								? substitutedSuperclass // could be array type or interface
454
										: substitutedInterfaces[0];
455
					}
456
					switch (substitutedSuperclass.kind()) {
457
						case Binding.ARRAY_TYPE :
458
							substitutedVariable.superclass = scope.environment().getResolvedType(TypeConstants.JAVA_LANG_OBJECT, null);
459
							substitutedVariable.superInterfaces = substitutedInterfaces;
460
							break;
461
						default:
462
							if (substitutedSuperclass.isInterface()) {
463
								substitutedVariable.superclass = scope.environment().getResolvedType(TypeConstants.JAVA_LANG_OBJECT, null);
464
								int interfaceCount = substitutedInterfaces.length;
465
								System.arraycopy(substitutedInterfaces, 0, substitutedInterfaces = new ReferenceBinding[interfaceCount+1], 1, interfaceCount);
466
								substitutedInterfaces[0] = (ReferenceBinding) substitutedSuperclass;
467
								substitutedVariable.superInterfaces = substitutedInterfaces;
468
							} else {
469
								substitutedVariable.superclass = (ReferenceBinding) substitutedSuperclass; // typeVar was extending other typeVar which got substituted with interface
470
								substitutedVariable.superInterfaces = substitutedInterfaces;
471
							}
472
					}
473
				}
474
			}
475
		    TypeVariableBinding[] returnTypeParameters = new TypeVariableBinding[classTypeVariablesArity];
476
			for (int j = 0; j < classTypeVariablesArity; j++) {
477
				returnTypeParameters[j] = (TypeVariableBinding) map.get(classTypeVariables[j]);
478
			}
479
			staticFactory.returnType = scope.environment().createParameterizedType(allocationType, returnTypeParameters, allocationType.enclosingType());
480
			staticFactory.parameters = Scope.substitute(substitution, method.parameters);
481
			staticFactory.thrownExceptions = Scope.substitute(substitution, method.thrownExceptions);
482
			if (staticFactory.thrownExceptions == null) { 
483
				staticFactory.thrownExceptions = Binding.NO_EXCEPTIONS;
484
			}
485
			staticFactories[sfi++] = new ParameterizedMethodBinding((ParameterizedTypeBinding) scope.environment().convertToParameterizedType(staticFactory.declaringClass),
486
											staticFactory);
487
	}
488
	if (sfi != methods.length) {
489
		System.arraycopy(staticFactories, 0, staticFactories = new MethodBinding[sfi], 0, sfi);
490
	}
491
	MethodBinding[] compatible = new MethodBinding[sfi];
492
	int compatibleIndex = 0;
493
	for (int i = 0; i < sfi; i++) {
494
		MethodBinding compatibleMethod = scope.computeCompatibleMethod(staticFactories[i], argumentTypes, this);
495
		if (compatibleMethod != null) {
496
			if (compatibleMethod.isValidBinding())
497
				compatible[compatibleIndex++] = compatibleMethod;
498
		}
499
	}
500
501
	if (compatibleIndex == 0) {
502
		return inferredTypes;
503
	}
504
	MethodBinding[] visible = new MethodBinding[compatibleIndex];
505
	int visibleIndex = 0;
506
	for (int i = 0; i < compatibleIndex; i++) {
507
		MethodBinding method = compatible[i];
508
		if (method.canBeSeenBy(this, scope))
509
			visible[visibleIndex++] = method;
510
	}
511
	if (visibleIndex == 0) {
512
		return inferredTypes;
513
	}
514
	MethodBinding mostSpecific = visibleIndex == 1 ? visible[0] : scope.mostSpecificMethodBinding(visible, visibleIndex, argumentTypes, this, allocationType);
515
	if (mostSpecific == null || !mostSpecific.isValidBinding()) {
516
		return inferredTypes;
517
	}
518
	return ((ParameterizedGenericMethodBinding) mostSpecific).typeArguments;
519
}
520
397
public void setActualReceiverType(ReferenceBinding receiverType) {
521
public void setActualReceiverType(ReferenceBinding receiverType) {
398
	// ignored
522
	// ignored
399
}
523
}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java (-1 / +1 lines)
Lines 268-274 Link Here
268
				// check argument type compatibility
268
				// check argument type compatibility
269
				if (checkBounds) // otherwise will do it in Scope.connectTypeVariables() or generic method resolution
269
				if (checkBounds) // otherwise will do it in Scope.connectTypeVariables() or generic method resolution
270
					parameterizedType.boundCheck(scope, args);
270
					parameterizedType.boundCheck(scope, args);
271
				else
271
				else if ((this.bits & ASTNode.IsDiamond) == 0)
272
					scope.deferBoundCheck(this);
272
					scope.deferBoundCheck(this);
273
				qualifyingType = parameterizedType;
273
				qualifyingType = parameterizedType;
274
		    } else {
274
		    } else {
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java (-1 / +1 lines)
Lines 245-251 Link Here
245
		// check argument type compatibility
245
		// check argument type compatibility
246
		if (checkBounds) // otherwise will do it in Scope.connectTypeVariables() or generic method resolution
246
		if (checkBounds) // otherwise will do it in Scope.connectTypeVariables() or generic method resolution
247
			parameterizedType.boundCheck(scope, this.typeArguments);
247
			parameterizedType.boundCheck(scope, this.typeArguments);
248
		else
248
		else if ((this.bits & ASTNode.IsDiamond) == 0)
249
			scope.deferBoundCheck(this);
249
			scope.deferBoundCheck(this);
250
		if (isTypeUseDeprecated(parameterizedType, scope))
250
		if (isTypeUseDeprecated(parameterizedType, scope))
251
			reportDeprecatedType(parameterizedType, scope);
251
			reportDeprecatedType(parameterizedType, scope);
(-)compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java (-5 / +1 lines)
Lines 275-285 Link Here
275
				// initialization of an enum constant
275
				// initialization of an enum constant
276
				receiverType = scope.enclosingSourceType();
276
				receiverType = scope.enclosingSourceType();
277
			} else {
277
			} else {
278
				if ((this.type.bits & ASTNode.IsDiamond) == 0) {
278
				receiverType = this.type.resolveType(scope, true /* check bounds*/);
279
					receiverType = this.type.resolveType(scope, true /* check bounds*/);
280
				} else {
281
					// can be done only after type arguments and method arguments resolution
282
				}
283
				// check for parameterized allocation deferred to below.
279
				// check for parameterized allocation deferred to below.
284
			}
280
			}
285
		}
281
		}
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemReasons.java (+1 lines)
Lines 31-34 Link Here
31
	final int TypeArgumentsForRawGenericMethod = 13; // for generic method
31
	final int TypeArgumentsForRawGenericMethod = 13; // for generic method
32
	final int InvalidTypeForStaticImport = 14;
32
	final int InvalidTypeForStaticImport = 14;
33
	final int InvalidTypeForAutoManagedResource = 15;
33
	final int InvalidTypeForAutoManagedResource = 15;
34
	final int InferenceFailed = 16;
34
}
35
}
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java (-2 / +2 lines)
Lines 511-517 Link Here
511
	 * Will answer a substituted method in case the method was generic and type inference got triggered;
511
	 * Will answer a substituted method in case the method was generic and type inference got triggered;
512
	 * in case the method was originally compatible, then simply answer it back.
512
	 * in case the method was originally compatible, then simply answer it back.
513
	 */
513
	 */
514
	protected final MethodBinding computeCompatibleMethod(MethodBinding method, TypeBinding[] arguments, InvocationSite invocationSite) {
514
	public final MethodBinding computeCompatibleMethod(MethodBinding method, TypeBinding[] arguments, InvocationSite invocationSite) {
515
		TypeBinding[] genericTypeArguments = invocationSite.genericTypeArguments();
515
		TypeBinding[] genericTypeArguments = invocationSite.genericTypeArguments();
516
		TypeBinding[] parameters = method.parameters;
516
		TypeBinding[] parameters = method.parameters;
517
		TypeVariableBinding[] typeVariables = method.typeVariables;
517
		TypeVariableBinding[] typeVariables = method.typeVariables;
Lines 3686-3692 Link Here
3686
	}
3686
	}
3687
3687
3688
	// caveat: this is not a direct implementation of JLS
3688
	// caveat: this is not a direct implementation of JLS
3689
	protected final MethodBinding mostSpecificMethodBinding(MethodBinding[] visible, int visibleSize, TypeBinding[] argumentTypes, final InvocationSite invocationSite, ReferenceBinding receiverType) {
3689
	public final MethodBinding mostSpecificMethodBinding(MethodBinding[] visible, int visibleSize, TypeBinding[] argumentTypes, final InvocationSite invocationSite, ReferenceBinding receiverType) {
3690
		int[] compatibilityLevels = new int[visibleSize];
3690
		int[] compatibilityLevels = new int[visibleSize];
3691
		for (int i = 0; i < visibleSize; i++)
3691
		for (int i = 0; i < visibleSize; i++)
3692
			compatibilityLevels[i] = parameterCompatibilityLevel(visible[i], argumentTypes);
3692
			compatibilityLevels[i] = parameterCompatibilityLevel(visible[i], argumentTypes);
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java (+1 lines)
Lines 170-175 Link Here
170
	char[] SYNTHETIC_ENCLOSING_INSTANCE_PREFIX = "this$".toCharArray(); //$NON-NLS-1$
170
	char[] SYNTHETIC_ENCLOSING_INSTANCE_PREFIX = "this$".toCharArray(); //$NON-NLS-1$
171
	char[] SYNTHETIC_ACCESS_METHOD_PREFIX =  "access$".toCharArray(); //$NON-NLS-1$
171
	char[] SYNTHETIC_ACCESS_METHOD_PREFIX =  "access$".toCharArray(); //$NON-NLS-1$
172
	char[] SYNTHETIC_ENUM_CONSTANT_INITIALIZATION_METHOD_PREFIX =  " enum constant initialization$".toCharArray(); //$NON-NLS-1$
172
	char[] SYNTHETIC_ENUM_CONSTANT_INITIALIZATION_METHOD_PREFIX =  " enum constant initialization$".toCharArray(); //$NON-NLS-1$
173
	char[] SYNTHETIC_STATIC_FACTORY =  "<factory>".toCharArray(); //$NON-NLS-1$
173
174
174
	// synthetic package-info name
175
	// synthetic package-info name
175
	public static final char[] PACKAGE_INFO_NAME = "package-info".toCharArray(); //$NON-NLS-1$
176
	public static final char[] PACKAGE_INFO_NAME = "package-info".toCharArray(); //$NON-NLS-1$
(-)src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_7.java (-33 / +53 lines)
Lines 18-24 Link Here
18
public class GenericsRegressionTest_1_7 extends AbstractRegressionTest {
18
public class GenericsRegressionTest_1_7 extends AbstractRegressionTest {
19
19
20
static {
20
static {
21
//	TESTS_NAMES = new String[] { "test0014" };
21
//	TESTS_NAMES = new String[] { "test0016" };
22
//	TESTS_NUMBERS = new int[] { 40, 41, 43, 45, 63, 64 };
22
//	TESTS_NUMBERS = new int[] { 40, 41, 43, 45, 63, 64 };
23
//	TESTS_RANGE = new int[] { 11, -1 };
23
//	TESTS_RANGE = new int[] { 11, -1 };
24
}
24
}
Lines 28-34 Link Here
28
public static Test suite() {
28
public static Test suite() {
29
	return buildMinimalComplianceTestSuite(testClass(), F_1_7);
29
	return buildMinimalComplianceTestSuite(testClass(), F_1_7);
30
}
30
}
31
public void _test001() {
31
public void test001() {
32
	this.runConformTest(
32
	this.runConformTest(
33
		new String[] {
33
		new String[] {
34
			"X.java",
34
			"X.java",
Lines 44-50 Link Here
44
		},
44
		},
45
		"SUCCESS");
45
		"SUCCESS");
46
}
46
}
47
public void _test001a() {
47
public void test001a() {
48
	this.runNegativeTest(
48
	this.runNegativeTest(
49
		new String[] {
49
		new String[] {
50
			"X.java",
50
			"X.java",
Lines 65-71 Link Here
65
		"The method testFunction(String) in the type X<String> is not applicable for the arguments (int)\n" + 
65
		"The method testFunction(String) in the type X<String> is not applicable for the arguments (int)\n" + 
66
		"----------\n");
66
		"----------\n");
67
}
67
}
68
public void _test001b() {
68
public void test001b() {
69
	this.runConformTest(
69
	this.runConformTest(
70
		new String[] {
70
		new String[] {
71
			"X.java",
71
			"X.java",
Lines 80-86 Link Here
80
		"SUCCESS");
80
		"SUCCESS");
81
}
81
}
82
// fields
82
// fields
83
public void _test001b_1() {
83
public void test001b_1() {
84
	this.runConformTest(
84
	this.runConformTest(
85
		new String[] {
85
		new String[] {
86
			"X.java",
86
			"X.java",
Lines 94-100 Link Here
94
		},
94
		},
95
		"SUCCESS");
95
		"SUCCESS");
96
}
96
}
97
public void _test001c() {
97
public void test001c() {
98
	this.runNegativeTest(
98
	this.runNegativeTest(
99
		new String[] {
99
		new String[] {
100
			"X.java",
100
			"X.java",
Lines 114-120 Link Here
114
		"----------\n");
114
		"----------\n");
115
}
115
}
116
// fields
116
// fields
117
public void _test001c_1() {
117
public void test001c_1() {
118
	this.runNegativeTest(
118
	this.runNegativeTest(
119
		new String[] {
119
		new String[] {
120
			"X.java",
120
			"X.java",
Lines 133-139 Link Here
133
		"The method add(int, String) in the type ArrayList<String> is not applicable for the arguments (int)\n" + 
133
		"The method add(int, String) in the type ArrayList<String> is not applicable for the arguments (int)\n" + 
134
		"----------\n");
134
		"----------\n");
135
}
135
}
136
public void _test001d() {
136
public void test001d() {
137
	this.runNegativeTest(
137
	this.runNegativeTest(
138
		new String[] {
138
		new String[] {
139
			"X.java",
139
			"X.java",
Lines 155-161 Link Here
155
		"The method ab(ArrayList<String>) in the type X<String> is not applicable for the arguments (ArrayList<Object>)\n" + 
155
		"The method ab(ArrayList<String>) in the type X<String> is not applicable for the arguments (ArrayList<Object>)\n" + 
156
		"----------\n");
156
		"----------\n");
157
}
157
}
158
public void _test001e() {
158
public void test001e() {
159
	this.runNegativeTest(
159
	this.runNegativeTest(
160
		new String[] {
160
		new String[] {
161
			"X.java",
161
			"X.java",
Lines 177-183 Link Here
177
		"The method ab(ArrayList<String>) in the type X<String> is not applicable for the arguments (ArrayList<Object>)\n" + 
177
		"The method ab(ArrayList<String>) in the type X<String> is not applicable for the arguments (ArrayList<Object>)\n" + 
178
		"----------\n");
178
		"----------\n");
179
}
179
}
180
public void _test001f() {
180
public void test001f() {
181
	this.runConformTest(
181
	this.runConformTest(
182
		new String[] {
182
		new String[] {
183
			"X.java",
183
			"X.java",
Lines 216-222 Link Here
216
		},
216
		},
217
		"SUCCESS");
217
		"SUCCESS");
218
}
218
}
219
public void _test001g() {
219
public void test001g() {
220
	this.runConformTest(
220
	this.runConformTest(
221
		new String[] {
221
		new String[] {
222
			"X.java",
222
			"X.java",
Lines 256-262 Link Here
256
		},
256
		},
257
		"SUCCESS\n1");
257
		"SUCCESS\n1");
258
}
258
}
259
public void _test001h() {
259
public void test001h() {
260
	this.runNegativeTest(
260
	this.runNegativeTest(
261
		new String[] {
261
		new String[] {
262
			"X.java",
262
			"X.java",
Lines 284-290 Link Here
284
		"The method methodx(String) in the type X<String>.X2<String> is not applicable for the arguments (int)\n" + 
284
		"The method methodx(String) in the type X<String>.X2<String> is not applicable for the arguments (int)\n" + 
285
		"----------\n");
285
		"----------\n");
286
}
286
}
287
public void _test001h_1() {
287
public void test001h_1() {
288
	this.runNegativeTest(
288
	this.runNegativeTest(
289
		new String[] {
289
		new String[] {
290
			"X.java",
290
			"X.java",
Lines 329-335 Link Here
329
		"Type safety: The method methodx(Object) belongs to the raw type X.X2. References to generic type X<T>.X2<T> should be parameterized\n" + 
329
		"Type safety: The method methodx(Object) belongs to the raw type X.X2. References to generic type X<T>.X2<T> should be parameterized\n" + 
330
		"----------\n");
330
		"----------\n");
331
}
331
}
332
public void _test001i() {
332
public void test001i() {
333
	this.runConformTest(
333
	this.runConformTest(
334
		new String[] {
334
		new String[] {
335
			"X.java",
335
			"X.java",
Lines 376-382 Link Here
376
		"Type safety: The method testFunction(Object) belongs to the raw type X. References to generic type X<T> should be parameterized\n" + 
376
		"Type safety: The method testFunction(Object) belongs to the raw type X. References to generic type X<T> should be parameterized\n" + 
377
		"----------\n");
377
		"----------\n");
378
}
378
}
379
public void _test003() {
379
public void test003() {
380
	this.runConformTest(
380
	this.runConformTest(
381
		new String[] {
381
		new String[] {
382
			"X.java",
382
			"X.java",
Lines 392-398 Link Here
392
		"SUCCESS");
392
		"SUCCESS");
393
}
393
}
394
394
395
public void _test004b() {
395
public void test004b() {
396
	this.runNegativeTest(
396
	this.runNegativeTest(
397
		new String[] {
397
		new String[] {
398
			"X.java",
398
			"X.java",
Lines 437-443 Link Here
437
		"1");
437
		"1");
438
}
438
}
439
439
440
public void _test006() {
440
public void test006() {
441
	this.runConformTest(
441
	this.runConformTest(
442
		new String[] {
442
		new String[] {
443
			"X.java",
443
			"X.java",
Lines 460-466 Link Here
460
		"SUCCESS");
460
		"SUCCESS");
461
}
461
}
462
// shows the difference between using <> and the raw type - different semantics
462
// shows the difference between using <> and the raw type - different semantics
463
public void _test007() {
463
public void test007() {
464
	this.runConformTest(
464
	this.runConformTest(
465
		new String[] {
465
		new String[] {
466
			"X.java",
466
			"X.java",
Lines 487-493 Link Here
487
		"1\n" + 
487
		"1\n" + 
488
		"2");
488
		"2");
489
}
489
}
490
public void _test007a() {
490
public void test007a() {
491
	this.runNegativeTest(
491
	this.runNegativeTest(
492
		new String[] {
492
		new String[] {
493
			"X.java",
493
			"X.java",
Lines 529-540 Link Here
529
		"----------\n");
529
		"----------\n");
530
}
530
}
531
//shows the difference between using <> and the raw type - different semantics
531
//shows the difference between using <> and the raw type - different semantics
532
public void _test008() {
532
public void test008() {
533
	this.runConformTest(
533
	this.runNegativeTest(
534
		new String[] {
534
		new String[] {
535
			"X.java",
535
			"X.java",
536
			"public class X<T> {\n" +
536
			"public class X<T> {\n" +
537
			"	T field1;" +
537
			"	T field1;\n" +
538
			"	public X(T param){\n" +
538
			"	public X(T param){\n" +
539
			"		field1 = param;\n" +
539
			"		field1 = param;\n" +
540
			"	}\n" +
540
			"	}\n" +
Lines 547-556 Link Here
547
			"	}\n" + 
547
			"	}\n" + 
548
			"}",
548
			"}",
549
		},
549
		},
550
		"");
550
		"----------\n" + 
551
		"1. WARNING in X.java (at line 7)\n" + 
552
		"	X<?> x1 = new X(1).get(\"\");\n" + 
553
		"	          ^^^^^^^^\n" + 
554
		"Type safety: The constructor X(Object) belongs to the raw type X. References to generic type X<T> should be parameterized\n" + 
555
		"----------\n" + 
556
		"2. WARNING in X.java (at line 7)\n" + 
557
		"	X<?> x1 = new X(1).get(\"\");\n" + 
558
		"	          ^^^^^^^^^^^^^^^^\n" + 
559
		"Type safety: The method get(Object) belongs to the raw type X. References to generic type X<T> should be parameterized\n" + 
560
		"----------\n" + 
561
		"3. WARNING in X.java (at line 7)\n" + 
562
		"	X<?> x1 = new X(1).get(\"\");\n" + 
563
		"	              ^\n" + 
564
		"X is a raw type. References to generic type X<T> should be parameterized\n" + 
565
		"----------\n" + 
566
		"4. ERROR in X.java (at line 8)\n" + 
567
		"	X<?> x2 = new X<>(1).get(\"\");\n" + 
568
		"	                     ^^^\n" + 
569
		"The method get(Integer) in the type X<Integer> is not applicable for the arguments (String)\n" + 
570
		"----------\n");
551
}
571
}
552
572
553
public void _test0014() {
573
public void test0014() {
554
	this.runConformTest(
574
	this.runConformTest(
555
		new String[] {
575
		new String[] {
556
			"X.java",
576
			"X.java",
Lines 568-574 Link Here
568
		"SUCCESS\n" +
588
		"SUCCESS\n" +
569
		"123");
589
		"123");
570
}
590
}
571
public void _test0014a() {
591
public void test0014a() {
572
	this.runNegativeTest(
592
	this.runNegativeTest(
573
		new String[] {
593
		new String[] {
574
			"X.java",
594
			"X.java",
Lines 590-596 Link Here
590
		"The method testFunction(String, Integer) in the type X<String,Integer> is not applicable for the arguments (int, String)\n" + 
610
		"The method testFunction(String, Integer) in the type X<String,Integer> is not applicable for the arguments (int, String)\n" + 
591
		"----------\n");
611
		"----------\n");
592
}
612
}
593
public void _test0015() {
613
public void test0015() {
594
	this.runConformTest(
614
	this.runConformTest(
595
		new String[] {
615
		new String[] {
596
			"X.java",
616
			"X.java",
Lines 611-617 Link Here
611
}
631
}
612
// To verify that a parameterized invocation of a generic constructor works even if <> is used
632
// To verify that a parameterized invocation of a generic constructor works even if <> is used
613
// to elide class type parameters.
633
// to elide class type parameters.
614
public void _test0016() {
634
public void test0016() {
615
	this.runConformTest(
635
	this.runConformTest(
616
		new String[] {
636
		new String[] {
617
			"X.java",
637
			"X.java",
Lines 632-638 Link Here
632
}
652
}
633
// To verify that a parameterized invocation of a generic constructor works even if <> is used
653
// To verify that a parameterized invocation of a generic constructor works even if <> is used
634
// to elide class type parameters. This test handles fields
654
// to elide class type parameters. This test handles fields
635
public void _test0016b() {
655
public void test0016b() {
636
	this.runConformTest(
656
	this.runConformTest(
637
		new String[] {
657
		new String[] {
638
			"X.java",
658
			"X.java",
Lines 657-663 Link Here
657
// To verify that a parameterized invocation of a non-generic constructor works even if <> is used
677
// To verify that a parameterized invocation of a non-generic constructor works even if <> is used
658
// to elide class type parameters.
678
// to elide class type parameters.
659
// This was not allowed in java 1.6 and 1.5 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=168230)
679
// This was not allowed in java 1.6 and 1.5 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=168230)
660
public void _test0017() {
680
public void test0017() {
661
	this.runConformTest(
681
	this.runConformTest(
662
		new String[] {
682
		new String[] {
663
			"X.java",
683
			"X.java",
Lines 679-685 Link Here
679
		"const.1\nconst.1\nconst.2");
699
		"const.1\nconst.1\nconst.2");
680
}
700
}
681
// To verify that the correct constructor is found by parameter substitution in the diamond case
701
// To verify that the correct constructor is found by parameter substitution in the diamond case
682
public void _test0018() {
702
public void test0018() {
683
	this.runConformTest(
703
	this.runConformTest(
684
		new String[] {
704
		new String[] {
685
			"X.java",
705
			"X.java",
Lines 700-706 Link Here
700
}
720
}
701
// To verify that the correct constructor is found by parameter substitution 
721
// To verify that the correct constructor is found by parameter substitution 
702
// in the diamond case -- fields
722
// in the diamond case -- fields
703
public void _test0018b() {
723
public void test0018b() {
704
	this.runConformTest(
724
	this.runConformTest(
705
		new String[] {
725
		new String[] {
706
			"X.java",
726
			"X.java",
Lines 738-744 Link Here
738
		"----------\n");
758
		"----------\n");
739
}
759
}
740
// check inference at method argument position.
760
// check inference at method argument position.
741
public void _test0020() {
761
public void test0020() {
742
	this.runNegativeTest(
762
	this.runNegativeTest(
743
		new String[] {
763
		new String[] {
744
			"X.java",
764
			"X.java",
Lines 757-763 Link Here
757
		"----------\n");
777
		"----------\n");
758
}
778
}
759
//check inference at method argument position.
779
//check inference at method argument position.
760
public void _test0021() {
780
public void test0021() {
761
	this.runNegativeTest(
781
	this.runNegativeTest(
762
		new String[] {
782
		new String[] {
763
			"X.java",
783
			"X.java",

Return to bug 339478