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

(-)compiler/org/eclipse/jdt/internal/compiler/ast/NameReference.java (-4 lines)
Lines 64-72 Link Here
64
	// ignored
64
	// ignored
65
}
65
}
66
66
67
public void setUnchecked(boolean isUnchecked) {
68
	// ignored
69
}
70
71
public abstract String unboundReferenceErrorName();
67
public abstract String unboundReferenceErrorName();
72
}
68
}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java (-4 lines)
Lines 611-620 Link Here
611
	// ignored
611
	// ignored
612
}
612
}
613
613
614
public void setUnchecked(boolean isUnchecked) {
615
	// ignored
616
}
617
618
public void traverse(ASTVisitor visitor, BlockScope scope) {
614
public void traverse(ASTVisitor visitor, BlockScope scope) {
619
	if (visitor.visit(this, scope)) {
615
	if (visitor.visit(this, scope)) {
620
		this.receiver.traverse(visitor, scope);
616
		this.receiver.traverse(visitor, scope);
(-)compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java (-3 / +7 lines)
Lines 372-378 Link Here
372
				if (isMethodUseDeprecated(this.binding, scope, true)) {
372
				if (isMethodUseDeprecated(this.binding, scope, true)) {
373
					scope.problemReporter().deprecatedMethod(this.binding, this);
373
					scope.problemReporter().deprecatedMethod(this.binding, this);
374
				}
374
				}
375
				checkInvocationArguments(scope, null, allocationType, this.binding, this.arguments, argumentTypes, argsContainCast, this, (this.bits & ASTNode.Unchecked) != 0);
375
				if (checkInvocationArguments(scope, null, allocationType, this.binding, this.arguments, argumentTypes, argsContainCast, this)) {
376
					this.bits |= ASTNode.Unchecked;
377
				}
376
				if (this.typeArguments != null && this.binding.original().typeVariables == Binding.NO_TYPE_VARIABLES) {
378
				if (this.typeArguments != null && this.binding.original().typeVariables == Binding.NO_TYPE_VARIABLES) {
377
					scope.problemReporter().unnecessaryTypeArgumentsForMethodInvocation(this.binding, this.genericTypeArguments, this.typeArguments);
379
					scope.problemReporter().unnecessaryTypeArgumentsForMethodInvocation(this.binding, this.genericTypeArguments, this.typeArguments);
378
				}
380
				}
Lines 449-461 Link Here
449
			this.enclosingInstance.computeConversion(scope, targetEnclosing, enclosingInstanceType);
451
			this.enclosingInstance.computeConversion(scope, targetEnclosing, enclosingInstanceType);
450
		}
452
		}
451
		if (this.arguments != null) {
453
		if (this.arguments != null) {
452
			checkInvocationArguments(scope, null, anonymousSuperclass, inheritedBinding, this.arguments, argumentTypes, argsContainCast, this, (this.bits & ASTNode.Unchecked) != 0);
454
			if (checkInvocationArguments(scope, null, anonymousSuperclass, inheritedBinding, this.arguments, argumentTypes, argsContainCast, this)) {
455
				this.bits |= ASTNode.Unchecked;
456
			}
453
		}
457
		}
454
		if (this.typeArguments != null && inheritedBinding.original().typeVariables == Binding.NO_TYPE_VARIABLES) {
458
		if (this.typeArguments != null && inheritedBinding.original().typeVariables == Binding.NO_TYPE_VARIABLES) {
455
			scope.problemReporter().unnecessaryTypeArgumentsForMethodInvocation(inheritedBinding, this.genericTypeArguments, this.typeArguments);
459
			scope.problemReporter().unnecessaryTypeArgumentsForMethodInvocation(inheritedBinding, this.genericTypeArguments, this.typeArguments);
456
		}
460
		}
457
		// Update the anonymous inner class : superclass, interface
461
		// Update the anonymous inner class : superclass, interface
458
		this.binding = this.anonymousType.createDefaultConstructorWithBinding(inheritedBinding, 	(this.bits & ASTNode.Unchecked) != 0 && genericTypeArguments == null);
462
		this.binding = this.anonymousType.createDefaultConstructorWithBinding(inheritedBinding, 	(this.bits & ASTNode.Unchecked) != 0 && this.genericTypeArguments == null);
459
		return this.resolvedType;
463
		return this.resolvedType;
460
	}
464
	}
461
465
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java (-3 / +5 lines)
Lines 251-257 Link Here
251
		}
