@@ -1909,11 +1909,15 @@ bool _isSubtype(universe, Rti s, sEnv, Rti t, tEnv) {
1909
1909
}
1910
1910
}
1911
1911
1912
- if (isEitherFunctionKind (t)) {
1912
+ if (isGenericFunctionKind (t)) {
1913
+ return _isGenericFunctionSubtype (universe, s, sEnv, t, tEnv);
1914
+ }
1915
+
1916
+ if (isFunctionKind (t)) {
1913
1917
return _isFunctionSubtype (universe, s, sEnv, t, tEnv);
1914
1918
}
1915
1919
1916
- if (isEitherFunctionKind (s)) {
1920
+ if (isFunctionKind (s) || isGenericFunctionKind (s)) {
1917
1921
return isFunctionType (t);
1918
1922
}
1919
1923
@@ -1924,25 +1928,25 @@ bool _isSubtype(universe, Rti s, sEnv, Rti t, tEnv) {
1924
1928
return _isSubtypeOfInterface (universe, s, sEnv, tName, tArgs, tEnv);
1925
1929
}
1926
1930
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
+
1927
1946
// TODO(fishythefish): Support required named parameters.
1928
1947
bool _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 ;
1946
1950
1947
1951
Rti sReturnType = Rti ._getReturnType (s);
1948
1952
Rti tReturnType = Rti ._getReturnType (t);
@@ -2136,8 +2140,6 @@ bool isJsInteropType(Rti t) => Rti._getKind(t) == Rti.kindAny;
2136
2140
2137
2141
bool isFutureOrType (Rti t) => Rti ._getKind (t) == Rti .kindFutureOr;
2138
2142
2139
- bool isEitherFunctionKind (Rti t) =>
2140
- isFunctionKind (t) || isGenericFunctionKind (t);
2141
2143
bool isFunctionKind (Rti t) => Rti ._getKind (t) == Rti .kindFunction;
2142
2144
bool isGenericFunctionKind (Rti t) => Rti ._getKind (t) == Rti .kindGenericFunction;
2143
2145
0 commit comments