Skip to content

Commit aff3f42

Browse files
scheglovCommit Queue
authored and
Commit Queue
committed
Records. Support for RecordTypeAnnotation in constants.
Change-Id: Ic5e39dc6bdf8740d190346dad67197f445407715 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349302 Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent bc2a1ef commit aff3f42

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

pkg/analyzer/lib/src/dart/constant/evaluation.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,6 +1244,15 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
12441244
typeSystem, nodeType, RecordState(positionalFields, namedFields));
12451245
}
12461246

1247+
@override
1248+
Constant? visitRecordTypeAnnotation(RecordTypeAnnotation node) {
1249+
return DartObjectImpl(
1250+
typeSystem,
1251+
_typeProvider.typeType,
1252+
TypeState(node.type),
1253+
);
1254+
}
1255+
12471256
@override
12481257
Constant visitSetOrMapLiteral(SetOrMapLiteral node) {
12491258
// Note: due to dartbug.com/33441, it's possible that a set/map literal

pkg/analyzer/test/src/dart/constant/evaluation_test.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,17 @@ void f(Object? x) {
946946
''');
947947
}
948948

949+
test_recordTypeAnnotation() async {
950+
await assertNoErrorsInCode(r'''
951+
const a = ('',) is (int,);
952+
''');
953+
final result = _topLevelVar('a');
954+
assertDartObjectText(result, r'''
955+
bool false
956+
variable: self::@variable::a
957+
''');
958+
}
959+
949960
test_typeParameter() async {
950961
await assertErrorsInCode('''
951962
class A<X> {

0 commit comments

Comments
 (0)