@@ -2388,6 +2388,8 @@ abstract class NonPromotionReasonVisitor<R, Node extends Object,
23882388 DemoteViaForEachVariableWrite <Variable , Node > reason);
23892389
23902390 R visitPropertyNotPromoted (PropertyNotPromoted reason);
2391+
2392+ R visitThisNotPromoted (ThisNotPromoted reason);
23912393}
23922394
23932395/// Non-promotion reason describing the situation where an expression was not
@@ -2622,6 +2624,19 @@ class SsaNode<Variable extends Object, Type extends Object> {
26222624 }
26232625}
26242626
2627+ /// Non-promotion reason describing the situation where an expression was not
2628+ /// promoted due to the fact that it's a reference to `this` .
2629+ class ThisNotPromoted extends NonPromotionReason {
2630+ @override
2631+ String get shortName => 'thisNotPromoted' ;
2632+
2633+ @override
2634+ R accept< R , Node extends Object , Expression extends Object ,
2635+ Variable extends Object > (
2636+ NonPromotionReasonVisitor <R , Node , Expression , Variable > visitor) =>
2637+ visitor.visitThisNotPromoted (this );
2638+ }
2639+
26252640/// Enum representing the different classifications of types that can be
26262641/// returned by [TypeOperations.classifyType] .
26272642enum TypeClassification {
@@ -5099,8 +5114,14 @@ class _ThisReference<Variable extends Object, Type extends Object>
50995114 Map <Type , NonPromotionReason > getNonPromotionReasons (
51005115 Map <Variable ?, VariableModel <Variable , Type >> variableInfo,
51015116 TypeOperations <Variable , Type > typeOperations) {
5102- // TODO(paulberry): implement.
5103- return {};
5117+ Map <Type , NonPromotionReason > result = < Type , NonPromotionReason > {};
5118+ List <Type >? promotedTypes = _getInfo (variableInfo)? .promotedTypes;
5119+ if (promotedTypes != null ) {
5120+ for (Type type in promotedTypes) {
5121+ result[type] = new ThisNotPromoted ();
5122+ }
5123+ }
5124+ return result;
51045125 }
51055126
51065127 @override
0 commit comments