251
		}
252
		return INVOCATION_ARGUMENT_OK;
252
		return INVOCATION_ARGUMENT_OK;
253
	}
253
	}
254
	public static void checkInvocationArguments(BlockScope scope, Expression receiver, TypeBinding receiverType, MethodBinding method, Expression[] arguments, TypeBinding[] argumentTypes, boolean argsContainCast, InvocationSite invocationSite, boolean uncheckedBoundCheck) {
254
	public static boolean checkInvocationArguments(BlockScope scope, Expression receiver, TypeBinding receiverType, MethodBinding method, Expression[] arguments, TypeBinding[] argumentTypes, boolean argsContainCast, InvocationSite invocationSite) {
255
		TypeBinding[] params = method.parameters;
255
		TypeBinding[] params = method.parameters;
256
		int paramLength = params.length;
256
		int paramLength = params.length;
257
		boolean isRawMemberInvocation = !method.isStatic()
257
		boolean isRawMemberInvocation = !method.isStatic()
Lines 259-264 Link Here
259
				&& method.declaringClass.isRawType()
259
				&& method.declaringClass.isRawType()
260
				&& method.hasSubstitutedParameters();
260
				&& method.hasSubstitutedParameters();
261
261
262
		boolean uncheckedBoundCheck = (method.tagBits & TagBits.HasUncheckedTypeArgumentForBoundCheck) != 0;
262
		MethodBinding rawOriginalGenericMethod = null;
263
		MethodBinding rawOriginalGenericMethod = null;
263
		if (!isRawMemberInvocation) {
264
		if (!isRawMemberInvocation) {
264
			if (method instanceof ParameterizedGenericMethodBinding) {
265
			if (method instanceof ParameterizedGenericMethodBinding) {
Lines 342-350 Link Here
342
				|| ((invocationStatus & INVOCATION_ARGUMENT_UNCHECKED) != 0 
343
				|| ((invocationStatus & INVOCATION_ARGUMENT_UNCHECKED) != 0 
343
						&& method instanceof ParameterizedGenericMethodBinding
344
						&& method instanceof ParameterizedGenericMethodBinding
344
						/*&& method.returnType != scope.environment().convertToRawType(method.returnType.erasure(), true)*/)) {
345
						/*&& method.returnType != scope.environment().convertToRawType(method.returnType.erasure(), true)*/)) {
345
			invocationSite.setUnchecked(true);
346
			scope.problemReporter().unsafeRawGenericMethodInvocation((ASTNode)invocationSite, method, argumentTypes);
346
		    scope.problemReporter().unsafeRawGenericMethodInvocation((ASTNode)invocationSite, method, argumentTypes);
347
			return true;
347
		}
348
		}
349
		return false;
348
	}
350
	}
349
	public ASTNode concreteStatement() {
351
	public ASTNode concreteStatement() {
350
		return this;
352
		return this;
(-)compiler/org/eclipse/jdt/internal/compiler/ast/AbstractVariableDeclaration.java (-5 lines)
Lines 128-136 Link Here
128
	public void setFieldIndex(int depth) {
128
	public void setFieldIndex(int depth) {
129
		// do nothing by default
129
		// do nothing by default
130
	}
130
	}
131
	
132
	public void setUnchecked(boolean isUnchecked) {
133
		// ignored
134
	}
135
	
136
}
131
}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java (-1 lines)
Lines 256-262 Link Here
256
			public void setActualReceiverType(ReferenceBinding actualReceiverType) { /* ignore */}
256
			public void setActualReceiverType(ReferenceBinding actualReceiverType) { /* ignore */}
257
			public void setDepth(int depth) { /* ignore */}
257
			public void setDepth(int depth) { /* ignore */}
258
			public void setFieldIndex(int depth){ /* ignore */}
258
			public void setFieldIndex(int depth){ /* ignore */}
259
			public void setUnchecked(boolean isUnchecked) {/* ignore */}
260
			public int sourceStart() { return 0; }
259
			public int sourceStart() { return 0; }
261
			public int sourceEnd() { return 0; }
260
			public int sourceEnd() { return 0; }
262
		};
261
		};
(-)compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java (-10 / +3 lines)
Lines 356-362 Link Here
356
	}
356
	}
357
	if (isMethodUseDeprecated(this.binding, scope, true))
357
	if (isMethodUseDeprecated(this.binding, scope, true))
358
		scope.problemReporter().deprecatedMethod(this.binding, this);
