mirror of
https://github.com/dart-lang/sdk
synced 2024-10-02 23:49:17 +00:00
[dart2wasm] Fix isSubtype
case of type parameter vs FutureOr
Change-Id: I3b6186426af231473fe2d93afcc787ffef6d3a97 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/319760 Commit-Queue: Aske Simon Christensen <askesc@google.com> Reviewed-by: Joshua Litt <joshualitt@google.com>
This commit is contained in:
parent
64dd387d09
commit
1e3689cfa7
|
@ -993,6 +993,16 @@ class _TypeUniverse {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// A function type parameter type is a subtype of `FutureOr<T>` if it's a
|
||||
// subtype of `T`.
|
||||
if (t.isFutureOr) {
|
||||
_FutureOrType tFutureOr = t.as<_FutureOrType>();
|
||||
if (isSubtype(s, sEnv, tFutureOr.typeArgument, tEnv)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, compare the bound to the other type.
|
||||
_Type bound = sEnvAdjusted.lookupAdjusted(sTypeParam);
|
||||
return isSubtype(bound, sEnvAdjusted, t, tEnv);
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
// Copyright (c) 2023, 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 'dart:async';
|
||||
import 'package:expect/expect.dart';
|
||||
|
||||
typedef LX = X Function<X, Y extends X>(X);
|
||||
typedef LY = Y Function<X, Y extends X>(X);
|
||||
typedef LFX = FutureOr<X> Function<X, Y extends X>(X);
|
||||
typedef LFY = FutureOr<Y> Function<X, Y extends X>(X);
|
||||
|
||||
typedef RX = X Function<X, Y extends X>(Y);
|
||||
typedef RY = Y Function<X, Y extends X>(Y);
|
||||
typedef RFX = FutureOr<X> Function<X, Y extends X>(Y);
|
||||
typedef RFY = FutureOr<Y> Function<X, Y extends X>(Y);
|
||||
|
||||
void main() {
|
||||
Expect.subtype<LX, RX>();
|
||||
Expect.notSubtype<LX, RY>();
|
||||
Expect.subtype<LX, RFX>();
|
||||
Expect.notSubtype<LX, RFY>();
|
||||
Expect.subtype<LY, RX>();
|
||||
Expect.subtype<LY, RY>();
|
||||
Expect.subtype<LY, RFX>();
|
||||
Expect.subtype<LY, RFY>();
|
||||
Expect.notSubtype<LFX, RX>();
|
||||
Expect.notSubtype<LFX, RY>();
|
||||
Expect.subtype<LFX, RFX>();
|
||||
Expect.notSubtype<LFX, RFY>();
|
||||
Expect.notSubtype<LFY, RX>();
|
||||
Expect.notSubtype<LFY, RY>();
|
||||
Expect.subtype<LFY, RFX>();
|
||||
Expect.subtype<LFY, RFY>();
|
||||
}
|
Loading…
Reference in a new issue