Skip to content

Commit

Permalink
* toString() output of AST nodes shows up with modifier sealed for
Browse files Browse the repository at this point in the history
pattern variable declaration

* Fixes #2017
  • Loading branch information
srikanth-sankaran committed Feb 15, 2024
1 parent c76d80f commit ca84d91
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,8 @@ public void markInitialized() {
// create a binding from the specified type
this.binding = new LocalVariableBinding(this, variableType, this.modifiers, false /*isArgument*/);
}
if (isPatternVariable)
this.binding.tagBits |= TagBits.IsPatternBinding;
scope.addLocalVariable(this.binding);
this.binding.setConstant(Constant.NotAConstant);
// allow to recursivelly target the binding....
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ public TypeBinding resolveType(BlockScope scope) {
if (this.resolvedType != null)
return this.resolvedType; // Srikanth, fix reentry

this.local.modifiers |= ExtraCompilerModifiers.AccOutOfFlowScope;
Pattern enclosingPattern = this.getEnclosingPattern();
if (this.local.type == null || this.local.type.isTypeNameVar(scope)) {
/*
Expand Down Expand Up @@ -161,7 +160,6 @@ public TypeBinding resolveType(BlockScope scope) {
this.local.resolve(scope, true);
if (this.local.binding != null) {
this.local.binding.modifiers |= ExtraCompilerModifiers.AccOutOfFlowScope; // start out this way, will be BlockScope.include'd when definitely assigned
this.local.binding.tagBits |= TagBits.IsPatternBinding;
if (enclosingPattern != null)
this.local.binding.useFlag = LocalVariableBinding.USED; // syntactically required even if untouched
if (this.local.type != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3188,7 +3188,7 @@ public void illegalModifierForMethod(AbstractMethodDeclaration methodDecl) {
}
public void illegalModifierForVariable(LocalDeclaration localDecl, boolean complainAsArgument) {
String[] arguments = new String[] {new String(localDecl.name)};
int problemId = ((localDecl.modifiers & ExtraCompilerModifiers.AccOutOfFlowScope) != 0) ?
int problemId = localDecl.binding.isPatternVariable() ?
IProblem.IllegalModifierForPatternVariable :
(complainAsArgument
? IProblem.IllegalModifierForArgument
Expand Down

0 comments on commit ca84d91

Please sign in to comment.