### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/ast/NameReference.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/NameReference.java,v retrieving revision 1.21 diff -u -r1.21 NameReference.java --- compiler/org/eclipse/jdt/internal/compiler/ast/NameReference.java 8 Jan 2009 20:51:05 -0000 1.21 +++ compiler/org/eclipse/jdt/internal/compiler/ast/NameReference.java 4 Feb 2009 17:51:51 -0000 @@ -64,9 +64,5 @@ // ignored } -public void setUnchecked(boolean isUnchecked) { - // ignored -} - public abstract String unboundReferenceErrorName(); } Index: compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java,v retrieving revision 1.126 diff -u -r1.126 FieldReference.java --- compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java 29 Jan 2009 17:00:08 -0000 1.126 +++ compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java 4 Feb 2009 17:51:50 -0000 @@ -611,10 +611,6 @@ // ignored } -public void setUnchecked(boolean isUnchecked) { - // ignored -} - public void traverse(ASTVisitor visitor, BlockScope scope) { if (visitor.visit(this, scope)) { this.receiver.traverse(visitor, scope); Index: compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java,v retrieving revision 1.93 diff -u -r1.93 QualifiedAllocationExpression.java --- compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java 3 Feb 2009 09:40:45 -0000 1.93 +++ compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java 4 Feb 2009 17:51:51 -0000 @@ -372,7 +372,9 @@ if (isMethodUseDeprecated(this.binding, scope, true)) { scope.problemReporter().deprecatedMethod(this.binding, this); } - checkInvocationArguments(scope, null, allocationType, this.binding, this.arguments, argumentTypes, argsContainCast, this, (this.bits & ASTNode.Unchecked) != 0); + if (checkInvocationArguments(scope, null, allocationType, this.binding, this.arguments, argumentTypes, argsContainCast, this)) { + this.bits |= ASTNode.Unchecked; + } if (this.typeArguments != null && this.binding.original().typeVariables == Binding.NO_TYPE_VARIABLES) { scope.problemReporter().unnecessaryTypeArgumentsForMethodInvocation(this.binding, this.genericTypeArguments, this.typeArguments); } @@ -449,13 +451,15 @@ this.enclosingInstance.computeConversion(scope, targetEnclosing, enclosingInstanceType); } if (this.arguments != null) { - checkInvocationArguments(scope, null, anonymousSuperclass, inheritedBinding, this.arguments, argumentTypes, argsContainCast, this, (this.bits & ASTNode.Unchecked) != 0); + if (checkInvocationArguments(scope, null, anonymousSuperclass, inheritedBinding, this.arguments, argumentTypes, argsContainCast, this)) { + this.bits |= ASTNode.Unchecked; + } } if (this.typeArguments != null && inheritedBinding.original().typeVariables == Binding.NO_TYPE_VARIABLES) { scope.problemReporter().unnecessaryTypeArgumentsForMethodInvocation(inheritedBinding, this.genericTypeArguments, this.typeArguments); } // Update the anonymous inner class : superclass, interface - this.binding = this.anonymousType.createDefaultConstructorWithBinding(inheritedBinding, (this.bits & ASTNode.Unchecked) != 0 && genericTypeArguments == null); + this.binding = this.anonymousType.createDefaultConstructorWithBinding(inheritedBinding, (this.bits & ASTNode.Unchecked) != 0 && this.genericTypeArguments == null); return this.resolvedType; } Index: compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java,v retrieving revision 1.97 diff -u -r1.97 ASTNode.java --- compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java 8 Jan 2009 20:51:05 -0000 1.97 +++ compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java 4 Feb 2009 17:51:49 -0000 @@ -251,7 +251,7 @@ } return INVOCATION_ARGUMENT_OK; } - public static void checkInvocationArguments(BlockScope scope, Expression receiver, TypeBinding receiverType, MethodBinding method, Expression[] arguments, TypeBinding[] argumentTypes, boolean argsContainCast, InvocationSite invocationSite, boolean uncheckedBoundCheck) { + public static boolean checkInvocationArguments(BlockScope scope, Expression receiver, TypeBinding receiverType, MethodBinding method, Expression[] arguments, TypeBinding[] argumentTypes, boolean argsContainCast, InvocationSite invocationSite) { TypeBinding[] params = method.parameters; int paramLength = params.length; boolean isRawMemberInvocation = !method.isStatic() @@ -259,6 +259,7 @@ && method.declaringClass.isRawType() && method.hasSubstitutedParameters(); + boolean uncheckedBoundCheck = (method.tagBits & TagBits.HasUncheckedTypeArgumentForBoundCheck) != 0; MethodBinding rawOriginalGenericMethod = null; if (!isRawMemberInvocation) { if (method instanceof ParameterizedGenericMethodBinding) { @@ -342,9 +343,10 @@ || ((invocationStatus & INVOCATION_ARGUMENT_UNCHECKED) != 0 && method instanceof ParameterizedGenericMethodBinding /*&& method.returnType != scope.environment().convertToRawType(method.returnType.erasure(), true)*/)) { - invocationSite.setUnchecked(true); - scope.problemReporter().unsafeRawGenericMethodInvocation((ASTNode)invocationSite, method, argumentTypes); + scope.problemReporter().unsafeRawGenericMethodInvocation((ASTNode)invocationSite, method, argumentTypes); + return true; } + return false; } public ASTNode concreteStatement() { return this; Index: compiler/org/eclipse/jdt/internal/compiler/ast/AbstractVariableDeclaration.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractVariableDeclaration.java,v retrieving revision 1.34 diff -u -r1.34 AbstractVariableDeclaration.java --- compiler/org/eclipse/jdt/internal/compiler/ast/AbstractVariableDeclaration.java 8 Jan 2009 20:51:05 -0000 1.34 +++ compiler/org/eclipse/jdt/internal/compiler/ast/AbstractVariableDeclaration.java 4 Feb 2009 17:51:49 -0000 @@ -128,9 +128,4 @@ public void setFieldIndex(int depth) { // do nothing by default } - - public void setUnchecked(boolean isUnchecked) { - // ignored - } - } Index: compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java,v retrieving revision 1.125 diff -u -r1.125 CastExpression.java --- compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java 8 Jan 2009 20:51:05 -0000 1.125 +++ compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java 4 Feb 2009 17:51:50 -0000 @@ -256,7 +256,6 @@ public void setActualReceiverType(ReferenceBinding actualReceiverType) { /* ignore */} public void setDepth(int depth) { /* ignore */} public void setFieldIndex(int depth){ /* ignore */} - public void setUnchecked(boolean isUnchecked) {/* ignore */} public int sourceStart() { return 0; } public int sourceEnd() { return 0; } }; Index: compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java,v retrieving revision 1.78 diff -u -r1.78 AllocationExpression.java --- compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java 3 Feb 2009 09:40:45 -0000 1.78 +++ compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java 4 Feb 2009 17:51:49 -0000 @@ -356,7 +356,9 @@ } if (isMethodUseDeprecated(this.binding, scope, true)) scope.problemReporter().deprecatedMethod(this.binding, this); - checkInvocationArguments(scope, null, allocationType, this.binding, this.arguments, argumentTypes, argsContainCast, this, (this.bits & ASTNode.Unchecked) != 0); + if (checkInvocationArguments(scope, null, allocationType, this.binding, this.arguments, argumentTypes, argsContainCast, this)) { + this.bits |= ASTNode.Unchecked; + } if (this.typeArguments != null && this.binding.original().typeVariables == Binding.NO_TYPE_VARIABLES) { scope.problemReporter().unnecessaryTypeArgumentsForMethodInvocation(this.binding, this.genericTypeArguments, this.typeArguments); } @@ -375,15 +377,6 @@ // ignored } -public void setUnchecked(boolean isUnchecked) { - if (isUnchecked) { - this.bits |= ASTNode.Unchecked; - } else { - this.bits &= ~ASTNode.Unchecked; - } - -} - public void traverse(ASTVisitor visitor, BlockScope scope) { if (visitor.visit(this, scope)) { if (this.typeArguments != null) { Index: compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java,v retrieving revision 1.142 diff -u -r1.142 MessageSend.java --- compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java 3 Feb 2009 09:40:45 -0000 1.142 +++ compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java 4 Feb 2009 17:51:51 -0000 @@ -467,7 +467,9 @@ scope.problemReporter().indirectAccessToStaticMethod(this, this.binding); } } - checkInvocationArguments(scope, this.receiver, this.actualReceiverType, this.binding, this.arguments, argumentTypes, argsContainCast, this, (this.bits & ASTNode.Unchecked) != 0); + if (checkInvocationArguments(scope, this.receiver, this.actualReceiverType, this.binding, this.arguments, argumentTypes, argsContainCast, this)) { + this.bits |= ASTNode.Unchecked; + } //-------message send that are known to fail at compile time----------- if (this.binding.isAbstract()) { @@ -538,14 +540,6 @@ // ignore for here } -public void setUnchecked(boolean isUnchecked) { - if (isUnchecked) { - this.bits |= ASTNode.Unchecked; - } else { - this.bits &= ~ASTNode.Unchecked; - } -} - public void traverse(ASTVisitor visitor, BlockScope blockScope) { if (visitor.visit(this, blockScope)) { this.receiver.traverse(visitor, blockScope); Index: compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java,v retrieving revision 1.69 diff -u -r1.69 ExplicitConstructorCall.java --- compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java 3 Feb 2009 09:40:45 -0000 1.69 +++ compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java 4 Feb 2009 17:51:50 -0000 @@ -400,7 +400,9 @@ if (isMethodUseDeprecated(this.binding, scope, this.accessMode != ExplicitConstructorCall.ImplicitSuper)) { scope.problemReporter().deprecatedMethod(this.binding, this); } - checkInvocationArguments(scope, null, receiverType, this.binding, this.arguments, argumentTypes, argsContainCast, this, (this.bits & ASTNode.Unchecked) != 0); + if (checkInvocationArguments(scope, null, receiverType, this.binding, this.arguments, argumentTypes, argsContainCast, this)) { + this.bits |= ASTNode.Unchecked; + } if (this.binding.isPrivate() || receiverType.isLocalType()) { this.binding.original().modifiers |= ExtraCompilerModifiers.AccLocallyUsed; } @@ -432,15 +434,6 @@ public void setFieldIndex(int depth) { // ignore for here } - - public void setUnchecked(boolean isUnchecked) { - if (isUnchecked) { - this.bits |= ASTNode.Unchecked; - } else { - this.bits &= ~ASTNode.Unchecked; - } - - } public void traverse(ASTVisitor visitor, BlockScope scope) { if (visitor.visit(this, scope)) { Index: eval/org/eclipse/jdt/internal/eval/CodeSnippetSuperReference.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetSuperReference.java,v retrieving revision 1.21 diff -u -r1.21 CodeSnippetSuperReference.java --- eval/org/eclipse/jdt/internal/eval/CodeSnippetSuperReference.java 8 Jan 2009 20:51:06 -0000 1.21 +++ eval/org/eclipse/jdt/internal/eval/CodeSnippetSuperReference.java 4 Feb 2009 17:51:52 -0000 @@ -54,10 +54,5 @@ public void setFieldIndex(int index){ // ignored } - -public void setUnchecked(boolean isUnchecked) { - // ignored -} - } Index: eval/org/eclipse/jdt/internal/eval/CodeSnippetReturnStatement.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetReturnStatement.java,v retrieving revision 1.35 diff -u -r1.35 CodeSnippetReturnStatement.java --- eval/org/eclipse/jdt/internal/eval/CodeSnippetReturnStatement.java 8 Jan 2009 20:51:06 -0000 1.35 +++ eval/org/eclipse/jdt/internal/eval/CodeSnippetReturnStatement.java 4 Feb 2009 17:51:52 -0000 @@ -141,8 +141,4 @@ public void setFieldIndex(int depth) { // ignored } - -public void setUnchecked(boolean isUnchecked) { - // ignored -} } Index: eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java,v retrieving revision 1.62 diff -u -r1.62 CodeSnippetMessageSend.java --- eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java 3 Feb 2009 09:40:45 -0000 1.62 +++ eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java 4 Feb 2009 17:51:52 -0000 @@ -312,7 +312,9 @@ } } } - checkInvocationArguments(scope, this.receiver, this.actualReceiverType, this.binding, this.arguments, argumentTypes, argsContainCast, this, (this.bits & ASTNode.Unchecked) != 0); + if (checkInvocationArguments(scope, this.receiver, this.actualReceiverType, this.binding, this.arguments, argumentTypes, argsContainCast, this)) { + this.bits |= ASTNode.Unchecked; + } //-------message send that are known to fail at compile time----------- if (this.binding.isAbstract()) { Index: eval/org/eclipse/jdt/internal/eval/CodeSnippetThisReference.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetThisReference.java,v retrieving revision 1.36 diff -u -r1.36 CodeSnippetThisReference.java --- eval/org/eclipse/jdt/internal/eval/CodeSnippetThisReference.java 8 Jan 2009 20:51:06 -0000 1.36 +++ eval/org/eclipse/jdt/internal/eval/CodeSnippetThisReference.java 4 Feb 2009 17:51:52 -0000 @@ -123,8 +123,4 @@ public void setFieldIndex(int index){ // ignored } - - public void setUnchecked(boolean isUnchecked) { - // ignored - } } Index: compiler/org/eclipse/jdt/internal/compiler/lookup/InvocationSite.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InvocationSite.java,v retrieving revision 1.14 diff -u -r1.14 InvocationSite.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/InvocationSite.java 8 Jan 2009 20:51:04 -0000 1.14 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/InvocationSite.java 4 Feb 2009 17:51:51 -0000 @@ -22,12 +22,6 @@ void setActualReceiverType(ReferenceBinding receiverType); void setDepth(int depth); void setFieldIndex(int depth); - /** - * Positioned when a method/constructor invocation is detected having required unchecked conversion - * for becoming applicable. - * @param isUnchecked - */ - void setUnchecked(boolean isUnchecked); int sourceEnd(); int sourceStart(); } Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java,v retrieving revision 1.67 diff -u -r1.67 ParameterizedGenericMethodBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java 23 Jan 2009 19:50:21 -0000 1.67 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java 4 Feb 2009 17:51:51 -0000 @@ -97,7 +97,7 @@ return new ProblemMethodBinding(methodSubstitute, originalMethod.selector, augmentedArguments, ProblemReasons.ParameterBoundMismatch); case TypeConstants.UNCHECKED : // tolerate unchecked bounds - invocationSite.setUnchecked(true); + methodSubstitute.tagBits |= TagBits.HasUncheckedTypeArgumentForBoundCheck; break; } } Index: compiler/org/eclipse/jdt/internal/compiler/lookup/TagBits.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TagBits.java,v retrieving revision 1.34 diff -u -r1.34 TagBits.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/TagBits.java 27 Jun 2008 16:04:02 -0000 1.34 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/TagBits.java 4 Feb 2009 17:51:52 -0000 @@ -29,6 +29,9 @@ // set for all bindings either represeting a missing type (type), or directly referencing a missing type (field/method/variable) long HasMissingType = ASTNode.Bit8; + // for method + long HasUncheckedTypeArgumentForBoundCheck = ASTNode.Bit9; + // for the type cycle hierarchy check used by ClassScope long BeginHierarchyCheck = ASTNode.Bit9; // type long EndHierarchyCheck = ASTNode.Bit10; // type Index: codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java,v retrieving revision 1.386 diff -u -r1.386 CompletionEngine.java --- codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 22 Jan 2009 09:46:59 -0000 1.386 +++ codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 4 Feb 2009 17:51:49 -0000 @@ -594,7 +594,6 @@ public void setActualReceiverType(ReferenceBinding receiverType) {/* empty */} public void setDepth(int depth){/* empty */} public void setFieldIndex(int depth){/* empty */} - public void setUnchecked(boolean isUnchecked) {/* empty */} public int sourceEnd() { return 0; } public int sourceStart() { return 0; } }; #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java,v retrieving revision 1.790 diff -u -r1.790 GenericTypeTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 4 Feb 2009 13:29:05 -0000 1.790 +++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 4 Feb 2009 17:52:10 -0000 @@ -49210,7 +49210,59 @@ "CAUGHT" ); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=263633 public void test1447() { + this.runConformTest( + new String[] { + "X.java", + "public abstract class X implements Visitable {\n" + + " public > T accept(U v) {\n" + + " return null;\n" + + " }\n" + + " public > T accept2(U v) {\n" + + " if (v == null)\n" + + " return this.accept(v);\n" + + " else \n" + + " return this. accept(v);\n" + + " }\n" + + "}\n" + + "interface Visitable {\n" + + " > T accept(U v);\n" + + "}\n" + + "interface Visitor {\n" + + "}\n", + }, + "" + ); +} + +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=263633 - variation +public void test1448() { + this.runConformTest( + new String[] { + "X.java", + "public abstract class X implements Visitable {\n" + + " public T accept(U v) {\n" + + " return null;\n" + + " }\n" + + " public T accept2(U v) {\n" + + " if (v == null)\n" + + " return this.accept(v);\n" + + " else \n" + + " return this. accept(v);\n" + + " }\n" + + "}\n" + + "interface Visitable {\n" + + " T accept(U v);\n" + + "}\n" + + "interface Visitor{\n" + + "}\n", + }, + "" + ); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=263633 - variation +public void test1449() { this.runConformTest( new String[] { "X.java",