Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 3097b72

Browse files
alexmarkovcommit-bot@chromium.org
authored andcommitted
[vm] Ignore differences in generic-covariant-impl flags of type parameters when doing a subtype check
We might get different flags on lhs and rhs of a subtype check as lhs might come from a tear-off which has generic-covariant-impl type parameters and rhs is a standalone function type. TEST=language/regress/regress46816_test Fixes dart-lang/sdk#46816 Change-Id: Ic0f1b4a9fdf0f4c9ae65c8c372d12c1e51ad8050 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209265 Reviewed-by: Tess Strickland <[email protected]> Commit-Queue: Alexander Markov <[email protected]>
1 parent 9b67ccf commit 3097b72

File tree

3 files changed

+43
-3
lines changed

3 files changed

+43
-3
lines changed

runtime/vm/object.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8949,9 +8949,11 @@ bool FunctionType::HasSameTypeParametersAndBounds(const FunctionType& other,
89498949
}
89508950
}
89518951
}
8952-
// Compare flags (IsGenericCovariantImpl).
8953-
if (!Array::Equals(type_params.flags(), other_type_params.flags())) {
8954-
return false;
8952+
if (kind != TypeEquality::kInSubtypeTest) {
8953+
// Compare flags (IsGenericCovariantImpl).
8954+
if (!Array::Equals(type_params.flags(), other_type_params.flags())) {
8955+
return false;
8956+
}
89558957
}
89568958
}
89578959
return true;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'package:expect/expect.dart';
6+
7+
class A<X extends num> {
8+
void f<Y extends X>(Y y) {}
9+
}
10+
11+
typedef Func = void Function<Y extends int>(Y);
12+
13+
main() {
14+
A<num> a = new A<int>();
15+
dynamic f = (a as A<int>).f;
16+
Expect.isTrue(f is Func);
17+
print(f as Func);
18+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// @dart=2.9
6+
7+
import 'package:expect/expect.dart';
8+
9+
class A<X extends num> {
10+
void f<Y extends X>(Y y) {}
11+
}
12+
13+
typedef Func = void Function<Y extends int>(Y);
14+
15+
main() {
16+
A<num> a = new A<int>();
17+
dynamic f = (a as A<int>).f;
18+
Expect.isTrue(f is Func);
19+
print(f as Func);
20+
}

0 commit comments

Comments
 (0)