mirror of
https://github.com/dart-lang/sdk
synced 2024-10-06 15:29:45 +00:00
[js_runtime] Never is a bottom in legacy mode
Opt-in code can have Never types even with legacy subtyping. Bug: 41675 Change-Id: I6dbdc064dceeedf0774d10faaca336561b41b7d5 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145561 Commit-Queue: Stephen Adams <sra@google.com> Reviewed-by: Mayank Patke <fishythefish@google.com>
This commit is contained in:
parent
94c81a137b
commit
ef1528aa78
|
@ -2559,11 +2559,7 @@ bool _isSubtype(universe, Rti s, sEnv, Rti t, tEnv) {
|
|||
if (isStrongTopType(s)) return false;
|
||||
|
||||
// Left Bottom:
|
||||
if (isLegacy) {
|
||||
if (isNullType(s)) return true;
|
||||
} else {
|
||||
if (sKind == Rti.kindNever) return true;
|
||||
}
|
||||
if (isBottomType(s)) return true;
|
||||
|
||||
// Left Type Variable Bound 1:
|
||||
bool leftTypeVariable = sKind == Rti.kindGenericFunctionParameter;
|
||||
|
@ -2897,6 +2893,9 @@ bool isStrongTopType(Rti t) {
|
|||
isNullableObjectType(t);
|
||||
}
|
||||
|
||||
bool isBottomType(Rti t) =>
|
||||
Rti._getKind(t) == Rti.kindNever || JS_GET_FLAG('LEGACY') && isNullType(t);
|
||||
|
||||
bool isObjectType(Rti t) => _Utils.isIdentical(t, TYPE_REF<Object>());
|
||||
bool isLegacyObjectType(Rti t) =>
|
||||
_Utils.isIdentical(t, LEGACY_TYPE_REF<Object>());
|
||||
|
|
|
@ -2653,11 +2653,7 @@ bool _isSubtype(Object? universe, Rti s, Object? sEnv, Rti t, Object? tEnv) {
|
|||
if (isStrongTopType(s)) return false;
|
||||
|
||||
// Left Bottom:
|
||||
if (isLegacy) {
|
||||
if (isNullType(s)) return true;
|
||||
} else {
|
||||
if (sKind == Rti.kindNever) return true;
|
||||
}
|
||||
if (isBottomType(s)) return true;
|
||||
|
||||
// Left Type Variable Bound 1:
|
||||
bool leftTypeVariable = sKind == Rti.kindGenericFunctionParameter;
|
||||
|
@ -2993,6 +2989,9 @@ bool isStrongTopType(Rti t) {
|
|||
isNullableObjectType(t);
|
||||
}
|
||||
|
||||
bool isBottomType(Rti t) =>
|
||||
Rti._getKind(t) == Rti.kindNever || JS_GET_FLAG('LEGACY') && isNullType(t);
|
||||
|
||||
bool isObjectType(Rti t) => _Utils.isIdentical(t, TYPE_REF<Object>());
|
||||
bool isLegacyObjectType(Rti t) =>
|
||||
_Utils.isIdentical(t, LEGACY_TYPE_REF<Object>());
|
||||
|
|
|
@ -39,6 +39,7 @@ void runTests() {
|
|||
testInterfaces();
|
||||
testTopTypes();
|
||||
testNull();
|
||||
testBottom();
|
||||
testFutureOr();
|
||||
testFunctions();
|
||||
testGenericFunctions();
|
||||
|
@ -80,6 +81,11 @@ void testNull() {
|
|||
equivalent(nullName, nullName);
|
||||
}
|
||||
|
||||
void testBottom() {
|
||||
String never = '0&';
|
||||
equivalent(nullName, never); // This test is run with legacy subtyping
|
||||
}
|
||||
|
||||
void testFutureOr() {
|
||||
strictSubtype('$futureName<int>', '$futureName<num>');
|
||||
strictSubtype('int', 'int/');
|
||||
|
|
Loading…
Reference in a new issue