Skip to content

Commit 27f18db

Browse files
kallentuCommit Queue
authored andcommitted
[cfe] Dot Shorthands: Fix bug with property fileOffsets.
Surfaced from this co19 test crashing because of an assert when making a null-aware element. The `fileOffset` for static tearoffs and static gets were not being properly set and caused the crash. This CL simply sets the `fileOffset` on those expressions and existing tests should pass. https://github.com/dart-lang/co19/blob/2c7f9a6a379cfc49b3e9019d1f616d7ec9edd766/LanguageFeatures/Static-access-shorthand/non_ambiguity_A02_t01.dart Bug: #59758 Change-Id: I7b81f0ee11d8a9458154f1148e92523d1ad8be99 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/420840 Reviewed-by: Chloe Stefantsova <[email protected]> Commit-Queue: Kallen Tu <[email protected]>
1 parent e7e07f7 commit 27f18db

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

pkg/front_end/lib/src/type_inference/inference_visitor.dart

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12284,18 +12284,21 @@ class InferenceVisitorImpl extends InferenceVisitorBase
1228412284
ExpressionInferenceResult expressionInferenceResult;
1228512285
switch (member) {
1228612286
case Field():
12287-
expressionInferenceResult =
12288-
inferExpression(new StaticGet(member), cachedContext);
12287+
Expression staticGet = new StaticGet(member)
12288+
..fileOffset = node.fileOffset;
12289+
expressionInferenceResult = inferExpression(staticGet, cachedContext);
1228912290
case Procedure():
1229012291
if (member.isGetter) {
12291-
expressionInferenceResult =
12292-
inferExpression(new StaticGet(member), cachedContext);
12292+
Expression staticGet = new StaticGet(member)
12293+
..fileOffset = node.fileOffset;
12294+
expressionInferenceResult = inferExpression(staticGet, cachedContext);
1229312295
} else {
1229412296
// Method tearoffs.
1229512297
DartType type =
1229612298
member.function.computeFunctionType(Nullability.nonNullable);
12297-
return instantiateTearOff(
12298-
type, typeContext, new StaticTearOff(member));
12299+
Expression tearOff = new StaticTearOff(member)
12300+
..fileOffset = node.fileOffset;
12301+
return instantiateTearOff(type, typeContext, tearOff);
1229912302
}
1230012303
case Constructor():
1230112304
case null:
@@ -12317,13 +12320,15 @@ class InferenceVisitorImpl extends InferenceVisitorBase
1231712320
if (constructor is Constructor) {
1231812321
DartType type = constructor.function
1231912322
.computeFunctionType(Nullability.nonNullable);
12320-
return instantiateTearOff(
12321-
type, typeContext, new ConstructorTearOff(constructor));
12323+
Expression tearOff = new ConstructorTearOff(constructor)
12324+
..fileOffset = node.fileOffset;
12325+
return instantiateTearOff(type, typeContext, tearOff);
1232212326
} else if (constructor is Procedure) {
1232312327
DartType type = constructor.function
1232412328
.computeFunctionType(Nullability.nonNullable);
12325-
return instantiateTearOff(
12326-
type, typeContext, new StaticTearOff(constructor));
12329+
Expression tearOff = new StaticTearOff(constructor)
12330+
..fileOffset = node.fileOffset;
12331+
return instantiateTearOff(type, typeContext, tearOff);
1232712332
}
1232812333
}
1232912334

0 commit comments

Comments
 (0)