diff --git a/pkg/dart2wasm/lib/types.dart b/pkg/dart2wasm/lib/types.dart index 44daee549b0..9a9f3df4349 100644 --- a/pkg/dart2wasm/lib/types.dart +++ b/pkg/dart2wasm/lib/types.dart @@ -611,23 +611,16 @@ class Types { } if (type.typeArguments.any((t) => t is! DynamicType)) { - // Type has at least one type argument that is not `dynamic`. - // - // In cases like `x is List` where `x : Iterable` (tested-against - // type is a subtype of the operand's static type and the types have same - // number of type arguments), it is not necessary to test the type - // arguments. + // If the tested-against type as an instance of the static operand type + // has the same type arguments as the static operand type, it is not + // necessary to test the type arguments. Class cls = translator.classForType(operandType); InterfaceType? base = translator.hierarchy .getTypeAsInstanceOf(type, cls, isNonNullableByDefault: codeGen.member.enclosingLibrary.isNonNullableByDefault) ?.withDeclaredNullability(operandType.declaredNullability); - - final sameNumTypeParams = operandType is InterfaceType && - operandType.typeArguments.length == type.typeArguments.length; - - if (!(sameNumTypeParams && base == operandType)) { + if (base != operandType) { makeType(codeGen, type); codeGen.call(translator.isSubtype.reference); _endPotentiallyNullableBlock(); diff --git a/tests/web/wasm/static_interop_test.dart b/tests/web/wasm/static_interop_test.dart index 3c66bd9d27e..25b7e7c54d8 100644 --- a/tests/web/wasm/static_interop_test.dart +++ b/tests/web/wasm/static_interop_test.dart @@ -311,7 +311,7 @@ extension AnonymousJSClassExtension on AnonymousJSClass { external String? get bleep; external int? get goo; external int? get ooo; - external List? saz; + external List? saz; external List? zoo; }