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 (-1 / +18 lines)
Lines 5-10 Link Here
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
7
 *
8
 * This is an implementation of an early-draft specification developed under the Java
9
 * Community Process (JCP) and is made available for testing and evaluation purposes
10
 * only. The code is not compatible with any specification of the JCP.
11
 * 
8
 * Contributors:
12
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
13
 *     IBM Corporation - initial API and implementation
10
 *     Stephan Herrmann - Contributions for 
14
 *     Stephan Herrmann - Contributions for 
Lines 29-34 Link Here
29
	public TypeReference[] typeArguments;
33
	public TypeReference[] typeArguments;
30
	public TypeBinding[] genericTypeArguments;
34
	public TypeBinding[] genericTypeArguments;
31
	public FieldDeclaration enumConstant; // for enum constant initializations
35
	public FieldDeclaration enumConstant; // for enum constant initializations
36
	protected TypeBinding expectedType; // for <> inference
32
37
33
public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
38
public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
34
	// check captured variables are initialized in current context (26134)
39
	// check captured variables are initialized in current context (26134)
Lines 255-261 Link Here
255
		// initialization of an enum constant
260
		// initialization of an enum constant
256
		this.resolvedType = scope.enclosingReceiverType();
261
		this.resolvedType = scope.enclosingReceiverType();
257
	} else {
262
	} else {
258
		this.resolvedType = this.type.resolveType(scope, true /* check bounds*/);
263
		TypeBinding lhsType = null;
264
		if ((this.type.bits & ASTNode.IsDiamond) != 0) {
265
			if (this.expectedType != null && this.expectedType.isParameterizedTypeWithActualArguments())
266
				lhsType = this.expectedType;
267
		}
268
		this.resolvedType = this.type.resolveType(scope, true /* check bounds*/, lhsType);
259
		checkParameterizedAllocation: {
269
		checkParameterizedAllocation: {
260
			if (this.type instanceof ParameterizedQualifiedTypeReference) { // disallow new X<String>.Y<Integer>()
270
			if (this.type instanceof ParameterizedQualifiedTypeReference) { // disallow new X<String>.Y<Integer>()
261
				ReferenceBinding currentType = (ReferenceBinding)this.resolvedType;
271
				ReferenceBinding currentType = (ReferenceBinding)this.resolvedType;
Lines 409-412 Link Here
409
	}
419
	}
410
	visitor.endVisit(this, scope);
420
	visitor.endVisit(this, scope);
411
}
421
}
422
/**
423
 * @see org.eclipse.jdt.internal.compiler.ast.Expression#setExpectedType(org.eclipse.jdt.internal.compiler.lookup.TypeBinding)
424
 */
425
public void setExpectedType(TypeBinding expectedType) {
426
	this.expectedType = expectedType;
427
}
428
412
}
429
}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java (-7 / +17 lines)
Lines 111-117 Link Here
111
    /*
111
    /*
112
     * No need to check for reference to raw type per construction
112
     * No need to check for reference to raw type per construction
113
     */
113
     */
114
	private TypeBinding internalResolveType(Scope scope, boolean checkBounds) {
114
	private TypeBinding internalResolveType(Scope scope, boolean checkBounds, TypeBinding expectedType) {
115
		// handle the error here
115
		// handle the error here
116
		this.constant = Constant.NotAConstant;
116
		this.constant = Constant.NotAConstant;
117
		if ((this.bits & ASTNode.DidResolve) != 0) { // is a shared type reference which was already resolved
117
		if ((this.bits & ASTNode.DidResolve) != 0) { // is a shared type reference which was already resolved
Lines 223-228 Link Here
223
						argTypes[j] = argType;
223
						argTypes[j] = argType;
224
					}
224
					}
225
				}
225
				}
226
				if ((this.bits & ASTNode.IsDiamond) != 0) {
227
					if (expectedType != null && expectedType.isParameterizedTypeWithActualArguments())
228
						argTypes = ((ParameterizedTypeBinding) expectedType).arguments;
229
				}
226
				if (argHasError) {
230
				if (argHasError) {
227
					return null;
231
					return null;
228
				}
232
				}
Lines 247-255 Link Here
247
						this.resolvedType = scope.createArrayType(this.resolvedType, this.dimensions);
