Disallow subtyping class Record.

Change-Id: I5f71e47cc0c60444cf0c7baebb4e9e9d3f105ef0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/257921
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
This commit is contained in:
Konstantin Shcheglov 2022-09-06 21:04:56 +00:00 committed by Commit Bot
parent ed5587dc2d
commit 6546d85c50
4 changed files with 25 additions and 0 deletions

View file

@ -31,6 +31,7 @@ const Set<String> _nonSubtypableDartCoreClassNames = {
'int',
'Null',
'num',
'Record',
'String',
};

View file

@ -92,6 +92,14 @@ class A extends num {}
]);
}
test_class_Record() async {
await assertErrorsInCode('''
class A extends Record {}
''', [
error(CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, 16, 6),
]);
}
test_class_String() async {
await assertErrorsInCode('''
class A extends String {}

View file

@ -116,6 +116,14 @@ class A implements num {}
]);
}
test_class_Record() async {
await assertErrorsInCode('''
class A implements Record {}
''', [
error(CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS, 19, 6),
]);
}
test_class_String() async {
await assertErrorsInCode('''
class A implements String {}

View file

@ -82,6 +82,14 @@ class A extends Object with num {}
]);
}
test_class_Record() async {
await assertErrorsInCode('''
class A extends Object with Record {}
''', [
error(CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS, 28, 6),
]);
}
test_class_String() async {
await assertErrorsInCode('''
class A extends Object with String {}