mirror of
https://github.com/dart-lang/sdk
synced 2024-10-04 16:04:53 +00:00
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:
parent
f6db810b96
commit
ab7f49166e
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue