diff options
Diffstat (limited to 'org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java')
-rw-r--r-- | org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java index 026243af0..7ce3c26b3 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java @@ -37,7 +37,7 @@ * Bug 529556 - [18.3] Add content assist support for 'var' as a type * Andy Clement (GoPivotal, Inc) aclement@gopivotal.com - Contributions for * Bug 409250 - [1.8][compiler] Various loose ends in 308 code generation - * Bug 426616 - [1.8][compiler] Type Annotations, multiple problems + * Bug 426616 - [1.8][compiler] Type Annotations, multiple problems *******************************************************************************/ package org.eclipse.jdt.internal.compiler.ast; @@ -130,9 +130,9 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl return flowInfo; } this.initialization.checkNPEbyUnboxing(currentScope, flowContext, flowInfo); - + FlowInfo preInitInfo = null; - boolean shouldAnalyseResource = this.binding != null + boolean shouldAnalyseResource = this.binding != null && flowInfo.reachMode() == FlowInfo.REACHABLE && currentScope.compilerOptions().analyseResourceLeaks //{ObjectTeams: notably lift methods of Closeable roles would trigger warnings against synthetic code @@ -261,7 +261,7 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl AnnotationCollector collector = new AnnotationCollector(this, targetType, parameterIndex, allAnnotationContexts); this.traverse(collector, (BlockScope) null); } - + public boolean isArgument() { return false; } @@ -272,7 +272,7 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl // Perform upwards projection on type wrt mentioned type variables TypeBinding[] mentionedTypeVariables= findCapturedTypeVariables(newType); if (mentionedTypeVariables != null && mentionedTypeVariables.length > 0) { - newType = newType.upwardsProjection(this.binding.declaringScope, mentionedTypeVariables); + newType = newType.upwardsProjection(this.binding.declaringScope, mentionedTypeVariables); } this.type.resolvedType = newType; if (this.binding != null) { @@ -295,7 +295,7 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl if (mentioned.isEmpty()) return null; return mentioned.toArray(new TypeVariableBinding[mentioned.size()]); } - + private static Expression findPolyExpression(Expression e) { // This is simpler than using an ASTVisitor, since we only care about a very few select cases. if (e instanceof FunctionalExpression) { @@ -318,7 +318,7 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl } return null; } - + @Override public void resolve(BlockScope scope) { resolve(scope, false); @@ -398,10 +398,10 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl } if (isTypeNameVar) { // Create binding for the initializer's type - // In order to resolve self-referential initializers, we must declare the variable with a placeholder type (j.l.Object), and then patch it later + // In order to resolve self-referential initializers, we must declare the variable with a placeholder type (j.l.Object), and then patch it later this.binding = new LocalVariableBinding(this, variableType != null ? variableType : scope.getJavaLangObject(), this.modifiers, false) { private boolean isInitialized = false; - + @Override public void markReferenced() { if (! this.isInitialized) { @@ -451,9 +451,9 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl return; } boolean resolveAnnotationsEarly = false; - if (scope.environment().usesNullTypeAnnotations() + if (scope.environment().usesNullTypeAnnotations() && !isTypeNameVar // 'var' does not provide a target type - && variableType != null && variableType.isValidBinding()) { + && variableType != null && variableType.isValidBinding()) { resolveAnnotationsEarly = this.initialization instanceof Invocation || this.initialization instanceof ConditionalExpression || this.initialization instanceof SwitchExpression @@ -583,8 +583,8 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl } visitor.endVisit(this, scope); } - - private void traverseWithoutInitializer(ASTVisitor visitor, BlockScope scope) { + + private void traverseWithoutInitializer(ASTVisitor visitor, BlockScope scope) { if (visitor.visit(this, scope)) { if (this.annotations != null) { int annotationsLength = this.annotations.length; @@ -597,12 +597,12 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl } public boolean isRecoveredFromLoneIdentifier() { // recovered from lonely identifier or identifier cluster ? - return this.name == RecoveryScanner.FAKE_IDENTIFIER && + return this.name == RecoveryScanner.FAKE_IDENTIFIER && (this.type instanceof SingleTypeReference || (this.type instanceof QualifiedTypeReference && !(this.type instanceof ArrayQualifiedTypeReference))) && this.initialization == null && !this.type.isBaseTypeReference(); } - + public boolean isTypeNameVar(Scope scope) { return this.type != null && this.type.isTypeNameVar(scope); } - + } |