251
						this.resolvedType = scope.createArrayType(this.resolvedType, this.dimensions);
248
					}
252
					}
249
					return this.resolvedType;
253
					return this.resolvedType;
250
				} else if (argLength != typeVariables.length && !isDiamond) { // check arity
254
				} else if (argLength != typeVariables.length) {
251
					scope.problemReporter().incorrectArityForParameterizedType(this, currentType, argTypes, i);
255
					if (!isDiamond) { // check arity
252
					return null;
256
						scope.problemReporter().incorrectArityForParameterizedType(this, currentType, argTypes, i);
257
						return null;
258
					}
259
					checkBounds = false; // successful <> inference needs no bounds check, we will scream foul if needed during inference.
253
				}
260
				}
254
				// check parameterizing non-static member type of raw type
261
				// check parameterizing non-static member type of raw type
255
				if (typeIsConsistent && !currentType.isStatic()) {
262
				if (typeIsConsistent && !currentType.isStatic()) {
Lines 344-355 Link Here
344
		}
351
		}
345
		return output;
352
		return output;
346
	}
353
	}
347
354
	
355
	public TypeBinding resolveType(BlockScope scope, boolean checkBounds, TypeBinding expectedType) {
356
	    return internalResolveType(scope, checkBounds, expectedType);
357
	}
348
	public TypeBinding resolveType(BlockScope scope, boolean checkBounds) {
358
	public TypeBinding resolveType(BlockScope scope, boolean checkBounds) {
349
	    return internalResolveType(scope, checkBounds);
359
	    return internalResolveType(scope, checkBounds, null);
350
	}
360
	}
351
	public TypeBinding resolveType(ClassScope scope) {
361
	public TypeBinding resolveType(ClassScope scope) {
352
	    return internalResolveType(scope, false);
362
	    return internalResolveType(scope, false, null);
353
	}
363
	}
