@@ -1909,11 +1909,15 @@ bool _isSubtype(universe, Rti s, sEnv, Rti t, tEnv) {
19091909 }
19101910 }
19111911
1912- if (isEitherFunctionKind (t)) {
1912+ if (isGenericFunctionKind (t)) {
1913+ return _isGenericFunctionSubtype (universe, s, sEnv, t, tEnv);
1914+ }
1915+
1916+ if (isFunctionKind (t)) {
19131917 return _isFunctionSubtype (universe, s, sEnv, t, tEnv);
19141918 }
19151919
1916- if (isEitherFunctionKind (s)) {
1920+ if (isFunctionKind (s) || isGenericFunctionKind (s)) {
19171921 return isFunctionType (t);
19181922 }
19191923
@@ -1924,25 +1928,25 @@ bool _isSubtype(universe, Rti s, sEnv, Rti t, tEnv) {
19241928 return _isSubtypeOfInterface (universe, s, sEnv, tName, tArgs, tEnv);
19251929}
19261930
1931+ bool _isGenericFunctionSubtype (universe, Rti s, sEnv, Rti t, tEnv) {
1932+ assert (isGenericFunctionKind (t));
1933+ if (! isGenericFunctionKind (s)) return false ;
1934+
1935+ var sBounds = Rti ._getGenericFunctionBounds (s);
1936+ var tBounds = Rti ._getGenericFunctionBounds (t);
1937+ if (! typesEqual (sBounds, tBounds)) return false ;
1938+ // TODO(fishythefish): Extend [sEnv] and [tEnv] with bindings for the [s]
1939+ // and [t] type parameters to enable checking the bound against
1940+ // non-type-parameter terms.
1941+
1942+ return _isFunctionSubtype (universe, Rti ._getGenericFunctionBase (s), sEnv,
1943+ Rti ._getGenericFunctionBase (t), tEnv);
1944+ }
1945+
19271946// TODO(fishythefish): Support required named parameters.
19281947bool _isFunctionSubtype (universe, Rti s, sEnv, Rti t, tEnv) {
1929- assert (isEitherFunctionKind (t));
1930- if (! isEitherFunctionKind (s)) return false ;
1931-
1932- if (isGenericFunctionKind (s)) {
1933- if (! isGenericFunctionKind (t)) return false ;
1934- var sBounds = Rti ._getGenericFunctionBounds (s);
1935- var tBounds = Rti ._getGenericFunctionBounds (t);
1936- if (! typesEqual (sBounds, tBounds)) return false ;
1937- // TODO(fishythefish): Extend [sEnv] and [tEnv] with bindings for the [s]
1938- // and [t] type parameters to enable checking the bound against
1939- // non-type-parameter terms.
1940-
1941- s = Rti ._getGenericFunctionBase (s);
1942- t = Rti ._getGenericFunctionBase (t);
1943- } else if (isGenericFunctionKind (t)) {
1944- return false ;
1945- }
1948+ assert (isFunctionKind (t));
1949+ if (! isFunctionKind (s)) return false ;
19461950
19471951 Rti sReturnType = Rti ._getReturnType (s);
19481952 Rti tReturnType = Rti ._getReturnType (t);
@@ -2136,8 +2140,6 @@ bool isJsInteropType(Rti t) => Rti._getKind(t) == Rti.kindAny;
21362140
21372141bool isFutureOrType (Rti t) => Rti ._getKind (t) == Rti .kindFutureOr;
21382142
2139- bool isEitherFunctionKind (Rti t) =>
2140- isFunctionKind (t) || isGenericFunctionKind (t);
21412143bool isFunctionKind (Rti t) => Rti ._getKind (t) == Rti .kindFunction;
21422144bool isGenericFunctionKind (Rti t) => Rti ._getKind (t) == Rti .kindGenericFunction;
21432145
0 commit comments