@@ -294,10 +294,9 @@ Statement while_(Expression condition, List<Statement> body) {
294294 location: location);
295295}
296296
297- Pattern wildcard (
298- {String ? type, String ? expectInferredType, bool isFinal = false }) =>
297+ Pattern wildcard ({String ? type, String ? expectInferredType}) =>
299298 _VariablePattern (type == null ? null : Type (type), null , expectInferredType,
300- isFinal : isFinal, location: computeLocation ());
299+ location: computeLocation ());
301300
302301typedef SharedMatchContext
303302 = shared.MatchContext <Node , Expression , Pattern , Type , Var >;
@@ -1252,11 +1251,12 @@ abstract class TryStatement extends Statement implements TryBuilder {
12521251/// analysis testing.
12531252class Var extends Node implements Promotable {
12541253 final String name;
1254+ final bool isFinal;
12551255
12561256 /// The type of the variable, or `null` if it is not yet known.
12571257 Type ? _type;
12581258
1259- Var (this .name) : super ._(location: computeLocation ());
1259+ Var (this .name, { this .isFinal = false } ) : super ._(location: computeLocation ());
12601260
12611261 /// Creates an L-value representing a reference to this variable.
12621262 LValue get expr =>
@@ -1278,11 +1278,10 @@ class Var extends Node implements Promotable {
12781278 _type = value;
12791279 }
12801280
1281- Pattern pattern (
1282- {String ? type, String ? expectInferredType, bool isFinal = false }) =>
1281+ Pattern pattern ({String ? type, String ? expectInferredType}) =>
12831282 new _VariablePattern (
12841283 type == null ? null : Type (type), this , expectInferredType,
1285- isFinal : isFinal, location: computeLocation ());
1284+ location: computeLocation ());
12861285
12871286 @override
12881287 void preVisit (PreVisitor visitor) {}
@@ -3220,6 +3219,11 @@ class _MiniAstTypeAnalyzer
32203219 return node.isExhaustive;
32213220 }
32223221
3222+ @override
3223+ bool isVariableFinal (Var node) {
3224+ return node.isFinal;
3225+ }
3226+
32233227 @override
32243228 bool isVariablePattern (Node pattern) => pattern is _VariablePattern ;
32253229
@@ -3925,10 +3929,8 @@ class _VariablePattern extends Pattern {
39253929
39263930 final String ? expectInferredType;
39273931
3928- final bool isFinal;
3929-
39303932 _VariablePattern (this .declaredType, this .variable, this .expectInferredType,
3931- {this .isFinal = false , required super .location})
3933+ {required super .location})
39323934 : super ._();
39333935
39343936 Type computeSchema (Harness h) =>
@@ -3949,8 +3951,7 @@ class _VariablePattern extends Pattern {
39493951 SharedMatchContext context,
39503952 ) {
39513953 var staticType = h.typeAnalyzer.analyzeVariablePattern (
3952- matchedType, context, this , variable, declaredType,
3953- isFinal: isFinal);
3954+ matchedType, context, this , variable, declaredType);
39543955 h.typeAnalyzer.handleVariablePattern (this ,
39553956 matchedType: matchedType, staticType: staticType);
39563957 }
0 commit comments