mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 21:50:11 +00:00
[ddc] Fix covariant bound checks with new types
Issue: https://github.com/dart-lang/sdk/issues/48585 Change-Id: I7a5d9c412696ea038af8320734790456d4e2880a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306914 Commit-Queue: Nicholas Shahan <nshahan@google.com> Reviewed-by: Mark Zhou <markzipan@google.com>
This commit is contained in:
parent
4f2f3405fb
commit
00d63e7bf9
|
@ -745,9 +745,6 @@ cast(obj, type) {
|
|||
///
|
||||
/// Will produce a warning/error (if enabled) when the subtype passes but would
|
||||
/// fail in sound null safety.
|
||||
///
|
||||
/// Currently only called from _checkAndCall to test type arguments applied to
|
||||
/// dynamic method calls.
|
||||
// TODO(48585) Revise argument types after removing old type representation.
|
||||
@notNull
|
||||
bool _isSubtypeWithWarning(@notNull t1, @notNull t2) {
|
||||
|
|
|
@ -1190,7 +1190,18 @@ bool isType(obj) => JS('', '#[#] === #', obj, _runtimeType, Type);
|
|||
|
||||
void checkTypeBound(
|
||||
@notNull Object type, @notNull Object bound, @notNull String name) {
|
||||
if (!isSubtypeOf(type, bound)) {
|
||||
bool validSubtype;
|
||||
if (JS_GET_FLAG('NEW_RUNTIME_TYPES')) {
|
||||
validSubtype = compileTimeFlag('soundNullSafety')
|
||||
// Check subtype directly in sound mode.
|
||||
? rti.isSubtype(JS_EMBEDDED_GLOBAL('', RTI_UNIVERSE),
|
||||
JS<rti.Rti>('!', '#', type), JS<rti.Rti>('!', '#', bound))
|
||||
// Check subtype but issue warnings/errors in weak mode.
|
||||
: _isSubtypeWithWarning(type, bound);
|
||||
} else {
|
||||
validSubtype = isSubtypeOf(type, bound);
|
||||
}
|
||||
if (!validSubtype) {
|
||||
throwTypeError('type `$type` does not extend `$bound` of `$name`.');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue