[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>
diff --git a/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart b/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart
index 6c1caa8..4cc8552 100644
--- a/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart
+++ b/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart
@@ -745,9 +745,6 @@
///
/// 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) {
diff --git a/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart b/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart
index 53184f4..f62a2d8 100644
--- a/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart
+++ b/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart
@@ -1190,7 +1190,18 @@
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`.');
}
}