@@ -703,15 +703,17 @@ abstract class _TypeUniverse {
703
703
substituteTypeArgument (type.as < _FutureOrType > ().typeArgument,
704
704
substitutions, rootFunction));
705
705
} else if (type.isInterface) {
706
- _InterfaceType interfaceType = type.as < _InterfaceType > ();
707
- final typeArguments = WasmArray <_Type >.filled (
708
- interfaceType.typeArguments.length, _literal <dynamic >());
709
- for (int i = 0 ; i < typeArguments.length; i++ ) {
710
- typeArguments[i] = substituteTypeArgument (
711
- interfaceType.typeArguments[i], substitutions, rootFunction);
706
+ final interfaceType = type.as < _InterfaceType > ();
707
+ final arguments = interfaceType.typeArguments;
708
+ if (arguments.length == 0 ) return interfaceType;
709
+ final newArguments =
710
+ WasmArray <_Type >.filled (arguments.length, _literal <dynamic >());
711
+ for (int i = 0 ; i < arguments.length; i++ ) {
712
+ newArguments[i] =
713
+ substituteTypeArgument (arguments[i], substitutions, rootFunction);
712
714
}
713
715
return _InterfaceType (interfaceType.classId,
714
- interfaceType.isDeclaredNullable, typeArguments );
716
+ interfaceType.isDeclaredNullable, newArguments );
715
717
} else if (type.isInterfaceTypeParameterType) {
716
718
assert (rootFunction == null );
717
719
return substituteInterfaceTypeParameter (
@@ -885,24 +887,15 @@ abstract class _TypeUniverse {
885
887
_typeRulesSubstitutions[sId][sSuperIndexOfT];
886
888
assert (substitutions.isNotEmpty);
887
889
888
- // If we have empty type arguments then create a list of dynamic type
889
- // arguments.
890
- WasmArray <_Type > typeArgumentsForSubstitution =
891
- substitutions.isNotEmpty && sTypeArguments.isEmpty
892
- ? WasmArray <_Type >.filled (substitutions.length, _literal <dynamic >())
893
- : sTypeArguments;
894
-
895
- // Finally substitute arguments. We must do this upfront so we can normalize
896
- // the type.
897
- // TODO(joshualitt): This process is expensive so we should cache the
898
- // result.
899
- final substituted =
900
- WasmArray <_Type >.filled (substitutions.length, _literal <dynamic >());
901
- for (int i = 0 ; i < substitutions.length; i++ ) {
902
- substituted[i] = substituteTypeArgument (
903
- substitutions[i], typeArgumentsForSubstitution, null );
890
+ // Check arguments.
891
+ for (int i = 0 ; i < tTypeArguments.length; i++ ) {
892
+ final sArgForTClass =
893
+ substituteTypeArgument (substitutions[i], sTypeArguments, null );
894
+ if (! isSubtype (sArgForTClass, sEnv, tTypeArguments[i], tEnv)) {
895
+ return false ;
896
+ }
904
897
}
905
- return areTypeArgumentsSubtypes (substituted, sEnv, tTypeArguments, tEnv) ;
898
+ return true ;
906
899
}
907
900
908
901
static bool isFunctionSubtype (_FunctionType s, _Environment ? sEnv,
0 commit comments