358
		scope.problemReporter().deprecatedMethod(this.binding, this);
359
	checkInvocationArguments(scope, null, allocationType, this.binding, this.arguments, argumentTypes, argsContainCast, this, (this.bits & ASTNode.Unchecked) != 0);
359
	if (checkInvocationArguments(scope, null, allocationType, this.binding, this.arguments, argumentTypes, argsContainCast, this)) {
360
		this.bits |= ASTNode.Unchecked;
361
	}
360
	if (this.typeArguments != null && this.binding.original().typeVariables == Binding.NO_TYPE_VARIABLES) {
362
	if (this.typeArguments != null && this.binding.original().typeVariables == Binding.NO_TYPE_VARIABLES) {
361
		scope.problemReporter().unnecessaryTypeArgumentsForMethodInvocation(this.binding, this.genericTypeArguments, this.typeArguments);
363
		scope.problemReporter().unnecessaryTypeArgumentsForMethodInvocation(this.binding, this.genericTypeArguments, this.typeArguments);
362
	}
364
	}
Lines 375-389 Link Here
375
	// ignored
377
	// ignored
376
}
378
}
377
379
378
public void setUnchecked(boolean isUnchecked) {
379
	if (isUnchecked) {
380
		this.bits |= ASTNode.Unchecked;
381
	} else {
382
		this.bits &= ~ASTNode.Unchecked;
383
	}
384
	
385
}
386
387
public void traverse(ASTVisitor visitor, BlockScope scope) {
380
public void traverse(ASTVisitor visitor, BlockScope scope) {
388
	if (visitor.visit(this, scope)) {
381
	if (visitor.visit(this, scope)) {
389
		if (this.typeArguments != null) {
382
		if (this.typeArguments != null) {
(-)compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java (-9 / +3 lines)
Lines 467-473 Link Here
467
			scope.problemReporter().indirectAccessToStaticMethod(this, this.binding);
467
			scope.problemReporter().indirectAccessToStaticMethod(this, this.binding);
468
		}
468
		}
469
	}
469
	}
470
	checkInvocationArguments(scope, this.receiver, this.actualReceiverType, this.binding, this.arguments, argumentTypes, argsContainCast, this, (this.bits & ASTNode.Unchecked) != 0);
470
	if (checkInvocationArguments(scope, this.receiver, this.actualReceiverType, this.binding, this.arguments, argumentTypes, argsContainCast, this)) {
471
		this.bits |= ASTNode.Unchecked;
472
	}
471
473
472
	//-------message send that are known to fail at compile time-----------
474
	//-------message send that are known to fail at compile time-----------
473
	if (this.binding.isAbstract()) {
475
	if (this.binding.isAbstract()) {
Lines 538-551 Link Here
538
	// ignore for here
540
	// ignore for here
539
}
541
}
540
542
541
public void setUnchecked(boolean isUnchecked) {
542
	if (isUnchecked) {
543
		this.bits |= ASTNode.Unchecked;
544
	} else {
545
		this.bits &= ~ASTNode.Unchecked;
546
	}
547
}
548
549
public void traverse(ASTVisitor visitor, BlockScope blockScope) {
543
public void traverse(ASTVisitor visitor, BlockScope blockScope) {
550
	if (visitor.visit(this, blockScope)) {
544
	if (visitor.visit(this, blockScope)) {
551
		this.receiver.traverse(visitor, blockScope);
545
		this.receiver.traverse(visitor, blockScope);
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java (-10 / +3 lines)
Lines 400-406 Link Here
400
				if (isMethodUseDeprecated(this.binding, scope, this.accessMode != ExplicitConstructorCall.ImplicitSuper)) {
400
				if (isMethodUseDeprecated(this.binding, scope, this.accessMode != ExplicitConstructorCall.ImplicitSuper)) {
401
					scope.problemReporter().deprecatedMethod(this.binding, this);
401
					scope.problemReporter().deprecatedMethod(this.binding, this);
402
				}
402
				}
403
				checkInvocationArguments(scope, null, receiverType, this.binding, this.arguments, argumentTypes, argsContainCast, this, (this.bits & ASTNode.Unchecked) != 0);
403
				if (checkInvocationArguments(scope, null, receiverType, this.binding, this.arguments, argumentTypes, argsContainCast, this)) {
404
					this.bits |= ASTNode.Unchecked;
405
				}
404
				if (this.binding.isPrivate() || receiverType.isLocalType()) {
406
				if (this.binding.isPrivate() || receiverType.isLocalType()) {
405
					this.binding.original().modifiers |= ExtraCompilerModifiers.AccLocallyUsed;
407
					this.binding.original().modifiers |= ExtraCompilerModifiers.AccLocallyUsed;
406
				}
408
				}
Lines 432-446 Link Here
432
	public void setFieldIndex(int depth) {
434
	public void setFieldIndex(int depth) {
433
		// ignore for here
435
		// ignore for here
434
	}
436
	}
435
436
	public void setUnchecked(boolean isUnchecked) {
437
		if (isUnchecked) {
438
			this.bits |= ASTNode.Unchecked;
439
		} else {
440
			this.bits &= ~ASTNode.Unchecked;
441
		}
442
		
443
	}
444
	
437
	
445
	public void traverse(ASTVisitor visitor, BlockScope scope) {
438
	public void traverse(ASTVisitor visitor, BlockScope scope) {
446
		if (visitor.visit(this, scope)) {
439
		if (visitor.visit(this, scope)) {
(-)eval/org/eclipse/jdt/internal/eval/CodeSnippetSuperReference.java (-5 lines)
Lines 54-63 Link Here
54
public void setFieldIndex(int index){
54
public void setFieldIndex(int index){
55
	// ignored
55
	// ignored
56
}
56
}
57
58
public void setUnchecked(boolean isUnchecked) {
59
	// ignored
60
}
61
62
}
57
}
63
58
(-)eval/org/eclipse/jdt/internal/eval/CodeSnippetReturnStatement.java (-4 lines)
Lines 141-148 Link Here
141
public void setFieldIndex(int depth) {
141
public void setFieldIndex(int depth) {
142
	// ignored
142
	// ignored
143
}
143
}
144
145
public void setUnchecked(boolean isUnchecked) {
146
	// ignored
147
}
148
}
144
}
(-)eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java (-1 / +3 lines)
Lines 312-318 Link Here
312
			}			
312
			}			
313
		}
313
		}
314
	}
314
	}
