Extension types. Report deferred superinterfaces.

Change-Id: Ie767ce5e96953d83edeeb3331bea0aecfc5f51a1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/319904
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
Konstantin Shcheglov 2023-08-10 23:17:35 +00:00 committed by Commit Queue
parent f6db810b96
commit ab7f49166e
2 changed files with 73 additions and 0 deletions

View file

@ -712,6 +712,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
_checkForNonCovariantTypeParameterPositionInRepresentationType(
node, element);
_checkForExtensionTypeRepresentationDependsOnItself(node, element);
_checkForExtensionTypeImplementsDeferred(node);
_checkForExtensionTypeImplementsItself(node, element);
_checkForExtensionTypeMemberConflicts(
node: node,
@ -2916,6 +2917,22 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
}
}
void _checkForExtensionTypeImplementsDeferred(
ExtensionTypeDeclarationImpl node,
) {
final clause = node.implementsClause;
if (clause == null) {
return;
}
for (final type in clause.interfaces) {
_checkForExtendsOrImplementsDeferredClass(
type,
CompileTimeErrorCode.IMPLEMENTS_DEFERRED_CLASS,
);
}
}
void _checkForExtensionTypeImplementsItself(
ExtensionTypeDeclarationImpl node,
ExtensionTypeElementImpl element,

View file

@ -106,6 +106,62 @@ ImplementsClause
''');
}
test_extensionType_implements_class() async {
newFile('$testPackageLibPath/a.dart', '''
class A {}
''');
await assertErrorsInCode('''
import 'a.dart' deferred as a;
extension type B(a.A it) implements a.A {}
''', [
error(CompileTimeErrorCode.IMPLEMENTS_DEFERRED_CLASS, 67, 3),
]);
final node = findNode.singleImplementsClause;
assertResolvedNodeText(node, r'''
ImplementsClause
implementsKeyword: implements
interfaces
NamedType
importPrefix: ImportPrefixReference
name: a
period: .
element: self::@prefix::a
name: A
element: package:test/a.dart::@class::A
type: A
''');
}
test_extensionType_implements_extensionType() async {
newFile('$testPackageLibPath/a.dart', '''
extension type A(int it) {}
''');
await assertErrorsInCode('''
import 'a.dart' deferred as a;
extension type B(int it) implements a.A {}
''', [
error(CompileTimeErrorCode.IMPLEMENTS_DEFERRED_CLASS, 67, 3),
]);
final node = findNode.singleImplementsClause;
assertResolvedNodeText(node, r'''
ImplementsClause
implementsKeyword: implements
interfaces
NamedType
importPrefix: ImportPrefixReference
name: a
period: .
element: self::@prefix::a
name: A
element: package:test/a.dart::@extensionType::A
type: A
''');
}
test_mixin() async {
await assertErrorsInCode(r'''
import 'dart:math' deferred as math;