Skip to content

Commit 97c2ca5

Browse files
johnniwinthercommit-bot@chromium.org
authored andcommitted
[cfe] Use valid static types and file offsets in collections transformation
Closes #39566 Change-Id: I589d0dd568b3ea939bb1238b1c61fca6867e737e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127320 Reviewed-by: Dmitry Stefantsov <dmitryas@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com>
1 parent daa400b commit 97c2ca5

21 files changed

+651
-251
lines changed

pkg/compiler/lib/src/ir/static_type_base.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,19 +133,17 @@ abstract class StaticTypeBase extends ir.Visitor<ir.DartType> {
133133

134134
@override
135135
ir.DartType visitListLiteral(ir.ListLiteral node) {
136-
return typeEnvironment.literalListType(
137-
node.typeArgument, ir.Nullability.legacy);
136+
return typeEnvironment.listType(node.typeArgument, ir.Nullability.legacy);
138137
}
139138

140139
@override
141140
ir.DartType visitSetLiteral(ir.SetLiteral node) {
142-
return typeEnvironment.literalSetType(
143-
node.typeArgument, ir.Nullability.legacy);
141+
return typeEnvironment.setType(node.typeArgument, ir.Nullability.legacy);
144142
}
145143

146144
@override
147145
ir.DartType visitMapLiteral(ir.MapLiteral node) {
148-
return typeEnvironment.literalMapType(
146+
return typeEnvironment.mapType(
149147
node.keyType, node.valueType, ir.Nullability.legacy);
150148
}
151149

pkg/front_end/lib/src/fasta/kernel/body_builder.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5253,7 +5253,8 @@ class BodyBuilder extends ScopeListener<JumpTarget>
52535253
context: context),
52545254
type: const BottomType())
52555255
..fileOffset = offset,
5256-
expression);
5256+
expression)
5257+
..fileOffset = offset;
52575258
}
52585259

52595260
Expression buildFallThroughError(int charOffset) {

pkg/front_end/lib/src/fasta/kernel/collections.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import 'package:kernel/visitor.dart'
2929
Visitor;
3030

3131
import '../messages.dart'
32-
show templateExpectedAfterButGot, templateExpectedButGot;
32+
show noLength, templateExpectedAfterButGot, templateExpectedButGot;
3333

3434
import '../problems.dart' show getFileUri, unsupported;
3535

@@ -566,7 +566,8 @@ MapEntry convertToMapEntry(Expression element, InferenceHelper helper,
566566
templateExpectedAfterButGot.withArguments(':'),
567567
element.fileOffset,
568568
// TODO(danrubel): what is the length of the expression?
569-
1,
569+
noLength,
570570
),
571-
new NullLiteral());
571+
new NullLiteral()..fileOffset = element.fileOffset)
572+
..fileOffset = element.fileOffset;
572573
}

0 commit comments

Comments
 (0)