315
	checkInvocationArguments(scope, this.receiver, this.actualReceiverType, this.binding, this.arguments, argumentTypes, argsContainCast, this, (this.bits & ASTNode.Unchecked) != 0);
315
	if (checkInvocationArguments(scope, this.receiver, this.actualReceiverType, this.binding, this.arguments, argumentTypes, argsContainCast, this)) {
316
		this.bits |= ASTNode.Unchecked;
317
	}
316
318
317
	//-------message send that are known to fail at compile time-----------
319
	//-------message send that are known to fail at compile time-----------
318
	if (this.binding.isAbstract()) {
320
	if (this.binding.isAbstract()) {
(-)eval/org/eclipse/jdt/internal/eval/CodeSnippetThisReference.java (-4 lines)
Lines 123-130 Link Here
123
	public void setFieldIndex(int index){
123
	public void setFieldIndex(int index){
124
		// ignored
124
		// ignored
125
	}
125
	}
126
	
127
	public void setUnchecked(boolean isUnchecked) {
128
		// ignored
129
	}	
130
}
126
}
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/InvocationSite.java (-6 lines)
Lines 22-33 Link Here
22
	void setActualReceiverType(ReferenceBinding receiverType);
22
	void setActualReceiverType(ReferenceBinding receiverType);
23
	void setDepth(int depth);
23
	void setDepth(int depth);
24
	void setFieldIndex(int depth);
24
	void setFieldIndex(int depth);
25
	/**
26
	 * Positioned when a method/constructor invocation is detected having required unchecked conversion
27
	 * for becoming applicable.
28
	 * @param isUnchecked
29
	 */
30
	void setUnchecked(boolean isUnchecked);
31
	int sourceEnd();
25
	int sourceEnd();
32
	int sourceStart();
26
	int sourceStart();
33
}
27
}
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java (-1 / +1 lines)
Lines 97-103 Link Here
97
			        return new ProblemMethodBinding(methodSubstitute, originalMethod.selector, augmentedArguments, ProblemReasons.ParameterBoundMismatch);
97
			        return new ProblemMethodBinding(methodSubstitute, originalMethod.selector, augmentedArguments, ProblemReasons.ParameterBoundMismatch);
98
				case TypeConstants.UNCHECKED :
98
				case TypeConstants.UNCHECKED :
99
					// tolerate unchecked bounds
99
					// tolerate unchecked bounds
100
					invocationSite.setUnchecked(true);
