Skip to content

Commit 7575235

Browse files
scheglovcommit-bot@chromium.org
authored andcommitted
Test that function types use mutual subtyping for type parameter bounds.
For dart-lang/language#807 Change-Id: Ife86fa35fda20347437391d742a4432518d7898a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135350 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent 95aade3 commit 7575235

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

pkg/analyzer/lib/src/generated/type_system.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1916,8 +1916,6 @@ class Dart2TypeSystem extends TypeSystem {
19161916
// The bounds of type parameters must be equal.
19171917
var freshTypeFormalTypes =
19181918
FunctionTypeImpl.relateTypeFormals(f, g, (t, s, _, __) {
1919-
// Type parameter bounds are invariant.
1920-
// TODO(scheglov) We do this for top types, but the spec says explicitly.
19211919
return isSubtypeOf2(t, s) && isSubtypeOf2(s, t);
19221920
});
19231921
if (freshTypeFormalTypes == null) {

pkg/analyzer/test/src/dart/element/subtype_test.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,6 +1712,24 @@ class SubtypeTest extends _SubtypingTestBase {
17121712
);
17131713
}
17141714

1715+
test_functionType_73() {
1716+
var E0 = typeParameter('E0', bound: objectNone);
1717+
var E1 = typeParameter('E1', bound: futureOrNone(objectNone));
1718+
1719+
isSubtype(
1720+
functionTypeNone(
1721+
typeFormals: [E0],
1722+
returnType: voidNone,
1723+
),
1724+
functionTypeNone(
1725+
typeFormals: [E1],
1726+
returnType: voidNone,
1727+
),
1728+
strT0: 'void Function<E0 extends Object>()',
1729+
strT1: 'void Function<E1 extends FutureOr<Object>>()',
1730+
);
1731+
}
1732+
17151733
test_functionType_generic_nested() {
17161734
var E0 = typeParameter('E0');
17171735
var F0 = typeParameter('F0');

0 commit comments

Comments
 (0)