354
	public void traverse(ASTVisitor visitor, BlockScope scope) {
364
	public void traverse(ASTVisitor visitor, BlockScope scope) {
355
		if (visitor.visit(this, scope)) {
365
		if (visitor.visit(this, scope)) {
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java (-7 / +22 lines)
Lines 89-95 Link Here
89
    /*
89
    /*
90
     * No need to check for reference to raw type per construction
90
     * No need to check for reference to raw type per construction
91
     */
91
     */
92
	private TypeBinding internalResolveType(Scope scope, ReferenceBinding enclosingType, boolean checkBounds) {
92
	private TypeBinding internalResolveType(Scope scope, ReferenceBinding enclosingType, boolean checkBounds, TypeBinding expectedType) {
93
		// handle the error here
93
		// handle the error here
94
		this.constant = Constant.NotAConstant;
94
		this.constant = Constant.NotAConstant;
95
		if ((this.bits & ASTNode.DidResolve) != 0) { // is a shared type reference which was already resolved
95
		if ((this.bits & ASTNode.DidResolve) != 0) { // is a shared type reference which was already resolved
Lines 188-193 Link Here
188
			    argTypes[i] = argType;
188
			    argTypes[i] = argType;
189
		     }
189
		     }
190
		}
190
		}
191
		if ((this.bits & ASTNode.IsDiamond) != 0) {
192
			if (expectedType != null && expectedType.isParameterizedTypeWithActualArguments())
193
				argTypes = ((ParameterizedTypeBinding) expectedType).arguments;
194
		}
191
		if (argHasError) {
195
		if (argHasError) {
192
			return null;
196
			return null;
193
		}
197
		}
Lines 221-229 Link Here
221
				return this.resolvedType = type;
225
				return this.resolvedType = type;
222
			}
226
			}
223
			// if missing generic type, and compliance >= 1.5, then will rebuild a parameterized binding
227
			// if missing generic type, and compliance >= 1.5, then will rebuild a parameterized binding
224
		} else if (argLength != typeVariables.length && (this.bits & ASTNode.IsDiamond) == 0) { // check arity, IsDiamond never set for 1.6-
228
		} else if (argLength != typeVariables.length) {
225
			scope.problemReporter().incorrectArityForParameterizedType(this, currentType, argTypes);
229
			if ((this.bits & ASTNode.IsDiamond) == 0) { // check arity, IsDiamond never set for 1.6-
226
			return null;
230
				scope.problemReporter().incorrectArityForParameterizedType(this, currentType, argTypes);
231
				return null;
232
			} 
233
			checkBounds = false; // successful <> inference needs no bounds check, we will scream foul if needed during inference.
227
		} else if (!currentType.isStatic()) {
234
		} else if (!currentType.isStatic()) {
228
			ReferenceBinding actualEnclosing = currentType.enclosingType();
235
			ReferenceBinding actualEnclosing = currentType.enclosingType();
229
			if (actualEnclosing != null && actualEnclosing.isRawType()){
236
			if (actualEnclosing != null && actualEnclosing.isRawType()){
Lines 281-296 Link Here
281
		return output;
288
		return output;
282
	}
289
	}
283
290
291
	public TypeBinding resolveType(BlockScope scope, boolean checkBounds, TypeBinding expectedType) {
292
	    return internalResolveType(scope, null, checkBounds, expectedType);
293
	}
294
	
284
	public TypeBinding resolveType(BlockScope scope, boolean checkBounds) {
295
	public TypeBinding resolveType(BlockScope scope, boolean checkBounds) {
285
	    return internalResolveType(scope, null, checkBounds);
296
	    return internalResolveType(scope, null, checkBounds, null);
286
	}
297
	}
287
298
288
	public TypeBinding resolveType(ClassScope scope) {
299
	public TypeBinding resolveType(ClassScope scope) {
289
	    return internalResolveType(scope, null, false /*no bounds check in classScope*/);
300
	    return internalResolveType(scope, null, false /*no bounds check in classScope*/, null);
290
	}
301
	}
291
302
292
	public TypeBinding resolveTypeEnclosing(BlockScope scope, ReferenceBinding enclosingType) {
303
	public TypeBinding resolveTypeEnclosing(BlockScope scope, ReferenceBinding enclosingType) {
293
	    return internalResolveType(scope, enclosingType, true/*check bounds*/);
304
	    return internalResolveType(scope, enclosingType, true/*check bounds*/, null);
305
	}
306
	
307
	public TypeBinding resolveTypeEnclosing(BlockScope scope, ReferenceBinding enclosingType, TypeBinding expectedType) {
308
	    return internalResolveType(scope, enclosingType, true/*check bounds*/, expectedType);
294
	}
309
	}
295
310
296
	public void traverse(ASTVisitor visitor, BlockScope scope) {
311
	public void traverse(ASTVisitor visitor, BlockScope scope) {
(-)compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java (-7 / +25 lines)
Lines 5-10 Link Here
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
7
 *
8
 * This is an implementation of an early-draft specification developed under the Java
9
 * Community Process (JCP) and is made available for testing and evaluation purposes
10
 * only. The code is not compatible with any specification of the JCP.
11
 * 
8
 * Contributors:
12
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
13
 *     IBM Corporation - initial API and implementation
10
 *     Stephan Herrmann - Contribution for bug 319201 - [null] no warning when unboxing SingleNameReference causes NPE
14
 *     Stephan Herrmann - Contribution for bug 319201 - [null] no warning when unboxing SingleNameReference causes NPE
Lines 261-267 Link Here
261
				scope.problemReporter().invalidType(this.enclosingInstance, enclosingInstanceType);
265
				scope.problemReporter().invalidType(this.enclosingInstance, enclosingInstanceType);
262
				hasError = true;
266
				hasError = true;
263
			} else {
267
			} else {
264
				receiverType = ((SingleTypeReference) this.type).resolveTypeEnclosing(scope, (ReferenceBinding) enclosingInstanceType);
268
				TypeBinding lhsType = null;
269
				if ((this.type.bits & ASTNode.IsDiamond) != 0) {
270
					if (this.expectedType != null && this.expectedType.isParameterizedTypeWithActualArguments())
271
						lhsType = this.expectedType;
272
				}
273
				receiverType = ((SingleTypeReference) this.type).resolveTypeEnclosing(scope, (ReferenceBinding) enclosingInstanceType, lhsType);
265
				if (receiverType != null && enclosingInstanceContainsCast) {
274
				if (receiverType != null && enclosingInstanceContainsCast) {
266
					CastExpression.checkNeedForEnclosingInstanceCast(scope, this.enclosingInstance, enclosingInstanceType, receiverType);
275
					CastExpression.checkNeedForEnclosingInstanceCast(scope, this.enclosingInstance, enclosingInstanceType, receiverType);
267
				}
276
				}
Lines 407-420 Link Here
407
				scope.problemReporter().missingTypeInConstructor(this, this.binding);
416
				scope.problemReporter().missingTypeInConstructor(this, this.binding);
408
			}
417
			}
409
			// The enclosing instance must be compatible with the innermost enclosing type
418
			// The enclosing instance must be compatible with the innermost enclosing type
410
			ReferenceBinding expectedType = this.binding.declaringClass.enclosingType();
419
			ReferenceBinding typeExpected = this.binding.declaringClass.enclosingType();
411
			if (expectedType != enclosingInstanceType) // must call before computeConversion() and typeMismatchError()
420
			if (typeExpected != enclosingInstanceType) // must call before computeConversion() and typeMismatchError()
412
				scope.compilationUnitScope().recordTypeConversion(expectedType, enclosingInstanceType);
421
				scope.compilationUnitScope().recordTypeConversion(typeExpected, enclosingInstanceType);
413
			if (enclosingInstanceType.isCompatibleWith(expectedType) || scope.isBoxingCompatibleWith(enclosingInstanceType, expectedType)) {
422
			if (enclosingInstanceType.isCompatibleWith(typeExpected) || scope.isBoxingCompatibleWith(enclosingInstanceType, typeExpected)) {
414
				this.enclosingInstance.computeConversion(scope, expectedType, enclosingInstanceType);
423
				this.enclosingInstance.computeConversion(scope, typeExpected, enclosingInstanceType);
415
				return this.resolvedType = receiverType;
424
				return this.resolvedType = receiverType;
416
			}
425
			}
417
			scope.problemReporter().typeMismatchError(enclosingInstanceType, expectedType, this.enclosingInstance, null);
426
			scope.problemReporter().typeMismatchError(enclosingInstanceType, typeExpected, this.enclosingInstance, null);
418
			return this.resolvedType = receiverType;
427
			return this.resolvedType = receiverType;
419
		}
428
		}
420
		ReferenceBinding superType = (ReferenceBinding) receiverType;
429
		ReferenceBinding superType = (ReferenceBinding) receiverType;
Lines 498-501 Link Here
498
		}
507
		}
499
		visitor.endVisit(this, scope);
508
		visitor.endVisit(this, scope);
500
	}
509
	}
510
	
511
	/**
512
	 * @see org.eclipse.jdt.internal.compiler.ast.Expression#setExpectedType(org.eclipse.jdt.internal.compiler.lookup.TypeBinding)
513
	 */
514
	public void setExpectedType(TypeBinding expectedType) {
515
		this.expectedType = expectedType;
516
		if (this.expectedType != null && this.enclosingInstance != null)
517
			this.enclosingInstance.setExpectedType(this.expectedType.enclosingType());
518
	}
501
}
519
}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/SingleTypeReference.java (-1 / +9 lines)
Lines 1-10 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
7
 *
8
 * This is an implementation of an early-draft specification developed under the Java
9
 * Community Process (JCP) and is made available for testing and evaluation purposes
10
 * only. The code is not compatible with any specification of the JCP.
11
 * 
8
 * Contributors:
12
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
13
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
14
 *******************************************************************************/
Lines 83-88 Link Here
83
		}
87
		}
84
		return this.resolvedType = memberType;
88
		return this.resolvedType = memberType;
85
	}
89
	}
90
	
91
	public TypeBinding resolveTypeEnclosing(BlockScope scope, ReferenceBinding enclosingInstanceType, TypeBinding expectedType) {
92
		return this.resolveTypeEnclosing(scope, enclosingInstanceType);
93
	}
86
94
87
	public void traverse(ASTVisitor visitor, BlockScope scope) {
95
	public void traverse(ASTVisitor visitor, BlockScope scope) {
88
		visitor.visit(this, scope);
96
		visitor.visit(this, scope);
(-)compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java (+4 lines)
Lines 208-213 Link Here
208
	return internalResolveType(scope);
208
	return internalResolveType(scope);
209
}
209
}
210
210
211
public TypeBinding resolveType(BlockScope scope, boolean checkBounds, TypeBinding expectedType) {
212
	return internalResolveType(scope);
213
}
214
211
public TypeBinding resolveType(ClassScope scope) {
215
public TypeBinding resolveType(ClassScope scope) {
212
	return internalResolveType(scope);
216
	return internalResolveType(scope);
213
}
217
}
(-)src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_7.java (-78 / +24 lines)
Lines 14-21 Link Here
14
 *******************************************************************************/
