mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 00:09:49 +00:00
[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 https://github.com/dart-lang/sdk/issues/46816 Change-Id: Ic0f1b4a9fdf0f4c9ae65c8c372d12c1e51ad8050 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209265 Reviewed-by: Tess Strickland <sstrickl@google.com> Commit-Queue: Alexander Markov <alexmarkov@google.com>
This commit is contained in:
parent
9b67ccf7d8
commit
3097b72b2b
|
@ -8949,9 +8949,11 @@ bool FunctionType::HasSameTypeParametersAndBounds(const FunctionType& other,
|
|||
}
|
||||
}
|
||||
}
|
||||
// Compare flags (IsGenericCovariantImpl).
|
||||
if (!Array::Equals(type_params.flags(), other_type_params.flags())) {
|
||||
return false;
|
||||
if (kind != TypeEquality::kInSubtypeTest) {
|
||||
// Compare flags (IsGenericCovariantImpl).
|
||||
if (!Array::Equals(type_params.flags(), other_type_params.flags())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
18
tests/language/regress/regress46816_test.dart
Normal file
18
tests/language/regress/regress46816_test.dart
Normal file
|
@ -0,0 +1,18 @@
|
|||
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
|
||||
class A<X extends num> {
|
||||
void f<Y extends X>(Y y) {}
|
||||
}
|
||||
|
||||
typedef Func = void Function<Y extends int>(Y);
|
||||
|
||||
main() {
|
||||
A<num> a = new A<int>();
|
||||
dynamic f = (a as A<int>).f;
|
||||
Expect.isTrue(f is Func);
|
||||
print(f as Func);
|
||||
}
|
20
tests/language_2/regress/regress46816_test.dart
Normal file
20
tests/language_2/regress/regress46816_test.dart
Normal file
|
@ -0,0 +1,20 @@
|
|||
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// @dart=2.9
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
|
||||
class A<X extends num> {
|
||||
void f<Y extends X>(Y y) {}
|
||||
}
|
||||
|
||||
typedef Func = void Function<Y extends int>(Y);
|
||||
|
||||
main() {
|
||||
A<num> a = new A<int>();
|
||||
dynamic f = (a as A<int>).f;
|
||||
Expect.isTrue(f is Func);
|
||||
print(f as Func);
|
||||
}
|
Loading…
Reference in a new issue