diff options
author | ssankaran | 2014-10-07 14:37:39 +0000 |
---|---|---|
committer | Jayaprakash Arthanareeswaran | 2014-11-21 07:24:04 +0000 |
commit | 4637690346bbf9fd15964504ed4ed2dac42b1170 (patch) | |
tree | f4f2e748a5b609698d0ccc85a86b71572da0d0e6 | |
parent | e23590101facf968511a5ff9acc326c6efbe8315 (diff) | |
download | eclipse.jdt.core-4637690346bbf9fd15964504ed4ed2dac42b1170.tar.gz eclipse.jdt.core-4637690346bbf9fd15964504ed4ed2dac42b1170.tar.xz eclipse.jdt.core-4637690346bbf9fd15964504ed4ed2dac42b1170.zip |
More infrastructure changes for F & G integration
12 files changed, 70 insertions, 38 deletions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java index b2fe043cdb..3fd48eb079 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java @@ -78,6 +78,7 @@ public class AllocationExpression extends Expression implements Invocation { // hold on to this context from invocation applicability inference until invocation type inference (per method candidate): private SimpleLookupTable/*<PMB,IC18>*/ inferenceContexts; protected InnerInferenceHelper innerInferenceHelper; + public boolean argumentsHaveErrors; /** Record to keep state between different parts of resolution. */ ResolutionState suspendedResolutionState; @@ -385,14 +386,14 @@ public TypeBinding resolveType(BlockScope scope) { // resolve type arguments (for generic constructor call) if (this.typeArguments != null) { int length = this.typeArguments.length; - boolean argHasError = sourceLevel < ClassFileConstants.JDK1_5; + this.argumentsHaveErrors = sourceLevel < ClassFileConstants.JDK1_5; this.genericTypeArguments = new TypeBinding[length]; for (int i = 0; i < length; i++) { TypeReference typeReference = this.typeArguments[i]; if ((this.genericTypeArguments[i] = typeReference.resolveType(scope, true /* check bounds*/)) == null) { - argHasError = true; + this.argumentsHaveErrors = true; } - if (argHasError && typeReference instanceof Wildcard) { + if (this.argumentsHaveErrors && typeReference instanceof Wildcard) { scope.problemReporter().illegalUsageOfWildcard(typeReference); } } @@ -400,7 +401,7 @@ public TypeBinding resolveType(BlockScope scope) { scope.problemReporter().diamondNotWithExplicitTypeArguments(this.typeArguments); return null; } - if (argHasError) { + if (this.argumentsHaveErrors) { if (this.arguments != null) { // still attempt to resolve arguments for (int i = 0, max = this.arguments.length; i < max; i++) { this.arguments[i].resolveType(scope); @@ -414,7 +415,7 @@ public TypeBinding resolveType(BlockScope scope) { boolean argsContainCast = false; TypeBinding[] argumentTypes = Binding.NO_PARAMETERS; if (this.arguments != null) { - boolean argHasError = false; + this.argumentsHaveErrors = false; int length = this.arguments.length; argumentTypes = new TypeBinding[length]; for (int i = 0; i < length; i++) { @@ -427,14 +428,14 @@ public TypeBinding resolveType(BlockScope scope) { if (this.arguments[i].resolvedType != null) scope.problemReporter().genericInferenceError("Argument was unexpectedly found resolved", this); //$NON-NLS-1$ if ((argumentTypes[i] = argument.resolveType(scope)) == null) { - argHasError = true; + this.argumentsHaveErrors = true; } if (sourceLevel >= ClassFileConstants.JDK1_8 && (argument.isPolyExpression() || ((argument instanceof Invocation) && ((Invocation) argument).usesInference()))) { if (this.innerInferenceHelper == null) this.innerInferenceHelper = new InnerInferenceHelper(); } } - if (argHasError) { + if (this.argumentsHaveErrors) { /* https://bugs.eclipse.org/bugs/show_bug.cgi?id=345359, if arguments have errors, completely bail out in the <> case. No meaningful type resolution is possible since inference of the elided types is fully tied to argument types. Do not return the partially resolved type. diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocAllocationExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocAllocationExpression.java index 5f23107abc..0ddda5fc0d 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocAllocationExpression.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocAllocationExpression.java @@ -46,7 +46,7 @@ public class JavadocAllocationExpression extends AllocationExpression { TypeBinding[] argumentTypes = Binding.NO_PARAMETERS; boolean hasTypeVarArgs = false; if (this.arguments != null) { - boolean argHasError = false; + this.argumentsHaveErrors = false; int length = this.arguments.length; argumentTypes = new TypeBinding[length]; for (int i = 0; i < length; i++) { @@ -57,12 +57,12 @@ public class JavadocAllocationExpression extends AllocationExpression { argumentTypes[i] = argument.resolveType((BlockScope)scope); } if (argumentTypes[i] == null) { - argHasError = true; + this.argumentsHaveErrors = true; } else if (!hasTypeVarArgs) { hasTypeVarArgs = argumentTypes[i].isTypeVariable(); } } - if (argHasError) { + if (this.argumentsHaveErrors) { return null; } } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocMessageSend.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocMessageSend.java index 87dccc30c1..21b5c9a1aa 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocMessageSend.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocMessageSend.java @@ -53,7 +53,7 @@ public class JavadocMessageSend extends MessageSend { TypeBinding[] argumentTypes = Binding.NO_PARAMETERS; boolean hasArgsTypeVar = false; if (this.arguments != null) { - boolean argHasError = false; // typeChecks all arguments + this.argumentsHaveErrors = false; // typeChecks all arguments int length = this.arguments.length; argumentTypes = new TypeBinding[length]; for (int i = 0; i < length; i++){ @@ -64,12 +64,12 @@ public class JavadocMessageSend extends MessageSend { argumentTypes[i] = argument.resolveType((BlockScope)scope); } if (argumentTypes[i] == null) { - argHasError = true; + this.argumentsHaveErrors = true; } else if (!hasArgsTypeVar) { hasArgsTypeVar = argumentTypes[i].isTypeVariable(); } } - if (argHasError) { + if (this.argumentsHaveErrors) { return null; } } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java index 15b6cadbfe..ef842c8ad1 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java @@ -116,6 +116,8 @@ public class MessageSend extends Expression implements Invocation { // hold on to this context from invocation applicability inference until invocation type inference (per method candidate): private SimpleLookupTable/*<PGMB,InferenceContext18>*/ inferenceContexts; protected InnerInferenceHelper innerInferenceHelper; + public boolean argumentsHaveErrors; + public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) { boolean nonStatic = !this.binding.isStatic(); @@ -611,18 +613,18 @@ public TypeBinding resolveType(BlockScope scope) { // resolve type arguments (for generic constructor call) if (this.typeArguments != null) { int length = this.typeArguments.length; - boolean argHasError = sourceLevel < ClassFileConstants.JDK1_5; // typeChecks all arguments + this.argumentsHaveErrors = sourceLevel < ClassFileConstants.JDK1_5; // typeChecks all arguments this.genericTypeArguments = new TypeBinding[length]; for (int i = 0; i < length; i++) { TypeReference typeReference = this.typeArguments[i]; if ((this.genericTypeArguments[i] = typeReference.resolveType(scope, true /* check bounds*/)) == null) { - argHasError = true; + this.argumentsHaveErrors = true; } - if (argHasError && typeReference instanceof Wildcard) { + if (this.argumentsHaveErrors && typeReference instanceof Wildcard) { scope.problemReporter().illegalUsageOfWildcard(typeReference); } } - if (argHasError) { + if (this.argumentsHaveErrors) { if (this.arguments != null) { // still attempt to resolve arguments for (int i = 0, max = this.arguments.length; i < max; i++) { this.arguments[i].resolveType(scope); @@ -634,7 +636,7 @@ public TypeBinding resolveType(BlockScope scope) { // will check for null after args are resolved TypeBinding[] argumentTypes = Binding.NO_PARAMETERS; if (this.arguments != null) { - boolean argHasError = false; // typeChecks all arguments + this.argumentsHaveErrors = false; // typeChecks all arguments int length = this.arguments.length; argumentTypes = new TypeBinding[length]; for (int i = 0; i < length; i++){ @@ -647,7 +649,7 @@ public TypeBinding resolveType(BlockScope scope) { } argument.setExpressionContext(INVOCATION_CONTEXT); if ((argumentTypes[i] = argument.resolveType(scope)) == null){ - argHasError = true; + this.argumentsHaveErrors = true; } if (sourceLevel >= ClassFileConstants.JDK1_8) { if (argument.isPolyExpression() @@ -657,7 +659,7 @@ public TypeBinding resolveType(BlockScope scope) { } } } - if (argHasError) { + if (this.argumentsHaveErrors) { if (this.actualReceiverType instanceof ReferenceBinding) { // record a best guess, for clients who need hint about possible method match TypeBinding[] pseudoArgs = new TypeBinding[length]; diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java index 5920a80239..bbb76dd93e 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java @@ -370,14 +370,14 @@ public class QualifiedAllocationExpression extends AllocationExpression { final boolean isDiamond = this.type != null && (this.type.bits & ASTNode.IsDiamond) != 0; if (this.typeArguments != null) { int length = this.typeArguments.length; - boolean argHasError = sourceLevel < ClassFileConstants.JDK1_5; + this.argumentsHaveErrors = sourceLevel < ClassFileConstants.JDK1_5; this.genericTypeArguments = new TypeBinding[length]; for (int i = 0; i < length; i++) { TypeReference typeReference = this.typeArguments[i]; if ((this.genericTypeArguments[i] = typeReference.resolveType(scope, true /* check bounds*/)) == null) { - argHasError = true; + this.argumentsHaveErrors = true; } - if (argHasError && typeReference instanceof Wildcard) { + if (this.argumentsHaveErrors && typeReference instanceof Wildcard) { scope.problemReporter().illegalUsageOfWildcard(typeReference); } } @@ -385,7 +385,7 @@ public class QualifiedAllocationExpression extends AllocationExpression { scope.problemReporter().diamondNotWithExplicitTypeArguments(this.typeArguments); return null; } - if (argHasError) { + if (this.argumentsHaveErrors) { if (this.arguments != null) { // still attempt to resolve arguments for (int i = 0, max = this.arguments.length; i < max; i++) { this.arguments[i].resolveType(scope); diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReferenceExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReferenceExpression.java index 24df199874..d18997a78e 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReferenceExpression.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReferenceExpression.java @@ -681,6 +681,7 @@ public class ReferenceExpression extends FunctionalExpression implements Invocat MethodBinding previousBinding = this.binding; MethodBinding previousDescriptor = this.descriptor; TypeBinding previousResolvedType = this.resolvedType; + TypeBinding previousExpectedType = this.expectedType; try { setExpressionContext(INVOCATION_CONTEXT); setExpectedType(targetType); @@ -695,7 +696,7 @@ public class ReferenceExpression extends FunctionalExpression implements Invocat this.descriptor = previousDescriptor; this.resolvedType = previousResolvedType; setExpressionContext(previousContext); - this.expectedType = null; // don't call setExpectedType(null), would NPE + this.expectedType = previousExpectedType; this.trialResolution = false; } } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java index 0b61cd9e05..d82605761c 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java @@ -1030,6 +1030,11 @@ public String toString(int tab) { private List trackingVariables; // can be null if no resources are tracked /** Used only during analyseCode and only for checking if a resource was closed in a finallyBlock. */ public FlowInfo finallyInfo; +public boolean shouldConsultShadowOriginal; + +public boolean shouldConsultShadowOriginal() { + return this.shouldConsultShadowOriginal; +} /** * Register a tracking variable and compute its id. */ diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/PolyTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/PolyTypeBinding.java index ff02719c83..289a66d430 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/PolyTypeBinding.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/PolyTypeBinding.java @@ -36,6 +36,17 @@ public class PolyTypeBinding extends TypeBinding { public boolean isCompatibleWith(TypeBinding left, Scope scope) { return this.vanillaCompatibilty ? this.expression.isCompatibleWith(left, scope) : this.expression.isBoxingCompatibleWith(left, scope); } + + @Override + public boolean isPertinentToApplicability(TypeBinding targetType, MethodBinding method) { + return this.expression.isPertinentToApplicability(targetType, method); + } + + @Override + public boolean isPertinentToApplicability(TypeVariableBinding typeVariable, MethodBinding method) { + return this.expression.isPertinentToApplicability(typeVariable, method); + } + public char[] qualifiedSourceName() { return readableName(); diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java index 5a13d4764b..9424ec430c 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java @@ -524,6 +524,14 @@ public final boolean isBaseType() { return (this.tagBits & TagBits.IsBaseType) != 0; } +public boolean isPertinentToApplicability(TypeVariableBinding typeVariable, MethodBinding method) { + return true; +} + +public boolean isPertinentToApplicability(TypeBinding argument, MethodBinding method) { + return true; +} + /* Answer true if the receiver is a base type other than void or null */ public final boolean isPrimitiveType() { diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java index d38afc377f..4c3c63fcc0 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java @@ -499,6 +499,10 @@ public class TypeVariableBinding extends ReferenceBinding { this.inRecursiveFunction = false; } + public boolean isPertinentToApplicability(TypeBinding argument, MethodBinding method) { + return argument.isPertinentToApplicability(this, method); + } + public boolean isProperType(boolean admitCapture18) { // handle recursive calls: if (this.inRecursiveFunction) // be optimistic, since this node is not an inference variable diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java index 623bc354a0..c2141e6f1f 100644 --- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java +++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java @@ -158,14 +158,14 @@ public TypeBinding resolveType(BlockScope scope) { // resolve type arguments (for generic constructor call) if (this.typeArguments != null) { int length = this.typeArguments.length; - boolean argHasError = scope.compilerOptions().sourceLevel < ClassFileConstants.JDK1_5; + this.argumentsHaveErrors = scope.compilerOptions().sourceLevel < ClassFileConstants.JDK1_5; this.genericTypeArguments = new TypeBinding[length]; for (int i = 0; i < length; i++) { TypeReference typeReference = this.typeArguments[i]; if ((this.genericTypeArguments[i] = typeReference.resolveType(scope, true /* check bounds*/)) == null) { - argHasError = true; + this.argumentsHaveErrors = true; } - if (argHasError && typeReference instanceof Wildcard) { + if (this.argumentsHaveErrors && typeReference instanceof Wildcard) { scope.problemReporter().illegalUsageOfWildcard(typeReference); } } @@ -173,7 +173,7 @@ public TypeBinding resolveType(BlockScope scope) { scope.problemReporter().diamondNotWithExplicitTypeArguments(this.typeArguments); return null; } - if (argHasError) { + if (this.argumentsHaveErrors) { if (this.arguments != null) { // still attempt to resolve arguments for (int i = 0, max = this.arguments.length; i < max; i++) { this.arguments[i].resolveType(scope); @@ -187,7 +187,7 @@ public TypeBinding resolveType(BlockScope scope) { boolean argsContainCast = false; TypeBinding[] argumentTypes = Binding.NO_PARAMETERS; if (this.arguments != null) { - boolean argHasError = false; + this.argumentsHaveErrors = false; int length = this.arguments.length; argumentTypes = new TypeBinding[length]; TypeBinding argumentType; @@ -199,14 +199,14 @@ public TypeBinding resolveType(BlockScope scope) { } argument.setExpressionContext(INVOCATION_CONTEXT); if ((argumentType = argumentTypes[i] = argument.resolveType(scope)) == null) { - argHasError = true; + this.argumentsHaveErrors = true; } if (argumentType != null && argumentType.kind() == Binding.POLY_TYPE) { if (this.innerInferenceHelper == null) this.innerInferenceHelper = new InnerInferenceHelper(); } } - if (argHasError) { + if (this.argumentsHaveErrors) { return this.resolvedType; } } diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java index 1f2a4d33da..738707b75a 100644 --- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java +++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java @@ -212,21 +212,21 @@ public TypeBinding resolveType(BlockScope scope) { // resolve type arguments (for generic constructor call) if (this.typeArguments != null) { int length = this.typeArguments.length; - boolean argHasError = false; // typeChecks all arguments + this.argumentsHaveErrors = false; // typeChecks all arguments this.genericTypeArguments = new TypeBinding[length]; for (int i = 0; i < length; i++) { if ((this.genericTypeArguments[i] = this.typeArguments[i].resolveType(scope, true /* check bounds*/)) == null) { - argHasError = true; + this.argumentsHaveErrors = true; } } - if (argHasError) { + if (this.argumentsHaveErrors) { return null; } } // will check for null after args are resolved TypeBinding[] argumentTypes = Binding.NO_PARAMETERS; if (this.arguments != null) { - boolean argHasError = false; // typeChecks all arguments + this.argumentsHaveErrors = false; // typeChecks all arguments int length = this.arguments.length; argumentTypes = new TypeBinding[length]; TypeBinding argumentType; @@ -238,13 +238,13 @@ public TypeBinding resolveType(BlockScope scope) { } argument.setExpressionContext(INVOCATION_CONTEXT); if ((argumentType = argumentTypes[i] = this.arguments[i].resolveType(scope)) == null) - argHasError = true; + this.argumentsHaveErrors = true; if (argumentType != null && argumentType.kind() == Binding.POLY_TYPE) { if (this.innerInferenceHelper == null) this.innerInferenceHelper = new InnerInferenceHelper(); } } - if (argHasError) { + if (this.argumentsHaveErrors) { if(this.actualReceiverType instanceof ReferenceBinding) { // record any selector match, for clients who may still need hint about possible method match this.binding = scope.findMethod((ReferenceBinding)this.actualReceiverType, this.selector, new TypeBinding[]{}, this, false); |