14
 *******************************************************************************/
15
package org.eclipse.jdt.core.tests.compiler.regression;
15
package org.eclipse.jdt.core.tests.compiler.regression;
16
16
17
import java.util.Map;
18
19
import junit.framework.Test;
17
import junit.framework.Test;
20
public class GenericsRegressionTest_1_7 extends AbstractRegressionTest {
18
public class GenericsRegressionTest_1_7 extends AbstractRegressionTest {
21
19
Lines 30-36 Link Here
30
public static Test suite() {
28
public static Test suite() {
31
	return buildMinimalComplianceTestSuite(testClass(), F_1_7);
29
	return buildMinimalComplianceTestSuite(testClass(), F_1_7);
32
}
30
}
33
public void _test001() {
31
public void test001() {
34
	this.runConformTest(
32
	this.runConformTest(
35
		new String[] {
33
		new String[] {
36
			"X.java",
34
			"X.java",
Lines 46-52 Link Here
46
		},
44
		},
47
		"SUCCESS");
45
		"SUCCESS");
48
}
46
}
49
public void _test001a() {
47
public void test001a() {
50
	this.runNegativeTest(
48
	this.runNegativeTest(
51
		new String[] {
49
		new String[] {
52
			"X.java",
50
			"X.java",
Lines 67-73 Link Here
67
		"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" + 
68
		"----------\n");
66
		"----------\n");
69
}
67
}
70
public void _test001b() {
68
public void test001b() {
71
	this.runConformTest(
69
	this.runConformTest(
72
		new String[] {
70
		new String[] {
73
			"X.java",
71
			"X.java",
Lines 82-88 Link Here
82
		"SUCCESS");
80
		"SUCCESS");
83
}
81
}
84
// fields
82
// fields
85
public void _test001b_1() {
83
public void test001b_1() {
86
	this.runConformTest(
84
	this.runConformTest(
87
		new String[] {
85
		new String[] {
88
			"X.java",
86
			"X.java",
Lines 96-102 Link Here
96
		},
94
		},
97
		"SUCCESS");
95
		"SUCCESS");
98
}
96
}
99
public void _test001c() {
97
public void test001c() {
100
	this.runNegativeTest(
98
	this.runNegativeTest(
101
		new String[] {
99
		new String[] {
102
			"X.java",
100
			"X.java",
Lines 116-122 Link Here
116
		"----------\n");
114
		"----------\n");
117
}
115
}
118
// fields
116
// fields
119
public void _test001c_1() {
117
public void test001c_1() {
120
	this.runNegativeTest(
118
	this.runNegativeTest(
121
		new String[] {
119
		new String[] {
122
			"X.java",
120
			"X.java",
Lines 174-180 Link Here
174
		"The method ab(ArrayList<String>) in the type X<String> is not applicable for the arguments (ArrayList<Integer>)\n" + 
172
		"The method ab(ArrayList<String>) in the type X<String> is not applicable for the arguments (ArrayList<Integer>)\n" + 
175
		"----------\n");
173
		"----------\n");
176
}
174
}
177
public void _test001f() {
175
public void test001f() {
178
	this.runConformTest(
176
	this.runConformTest(
179
		new String[] {
177
		new String[] {
180
			"X.java",
178
			"X.java",
Lines 193-199 Link Here
193
		"SUCCESS");
191
		"SUCCESS");
194
}
192
}
195
// fields
193
// fields
196
public void _test001f_1() {
194
public void test001f_1() {
197
	this.runConformTest(
195
	this.runConformTest(
198
		new String[] {
196
		new String[] {
199
			"X.java",
197
			"X.java",
Lines 213-219 Link Here
213
		},
211
		},
214
		"SUCCESS");
212
		"SUCCESS");
215
}
213
}
216
public void _test001g() {
214
public void test001g() {
217
	this.runConformTest(
215
	this.runConformTest(
218
		new String[] {
216
		new String[] {
219
			"X.java",
217
			"X.java",
Lines 232-238 Link Here
232
		},
230
		},
233
		"SUCCESS\n1");
231
		"SUCCESS\n1");
234
}
232
}
235
public void _test001g_1() {
233
public void test001g_1() {
236
	this.runConformTest(
234
	this.runConformTest(
237
		new String[] {
235
		new String[] {
238
			"X.java",
236
			"X.java",
Lines 253-259 Link Here
253
		},
251
		},
254
		"SUCCESS\n1");
252
		"SUCCESS\n1");
255
}
253
}
256
public void _test001h() {
254
public void test001h() {
257
	this.runNegativeTest(
255
	this.runNegativeTest(
258
		new String[] {
256
		new String[] {
259
			"X.java",
257
			"X.java",
Lines 281-287 Link Here
281
		"The method methodx(String) in the type X<String>.X2<String> is not applicable for the arguments (int)\n" + 
279
		"The method methodx(String) in the type X<String>.X2<String> is not applicable for the arguments (int)\n" + 
282
		"----------\n");
280
		"----------\n");
283
}
281
}
284
public void _test001h_1() {
282
public void test001h_1() {
285
	this.runNegativeTest(
283
	this.runNegativeTest(
286
		new String[] {
284
		new String[] {
287
			"X.java",
285
			"X.java",
Lines 326-332 Link Here
326
		"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" + 
324
		"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" + 
327
		"----------\n");
325
		"----------\n");
328
}
326
}
329
public void _test001i() {
327
public void test001i() {
330
	this.runConformTest(
328
	this.runConformTest(
331
		new String[] {
329
		new String[] {
332
			"X.java",
330
			"X.java",
Lines 347-353 Link Here
347
		},
345
		},
348
		"SUCCESS");
346
		"SUCCESS");
349
}
347
}
350
public void _test002() {
348
public void test002() {
351
	this.runNegativeTest(
349
	this.runNegativeTest(
352
		new String[] {
350
		new String[] {
353
			"X.java",
351
			"X.java",
Lines 389-395 Link Here
389
		"SUCCESS");
387
		"SUCCESS");
390
}
388
}
391
389
392
public void _test004b() {
390
public void test004b() {
393
	this.runNegativeTest(
391
	this.runNegativeTest(
394
		new String[] {
392
		new String[] {
395
			"X.java",
393
			"X.java",
Lines 408-417 Link Here
408
		"1. ERROR in X.java (at line 5)\n" + 
406
		"1. ERROR in X.java (at line 5)\n" + 
409
		"	new X<>().new X2<>(){\n" + 
407
		"	new X<>().new X2<>(){\n" + 
410
		"	              ^^\n" + 
408
		"	              ^^\n" + 
411
		"Empty type argument list cannot be used in anonymous class declaration\n" + 
409
		"Incorrect number of arguments for type X<>.X2; it cannot be parameterized with arguments <>\n" + 
412
		"----------\n");
410
		"----------\n");
413
}
411
}
414
public void _test004c() {
412
public void test004c() {
415
	this.runConformTest(
413
	this.runConformTest(
416
		new String[] {
414
		new String[] {
417
			"X.java",
415
			"X.java",
Lines 434-440 Link Here
434
		"1");
432
		"1");
435
}
433
}
436
434
437
public void _test006() {
435
public void test006() {
438
	this.runConformTest(
436
	this.runConformTest(
439
		new String[] {
437
		new String[] {
440
			"X.java",
438
			"X.java",
Lines 530-588 Link Here
530
		"2");
528
		"2");
531
}
529
}
532
530
533
// To be activated if we introduce a warning to be raised when <> can be used but is not used.
531
public void test0014() {
534
public void _test012() {
535
	Map options = getCompilerOptions();
536
	//options.put(CompilerOptions.OPTION_ReportRedundantDeclarationOfTypeArguments, CompilerOptions.ERROR);
537
	this.runNegativeTest(
538
		new String[] {
539
			"X.java",
540
			"public class X<T> {\n" +
541
			"	X<String> f1 = new X<String>();\n" +
542
			"	public void foo() {\n" +
543
			"		X<Integer> i1 = new X<Integer>();\n" +
544
			"	}\n" +
545
			"}",
546
		},
547
		"----------\n" + 
548
		"1. ERROR in X.java (at line 2)\n" + 
549
		"	X<String> f1 = new X<String>();\n" + 
550
		"	               ^^^^^^^^^^^^^^^\n" + 
551
		"Redundant declaration of type arguments <String>\n" + 
552
		"----------\n" + 
553
		"2. ERROR in X.java (at line 4)\n" + 
554
		"	X<Integer> i1 = new X<Integer>();\n" + 
555
		"	                ^^^^^^^^^^^^^^^^\n" + 
556
		"Redundant declaration of type arguments <Integer>\n" + 
557
		"----------\n",
558
		null,
559
		true,
560
		options);
561
}
562
// To be activated if we introduce a warning to be raised when <> can be used but is not used.
563
public void _test013a() {
564
	Map options = getCompilerOptions();
565
	//options.put(CompilerOptions.OPTION_ReportRedundantDeclarationOfTypeArguments, CompilerOptions.ERROR);
566
	this.runConformTest(
567
		new String[] {
568
			"X.java",
569
			"public class X<T> {\n" +
570
			"	class Y<U>{}\n" +
571
			"	Y<String> f1 = new Y();\n" +
572
			"	public static void main(String[] args) {\n" +
573
			"		X<Integer> i1 = new X<>();\n" +
574
			"		System.out.println(\"SUCCESS\");\n" +
575
			"	}\n" +
576
			"}",
577
		},
578
		"SUCCESS",
579
		null,
580
		true,
581
		null,
582
		options,
583
		null);
584
}
585
public void _test0014() {
586
	this.runConformTest(
532
	this.runConformTest(
587
		new String[] {
533
		new String[] {
588
			"X.java",
534
			"X.java",
Lines 600-606 Link Here
600
		"SUCCESS\n" +
546
		"SUCCESS\n" +
601
		"123");
547
		"123");
602
}
548
}
603
public void _test0014a() {
549
public void test0014a() {
604
	this.runNegativeTest(
550
	this.runNegativeTest(
605
		new String[] {
551
		new String[] {
606
			"X.java",
552
			"X.java",
Lines 622-628 Link Here
622
		"The method testFunction(String, Integer) in the type X<String,Integer> is not applicable for the arguments (int, String)\n" + 
568
		"The method testFunction(String, Integer) in the type X<String,Integer> is not applicable for the arguments (int, String)\n" + 
623
		"----------\n");
569
		"----------\n");
624
}
570
}
625
public void _test0015() {
571
public void test0015() {
626
	this.runConformTest(
572
	this.runConformTest(
627
		new String[] {
573
		new String[] {
628
			"X.java",
574
			"X.java",
Lines 643-649 Link Here
643
}
589
}
644
// To verify that a parameterized invocation of a generic constructor works even if <> is used
590
// To verify that a parameterized invocation of a generic constructor works even if <> is used
645
// to elide class type parameters.
591
// to elide class type parameters.
646
public void _test0016() {
592
public void test0016() {
647
	this.runConformTest(
593
	this.runConformTest(
648
		new String[] {
594
		new String[] {
649
			"X.java",
595
			"X.java",
Lines 664-670 Link Here
664
}
610
}
665
// To verify that a parameterized invocation of a generic constructor works even if <> is used
611
// To verify that a parameterized invocation of a generic constructor works even if <> is used
666
// to elide class type parameters. This test handles fields
612
// to elide class type parameters. This test handles fields
667
public void _test0016b() {
613
public void test0016b() {
668
	this.runConformTest(
614
	this.runConformTest(
669
		new String[] {
615
		new String[] {
670
			"X.java",
616
			"X.java",
Lines 689-695 Link Here
689
// To verify that a parameterized invocation of a non-generic constructor works even if <> is used
635
// To verify that a parameterized invocation of a non-generic constructor works even if <> is used
690
// to elide class type parameters.
636
// to elide class type parameters.
691
// This was not allowed in java 1.6 and 1.5 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=168230)
637
// This was not allowed in java 1.6 and 1.5 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=168230)
692
public void _test0017() {
638
public void test0017() {
693
	this.runConformTest(
639
	this.runConformTest(
694
		new String[] {
640
		new String[] {
695
			"X.java",
641
			"X.java",

Return to bug 339478