Skip to content

Commit 274f563

Browse files
stereotype441Commit Queue
authored andcommitted
[Flow analysis] Remove PropertyNotPromoted.staticType.
This field was only used to populate expectation strings in "id" tests; it did not affect any user-visible behavior of the analyzer or CFE. Including information in "id" tests that doesn't affect any user-visible behavior isn't helpful. Removing this field will enable some upcoming flow analysis refactoring work (I intend to remove the `ExpressionInfo._type` field, replacing its remaining usages with a more reliable mechanism). Change-Id: Id4c6593fae4ef25b8c21f0625e6c1f9eaa766e17 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406403 Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Paul Berry <[email protected]>
1 parent eb59838 commit 274f563

14 files changed

+432
-303
lines changed

pkg/_fe_analyzer_shared/lib/src/flow_analysis/flow_analysis.dart

Lines changed: 24 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@ class DemoteViaExplicitWrite<Variable extends Object>
5252
String get shortName => 'explicitWrite';
5353

5454
@override
55-
R accept<R, Node extends Object, Variable extends Object,
56-
Type extends Object>(
57-
NonPromotionReasonVisitor<R, Node, Variable, Type> visitor) =>
55+
R accept<R, Node extends Object, Variable extends Object>(
56+
NonPromotionReasonVisitor<R, Node, Variable> visitor) =>
5857
visitor.visitDemoteViaExplicitWrite(
5958
this as DemoteViaExplicitWrite<Variable>);
6059

@@ -2978,23 +2977,22 @@ abstract class NonPromotionReason {
29782977
String get shortName;
29792978

29802979
/// Implementation of the visitor pattern for non-promotion reasons.
2981-
R accept<R, Node extends Object, Variable extends Object,
2982-
Type extends Object>(
2983-
NonPromotionReasonVisitor<R, Node, Variable, Type> visitor);
2980+
R accept<R, Node extends Object, Variable extends Object>(
2981+
NonPromotionReasonVisitor<R, Node, Variable> visitor);
29842982
}
29852983

29862984
/// Implementation of the visitor pattern for non-promotion reasons.
29872985
abstract class NonPromotionReasonVisitor<R, Node extends Object,
2988-
Variable extends Object, Type extends Object> {
2986+
Variable extends Object> {
29892987
NonPromotionReasonVisitor._() : assert(false, 'Do not extend this class');
29902988

29912989
R visitDemoteViaExplicitWrite(DemoteViaExplicitWrite<Variable> reason);
29922990

29932991
R visitPropertyNotPromotedForInherentReason(
2994-
PropertyNotPromotedForInherentReason<Type> reason);
2992+
PropertyNotPromotedForInherentReason reason);
29952993

29962994
R visitPropertyNotPromotedForNonInherentReason(
2997-
PropertyNotPromotedForNonInherentReason<Type> reason);
2995+
PropertyNotPromotedForNonInherentReason reason);
29982996

