Bug 527554 - [18.3] Compiler support for JEP 286 (LVTI)
Fix modifiers of blank finals
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 d223ef0..1b5f671 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
@@ -267,26 +267,8 @@
variableTypeInferenceError = true;
}
}
- // 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;
-
- public void markReferenced() {
- if (! this.isInitialized) {
- scope.problemReporter().varLocalReferencesItself(LocalDeclaration.this);
- this.type = null;
- this.isInitialized = true; // Quell additional type errors
- }
- }
- @Override
- public void markInitialized() {
- this.isInitialized = true;
- }
- };
} else {
- // create a binding from the specified type
variableType = this.type.resolveType(scope, true /* check bounds*/);
- this.binding = new LocalVariableBinding(this, variableType, this.modifiers, false /*isArgument*/);
}
this.bits |= (this.type.bits & ASTNode.HasTypeAnnotations);
@@ -317,6 +299,28 @@
if ((this.modifiers & ClassFileConstants.AccFinal)!= 0 && this.initialization == null) {
this.modifiers |= ExtraCompilerModifiers.AccBlankFinal;
}
+ 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
+ this.binding = new LocalVariableBinding(this, variableType != null ? variableType : scope.getJavaLangObject(), this.modifiers, false) {
+ private boolean isInitialized = false;
+
+ public void markReferenced() {
+ if (! this.isInitialized) {
+ scope.problemReporter().varLocalReferencesItself(LocalDeclaration.this);
+ this.type = null;
+ this.isInitialized = true; // Quell additional type errors
+ }
+ }
+ @Override
+ public void markInitialized() {
+ this.isInitialized = true;
+ }
+ };
+ } else {
+ // create a binding from the specified type
+ this.binding = new LocalVariableBinding(this, variableType, this.modifiers, false /*isArgument*/);
+ }
scope.addLocalVariable(this.binding);
this.binding.setConstant(Constant.NotAConstant);
// allow to recursivelly target the binding....