Skip to content

Commit 00d63e7

Browse files
nshahanCommit Queue
authored and
Commit Queue
committed
[ddc] Fix covariant bound checks with new types
Issue: #48585 Change-Id: I7a5d9c412696ea038af8320734790456d4e2880a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306914 Commit-Queue: Nicholas Shahan <[email protected]> Reviewed-by: Mark Zhou <[email protected]>
1 parent 4f2f340 commit 00d63e7

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -745,9 +745,6 @@ cast(obj, type) {
745745
///
746746
/// Will produce a warning/error (if enabled) when the subtype passes but would
747747
/// fail in sound null safety.
748-
///
749-
/// Currently only called from _checkAndCall to test type arguments applied to
750-
/// dynamic method calls.
751748
// TODO(48585) Revise argument types after removing old type representation.
752749
@notNull
753750
bool _isSubtypeWithWarning(@notNull t1, @notNull t2) {

sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,18 @@ bool isType(obj) => JS('', '#[#] === #', obj, _runtimeType, Type);
11901190

11911191
void checkTypeBound(
11921192
@notNull Object type, @notNull Object bound, @notNull String name) {
1193-
if (!isSubtypeOf(type, bound)) {
1193+
bool validSubtype;
1194+
if (JS_GET_FLAG('NEW_RUNTIME_TYPES')) {
1195+
validSubtype = compileTimeFlag('soundNullSafety')
1196+
// Check subtype directly in sound mode.
1197+
? rti.isSubtype(JS_EMBEDDED_GLOBAL('', RTI_UNIVERSE),
1198+
JS<rti.Rti>('!', '#', type), JS<rti.Rti>('!', '#', bound))
1199+
// Check subtype but issue warnings/errors in weak mode.
1200+
: _isSubtypeWithWarning(type, bound);
1201+
} else {
1202+
validSubtype = isSubtypeOf(type, bound);
1203+
}
1204+
if (!validSubtype) {
11941205
throwTypeError('type `$type` does not extend `$bound` of `$name`.');
11951206
}
11961207
}

0 commit comments

Comments
 (0)