29992997
R visitThisNotPromoted(ThisNotPromoted reason);
30002998
}
@@ -3624,37 +3622,30 @@ class PromotionModel<Type extends Object> {
36243622

36253623
/// Non-promotion reason describing the situation where an expression was not
36263624
/// promoted due to the fact that it's a property get.
3627-
abstract base class PropertyNotPromoted<Type extends Object>
3628-
extends NonPromotionReason {
3625+
abstract base class PropertyNotPromoted extends NonPromotionReason {
36293626
/// The name of the property.
36303627
final String propertyName;
36313628

36323629
/// The field or property being accessed. This matches a `propertyMember`
36333630
/// value that was passed to [FlowAnalysis.propertyGet].
36343631
final Object? propertyMember;
36353632

3636-
/// The static type of the property at the time of the access. This is the
3637-
/// type that was passed to [FlowAnalysis.whyNotPromoted]; it is provided to
3638-
/// the client as a convenience for ID testing.
3639-
final Type staticType;
3640-
36413633
/// Whether field promotion is enabled for the current library.
36423634
final bool fieldPromotionEnabled;
36433635

3644-
PropertyNotPromoted(this.propertyName, this.propertyMember, this.staticType,
3636+
PropertyNotPromoted(this.propertyName, this.propertyMember,
36453637
{required this.fieldPromotionEnabled});
36463638
}
36473639

36483640
/// Non-promotion reason describing the situation where an expression was not
36493641
/// promoted due to the fact that it's a property get, and the target of the
36503642
/// property get is something inherently non-promotable.
3651-
final class PropertyNotPromotedForInherentReason<Type extends Object>
3652-
extends PropertyNotPromoted<Type> {
3643+
final class PropertyNotPromotedForInherentReason extends PropertyNotPromoted {
36533644
/// The reason why the property isn't promotable.
36543645
final PropertyNonPromotabilityReason whyNotPromotable;
36553646

3656-
PropertyNotPromotedForInherentReason(super.propertyName, super.propertyMember,
3657-
super.staticType, this.whyNotPromotable,
3647+
PropertyNotPromotedForInherentReason(
3648+
super.propertyName, super.propertyMember, this.whyNotPromotable,
36583649
{required super.fieldPromotionEnabled});
36593650

36603651
@override
@@ -3674,11 +3665,9 @@ final class PropertyNotPromotedForInherentReason<Type extends Object>
36743665
String get shortName => 'propertyNotPromotedForInherentReason';
36753666

36763667
@override
3677-
R accept<R, Node extends Object, Variable extends Object,
3678-
Type extends Object>(
3679-
NonPromotionReasonVisitor<R, Node, Variable, Type> visitor) =>
3680-
visitor.visitPropertyNotPromotedForInherentReason(
3681-
this as PropertyNotPromotedForInherentReason<Type>);
3668+
R accept<R, Node extends Object, Variable extends Object>(
3669+
NonPromotionReasonVisitor<R, Node, Variable> visitor) =>
3670+
visitor.visitPropertyNotPromotedForInherentReason(this);
36823671
}
36833672

36843673
/// Non-promotion reason describing the situation where an expression was not
@@ -3698,10 +3687,10 @@ final class PropertyNotPromotedForInherentReason<Type extends Object>
36983687
/// promotion being disabled. So this class is used for both scenarios; it is up
36993688
/// to the client to determine the correct non-promotion reason to report to the
37003689
/// user.
3701-
final class PropertyNotPromotedForNonInherentReason<Type extends Object>
3702-
extends PropertyNotPromoted<Type> {
3690+
final class PropertyNotPromotedForNonInherentReason
3691+
extends PropertyNotPromoted {
37033692
PropertyNotPromotedForNonInherentReason(
3704-
super.propertyName, super.propertyMember, super.staticType,
3693+
super.propertyName, super.propertyMember,
37053694
{required super.fieldPromotionEnabled});
37063695

37073696
@override
@@ -3711,11 +3700,9 @@ final class PropertyNotPromotedForNonInherentReason<Type extends Object>
37113700
String get shortName => 'PropertyNotPromotedForNonInherentReason';
37123701

37133702
@override
3714-
R accept<R, Node extends Object, Variable extends Object,
3715-
Type extends Object>(
3716-
NonPromotionReasonVisitor<R, Node, Variable, Type> visitor) =>
3717-
visitor.visitPropertyNotPromotedForNonInherentReason(
3718-
this as PropertyNotPromotedForNonInherentReason<Type>);
3703+
R accept<R, Node extends Object, Variable extends Object>(
3704+
NonPromotionReasonVisitor<R, Node, Variable> visitor) =>
3705+
visitor.visitPropertyNotPromotedForNonInherentReason(this);
37193706
}
37203707

37213708
/// Target for a property access that might undergo promotion.
@@ -4115,9 +4102,8 @@ class ThisNotPromoted extends NonPromotionReason {
41154102
String get shortName => 'thisNotPromoted';
41164103

41174104
@override
4118-
R accept<R, Node extends Object, Variable extends Object,
4119-
Type extends Object>(
4120-
NonPromotionReasonVisitor<R, Node, Variable, Type> visitor) =>
4105+
R accept<R, Node extends Object, Variable extends Object>(
4106+
NonPromotionReasonVisitor<R, Node, Variable> visitor) =>
41214107
visitor.visitThisNotPromoted(this);
41224108
}
41234109

@@ -5924,12 +5910,11 @@ class _FlowAnalysisImpl<Node extends Object, Statement extends Node,
59245910
for (Type type in previouslyPromotedTypes) {
59255911
result[type] = whyNotPromotable == null
59265912
? new PropertyNotPromotedForNonInherentReason(
5927-
reference.propertyName, propertyMember, reference._type,
5913+
reference.propertyName, propertyMember,
59285914
fieldPromotionEnabled: fieldPromotionEnabled)
59295915
: new PropertyNotPromotedForInherentReason(
59305916
reference.propertyName,
59315917
propertyMember,
5932-
reference._type,
59335918
whyNotPromotable,
59345919
fieldPromotionEnabled: fieldPromotionEnabled);
59355920
}

pkg/_fe_analyzer_shared/test/flow_analysis/flow_analysis_test.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11514,9 +11514,8 @@ class _MockNonPromotionReason extends NonPromotionReason {
1151411514
String get shortName => fail('Unexpected call to shortName');
1151511515

1151611516
@override
11517-
R accept<R, Node extends Object, Variable extends Object,
11518-
Type extends Object>(
11519-
NonPromotionReasonVisitor<R, Node, Variable, Type> visitor) =>
11517+
R accept<R, Node extends Object, Variable extends Object>(
11518+
NonPromotionReasonVisitor<R, Node, Variable> visitor) =>
1152011519
fail('Unexpected call to accept');
1152111520
}
1152211521

0 commit comments

Comments
 (0)