mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 09:43:57 +00:00
Extension type. Issue 53866. Allow the representation type to be the subtype of implemented extension type.
Bug: https://github.com/dart-lang/sdk/issues/53866 Change-Id: Ic3ac0556695c8ffbb8a4545777ea07a8b52c1e76 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332363 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
a096d44753
commit
059db5cb97
|
@ -1785,11 +1785,15 @@ class ResolutionVisitor extends RecursiveAstVisitor<void> {
|
|||
return;
|
||||
}
|
||||
|
||||
final declaredRepresentation = declaredElement.representation.type;
|
||||
if (typeSystem.isSubtypeOf(declaredRepresentation, type)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// When `type` is an extension type.
|
||||
if (type is InterfaceTypeImpl) {
|
||||
final implementedRepresentation = type.representationType;
|
||||
if (implementedRepresentation != null) {
|
||||
final declaredRepresentation = declaredElement.representation.type;
|
||||
if (!typeSystem.isSubtypeOf(
|
||||
declaredRepresentation,
|
||||
implementedRepresentation,
|
||||
|
@ -1810,14 +1814,11 @@ class ResolutionVisitor extends RecursiveAstVisitor<void> {
|
|||
}
|
||||
}
|
||||
|
||||
final declaredRepresentation = declaredElement.representation.type;
|
||||
if (!typeSystem.isSubtypeOf(declaredRepresentation, type)) {
|
||||
_errorReporter.reportErrorForNode(
|
||||
CompileTimeErrorCode.EXTENSION_TYPE_IMPLEMENTS_NOT_SUPERTYPE,
|
||||
node,
|
||||
[type, declaredRepresentation],
|
||||
);
|
||||
}
|
||||
_errorReporter.reportErrorForNode(
|
||||
CompileTimeErrorCode.EXTENSION_TYPE_IMPLEMENTS_NOT_SUPERTYPE,
|
||||
node,
|
||||
[type, declaredRepresentation],
|
||||
);
|
||||
}
|
||||
|
||||
void _visitIf(IfElementOrStatementImpl node) {
|
||||
|
|
|
@ -44,6 +44,14 @@ extension type B(S3 it) implements A {}
|
|||
class S1 {}
|
||||
class S2 extends S1 {}
|
||||
class S3 extends S2 {}
|
||||
''');
|
||||
}
|
||||
|
||||
test_supertype3() async {
|
||||
await assertNoErrorsInCode('''
|
||||
extension type V1(num _) {}
|
||||
extension type V2(int _) implements V1 {}
|
||||
extension type ET(V2 id) implements V1 {}
|
||||
''');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue