Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2406)

Unified Diff: pkg/front_end/lib/src/fasta/kernel/body_builder.dart

Issue 2775163003: Make catch variables final. (Closed)
Patch Set: Update expectation files. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/front_end/test/fasta/accessors.dart.direct.expect » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/lib/src/fasta/kernel/body_builder.dart
diff --git a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
index aded0f24e94f9df966a9c5c68e2c43067a04222c..5b1ad433d2eb734c540649ff2bd79604b94df9a9 100644
--- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
@@ -1393,7 +1393,12 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
}
Identifier name = pop();
DartType type = pop();
- pop(); // Modifiers.
+ int modifiers = Modifier.validate(pop());
+ if (inCatchClause) {
+ modifiers |= finalMask;
+ }
+ bool isConst = (modifiers & constMask) != 0;
+ bool isFinal = (modifiers & finalMask) != 0;
ignore(Unhandled.Metadata);
VariableDeclaration variable;
if (!inCatchClause && functionNestingLevel == 0) {
@@ -1417,7 +1422,10 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
}
type = field.target.type ?? const DynamicType();
variable = new VariableDeclaration(name.name,
- type: type, initializer: name.initializer);
+ type: type,
+ initializer: name.initializer,
+ isFinal: isFinal,
+ isConst: isConst)..fileOffset = name.fileOffset;
} else {
addCompileTimeError(
name.fileOffset, "'${name.name}' isn't a field in this class.");
@@ -1425,7 +1433,9 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
}
variable ??= new VariableDeclaration(name.name,
type: type ?? const DynamicType(),
- initializer: name.initializer)..fileOffset = name.fileOffset;
+ initializer: name.initializer,
+ isFinal: isFinal,
+ isConst: isConst)..fileOffset = name.fileOffset;
push(variable);
}
« no previous file with comments | « no previous file | pkg/front_end/test/fasta/accessors.dart.direct.expect » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698