100
					methodSubstitute.tagBits |= TagBits.HasUncheckedTypeArgumentForBoundCheck;
101
					break;
101
					break;
102
			}
102
			}
103
		}
103
		}
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/TagBits.java (+3 lines)
Lines 29-34 Link Here
29
	// set for all bindings either represeting a missing type (type), or directly referencing a missing type (field/method/variable)
29
	// set for all bindings either represeting a missing type (type), or directly referencing a missing type (field/method/variable)
30
	long HasMissingType = ASTNode.Bit8;
30
	long HasMissingType = ASTNode.Bit8;
31
31
32
	// for method
33
	long HasUncheckedTypeArgumentForBoundCheck = ASTNode.Bit9;
34
	
32
	// for the type cycle hierarchy check used by ClassScope
35
	// for the type cycle hierarchy check used by ClassScope
33
	long BeginHierarchyCheck = ASTNode.Bit9;  // type
36
	long BeginHierarchyCheck = ASTNode.Bit9;  // type
34
	long EndHierarchyCheck = ASTNode.Bit10; // type
37
	long EndHierarchyCheck = ASTNode.Bit10; // type
(-)codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java (-1 lines)
Lines 594-600 Link Here
594
		public void setActualReceiverType(ReferenceBinding receiverType) {/* empty */}
594
		public void setActualReceiverType(ReferenceBinding receiverType) {/* empty */}
595
		public void setDepth(int depth){/* empty */}
595
		public void setDepth(int depth){/* empty */}
596
		public void setFieldIndex(int depth){/* empty */}
596
		public void setFieldIndex(int depth){/* empty */}
597
		public void setUnchecked(boolean isUnchecked) {/* empty */}
598
		public int sourceEnd() { return 0; 	}
597
		public int sourceEnd() { return 0; 	}
599
		public int sourceStart() { return 0; 	}
598
		public int sourceStart() { return 0; 	}
600
	};
599
	};
(-)src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java (+52 lines)
Lines 49210-49216 Link Here
49210
             "CAUGHT"
49210
             "CAUGHT"
49211
     );
49211
     );
49212
}
49212
}
49213
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=263633
49213
public void test1447() {
49214
public void test1447() {
49215
    this.runConformTest(
49216
            new String[] {
49217
                    "X.java",
49218
        			"public abstract class X implements Visitable {\n" + 
49219
        			"	public <T, U extends Visitor<T>> T accept(U v) {\n" + 
49220
        			"		return null;\n" + 
49221
        			"	}\n" + 
49222
        			"	public <T, U extends Visitor<T>> T accept2(U v) {\n" + 
49223
        			"		if (v == null)\n" + 
49224
        			"			return this.accept(v);\n" + 
49225
        			"		else \n" + 
49226
        			"			return this.<T, U> accept(v);\n" + 
49227
        			"	}\n" + 
49228
        			"}\n" + 
49229
        			"interface Visitable {\n" + 
49230
        			"	<T, U extends Visitor<T>> T accept(U v);\n" + 
49231
        			"}\n" + 
49232
        			"interface Visitor<T> {\n" + 
49233
        			"}\n",
49234
       		},
49235
            ""
49236
    );
49237
}
49238
49239
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=263633 - variation
49240
public void test1448() {
49241
    this.runConformTest(
49242
            new String[] {
49243
                    "X.java",
49244
        			"public abstract class X implements Visitable {\n" + 
49245
        			"	public <T, U extends Visitor> T accept(U v) {\n" + 
49246
        			"		return null;\n" + 
49247
        			"	}\n" + 
49248
        			"	public <T, U extends Visitor> T accept2(U v) {\n" + 
49249
        			"		if (v == null)\n" + 
49250
        			"			return this.accept(v);\n" + 
49251
        			"		else \n" + 
49252
        			"			return this.<T, U> accept(v);\n" + 
49253
        			"	}\n" + 
49254
        			"}\n" + 
49255
        			"interface Visitable {\n" + 
49256
        			"	<T, U extends Visitor> T accept(U v);\n" + 
49257
        			"}\n" + 
49258
        			"interface Visitor{\n" + 
49259
        			"}\n",
49260
       		},
49261
            ""
49262
    );
49263
}
49264
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=263633 - variation
49265
public void test1449() {
49214
     this.runConformTest(
49266
     this.runConformTest(
49215
             new String[] {
49267
             new String[] {
49216
                     "X.java",
49268
                     "X.java",

Return to bug 263633