Skip to content

Commit d8c4803

Browse files
chloestefantsovaCommit Queue
authored andcommitted
[cfe] Remove legacy raw types from CoreTypes
Change-Id: I9d920cc00ce22900429fd38b6c452483438f94d6 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/397161 Reviewed-by: Johnni Winther <[email protected]> Reviewed-by: Mayank Patke <[email protected]> Commit-Queue: Chloe Stefantsova <[email protected]> Reviewed-by: Nate Biggs <[email protected]>
1 parent cb96256 commit d8c4803

File tree

16 files changed

+91
-831
lines changed

16 files changed

+91
-831
lines changed

pkg/compiler/lib/src/js_model/element_map_impl.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ class JsKernelToElementMap implements JsToElementMap, IrToElementMap {
663663
} else {
664664
data.instantiationToBounds = getInterfaceType(
665665
ir.instantiateToBounds(
666-
coreTypes.legacyRawType(node),
666+
coreTypes.nonNullableRawType(node),
667667
coreTypes.objectClass,
668668
)
669669
as ir.InterfaceType,

pkg/compiler/lib/src/kernel/element_map_impl.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ class KernelToElementMap implements IrToElementMap {
338338
} else {
339339
data.instantiationToBounds = getInterfaceType(
340340
ir.instantiateToBounds(
341-
coreTypes.legacyRawType(node),
341+
coreTypes.nonNullableRawType(node),
342342
coreTypes.objectClass,
343343
)
344344
as ir.InterfaceType,

pkg/dev_compiler/lib/src/kernel/compiler.dart

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,6 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
761761
// See normalization functions in: sdk/lib/_internal/js_shared/lib/rti.dart
762762
if (_isBuildingSdk) {
763763
var prerequisiteRtiTypes = [
764-
_coreTypes.objectLegacyRawType,
765764
_coreTypes.objectNullableRawType,
766765
NeverType.legacy()
767766
];
@@ -4218,8 +4217,7 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
42184217
condition.getStaticType(_staticTypeContext).extensionTypeErasure;
42194218
var jsCondition = _visitExpression(condition);
42204219

4221-
if (conditionType != _coreTypes.boolLegacyRawType &&
4222-
conditionType != _coreTypes.boolNullableRawType &&
4220+
if (conditionType != _coreTypes.boolNullableRawType &&
42234221
conditionType != _coreTypes.boolNonNullableRawType) {
42244222
jsCondition = _runtimeCall('dtest(#)', [jsCondition]);
42254223
} else if (_isNullable(condition)) {
@@ -6996,9 +6994,8 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
69966994
if (_typeRep.isNumber(from) && _typeRep.isNumber(to)) {
69976995
// If `to` is some form of `num`, it should have been filtered above.
69986996

6999-
// * -> double? | double* : no-op
7000-
if (to == _coreTypes.doubleLegacyRawType ||
7001-
to == _coreTypes.doubleNullableRawType) {
6997+
// * -> double? : no-op
6998+
if (to == _coreTypes.doubleNullableRawType) {
70026999
return jsFrom;
70037000
}
70047001

@@ -7015,9 +7012,8 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
70157012
return _runtimeCall('asInt(#)', [jsFrom]);
70167013
}
70177014

7018-
// * -> int? | int* : asNullableInt check
7019-
if (to == _coreTypes.intLegacyRawType ||
7020-
to == _coreTypes.intNullableRawType) {
7015+
// * -> int? : asNullableInt check
7016+
if (to == _coreTypes.intNullableRawType) {
70217017
return _runtimeCall('asNullableInt(#)', [jsFrom]);
70227018
}
70237019
}

pkg/dev_compiler/lib/src/kernel/compiler_new.dart

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,6 @@ class LibraryCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
939939
// See normalization functions in: sdk/lib/_internal/js_shared/lib/rti.dart
940940
if (_isSdkInternalRuntime(_currentLibrary!)) {
941941
var prerequisiteRtiTypes = [
942-
_coreTypes.objectLegacyRawType,
943942
_coreTypes.objectNullableRawType,
944943
NeverType.legacy()
945944
];
@@ -4644,8 +4643,7 @@ class LibraryCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
46444643
condition.getStaticType(_staticTypeContext).extensionTypeErasure;
46454644
var jsCondition = _visitExpression(condition);
46464645

4647-
if (conditionType != _coreTypes.boolLegacyRawType &&
4648-
conditionType != _coreTypes.boolNullableRawType &&
4646+
if (conditionType != _coreTypes.boolNullableRawType &&
46494647
conditionType != _coreTypes.boolNonNullableRawType) {
46504648
jsCondition = _runtimeCall('dtest(#)', [jsCondition]);
46514649
} else if (_isNullable(condition)) {
@@ -7422,8 +7420,7 @@ class LibraryCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
74227420
// If `to` is some form of `num`, it should have been filtered above.
74237421

74247422
// * -> double? | double* : no-op
7425-
if (to == _coreTypes.doubleLegacyRawType ||
7426-
to == _coreTypes.doubleNullableRawType) {
7423+
if (to == _coreTypes.doubleNullableRawType) {
74277424
return jsFrom;
74287425
}
74297426

@@ -7441,8 +7438,7 @@ class LibraryCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
74417438
}
74427439

74437440
// * -> int? | int* : asNullableInt check
7444-
if (to == _coreTypes.intLegacyRawType ||
7445-
to == _coreTypes.intNullableRawType) {
7441+
if (to == _coreTypes.intNullableRawType) {
74467442
return _runtimeCall('asNullableInt(#)', [jsFrom]);
74477443
}
74487444
}

pkg/dev_compiler/lib/src/kernel/nullable_inference.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,7 @@ class NullableInference extends ExpressionVisitor<bool>
181181
if (target == null) return true;
182182
if (target.name.text == 'toString' && receiver != null) {
183183
var receiverType = receiver.getStaticType(_staticTypeContext);
184-
if (receiverType == coreTypes.stringLegacyRawType ||
185-
receiverType == coreTypes.stringNonNullableRawType) {
184+
if (receiverType == coreTypes.stringNonNullableRawType) {
186185
// TODO(nshahan): In unsound null safety the return type of
187186
// `Object.toString()` is still considered nullable. The `class String`
188187
// in dart:core does not explicitly declare `.toString()`, which results

pkg/front_end/lib/src/kernel/constant_evaluator.dart

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3709,7 +3709,7 @@ class ConstantEvaluator implements ExpressionVisitor<Constant> {
37093709
templateConstEvalInvalidBinaryOperandType.withArguments(
37103710
'+',
37113711
receiver,
3712-
typeEnvironment.coreTypes.stringLegacyRawType,
3712+
typeEnvironment.coreTypes.stringNonNullableRawType,
37133713
other.getType(staticTypeContext)));
37143714
case '[]':
37153715
if (enableConstFunctions) {
@@ -3748,7 +3748,7 @@ class ConstantEvaluator implements ExpressionVisitor<Constant> {
37483748
templateConstEvalInvalidBinaryOperandType.withArguments(
37493749
op,
37503750
other,
3751-
typeEnvironment.coreTypes.intLegacyRawType,
3751+
typeEnvironment.coreTypes.intNonNullableRawType,
37523752
other.getType(staticTypeContext)));
37533753
}
37543754
num receiverValue = (receiver as PrimitiveConstant<num>).value;
@@ -3760,7 +3760,7 @@ class ConstantEvaluator implements ExpressionVisitor<Constant> {
37603760
templateConstEvalInvalidBinaryOperandType.withArguments(
37613761
op,
37623762
receiver,
3763-
typeEnvironment.coreTypes.numLegacyRawType,
3763+
typeEnvironment.coreTypes.numNonNullableRawType,
37643764
other.getType(staticTypeContext)));
37653765
}
37663766
} else if (receiver is DoubleConstant) {
@@ -3771,7 +3771,7 @@ class ConstantEvaluator implements ExpressionVisitor<Constant> {
37713771
templateConstEvalInvalidBinaryOperandType.withArguments(
37723772
op,
37733773
receiver,
3774-
typeEnvironment.coreTypes.intLegacyRawType,
3774+
typeEnvironment.coreTypes.intNonNullableRawType,
37753775
receiver.getType(staticTypeContext)));
37763776
}
37773777
if (positionalArguments.length == 0) {
@@ -3793,7 +3793,7 @@ class ConstantEvaluator implements ExpressionVisitor<Constant> {
37933793
templateConstEvalInvalidBinaryOperandType.withArguments(
37943794
op,
37953795
receiver,
3796-
typeEnvironment.coreTypes.numLegacyRawType,
3796+
typeEnvironment.coreTypes.numNonNullableRawType,
37973797
other.getType(staticTypeContext)));
37983798
}
37993799
} else if (receiver is BoolConstant) {
@@ -4674,8 +4674,10 @@ class ConstantEvaluator implements ExpressionVisitor<Constant> {
46744674
// `null is Null` is handled below.
46754675
return typeEnvironment.isSubtypeOf(type, const NullType(),
46764676
SubtypeCheckMode.ignoringNullabilities) ||
4677-
typeEnvironment.isSubtypeOf(typeEnvironment.objectLegacyRawType,
4678-
type, SubtypeCheckMode.ignoringNullabilities);
4677+
typeEnvironment.isSubtypeOf(
4678+
typeEnvironment.objectNullableRawType,
4679+
type,
4680+
SubtypeCheckMode.ignoringNullabilities);
46794681
} else {
46804682
return typeEnvironment.isSubtypeOf(
46814683
const NullType(), type, SubtypeCheckMode.withNullabilities);

pkg/front_end/lib/src/type_inference/standard_bounds.dart

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,6 @@ mixin TypeSchemaStandardBounds on StandardBounds {
3434
return super.getNullabilityAwareStandardLowerBoundInternal(type1, type2);
3535
}
3636

37-
@override
38-
// Coverage-ignore(suite): Not run.
39-
DartType getNullabilityObliviousStandardLowerBoundInternal(type1, type2) {
40-
// For any type T, SLB(?, T) = SLB(T, ?) = T.
41-
if (type1 is UnknownType) {
42-
return type2;
43-
}
44-
if (type2 is UnknownType) {
45-
return type1;
46-
}
47-
return super
48-
.getNullabilityObliviousStandardLowerBoundInternal(type1, type2);
49-
}
50-
5137
@override
5238
DartType getNullabilityAwareStandardUpperBoundInternal(
5339
DartType type1, DartType type2) {
@@ -57,19 +43,4 @@ mixin TypeSchemaStandardBounds on StandardBounds {
5743

5844
return super.getNullabilityAwareStandardUpperBoundInternal(type1, type2);
5945
}
60-
61-
@override
62-
// Coverage-ignore(suite): Not run.
63-
DartType getNullabilityObliviousStandardUpperBoundInternal(
64-
DartType type1, DartType type2) {
65-
// For any type T, SUB(?, T) = SUB(T, ?) = T.
66-
if (type1 is UnknownType) {
67-
return type2;
68-
}
69-
if (type2 is UnknownType) {
70-
return type1;
71-
}
72-
return super
73-
.getNullabilityObliviousStandardUpperBoundInternal(type1, type2);
74-
}
7546
}

pkg/front_end/test/types/legacy_upper_bound_helper.dart

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -61,41 +61,41 @@ abstract class LegacyUpperBoundTest {
6161
Future<void> test_getLegacyLeastUpperBound_expansive() async {
6262
await parseComponent("""
6363
class N<T>;
64-
class C1<T> extends N<N<C1<T*>*>*>;
65-
class C2<T> extends N<N<C2<N<C2<T*>*>*>*>*>;
64+
class C1<T> extends N<N<C1<T>>>;
65+
class C2<T> extends N<N<C2<N<C2<T>>>>>;
6666
""");
6767

6868
// The least upper bound of C1<int> and N<C1<String>> is Object since the
6969
// supertypes are
7070
// {C1<int>, N<N<C1<int>>>, Object} for C1<int> and
7171
// {N<C1<String>>, Object} for N<C1<String>> and
7272
// Object is the most specific type in the intersection of the supertypes.
73-
checkLegacyUp("C1<int*>*", "N<C1<String*>*>*", "Object*");
73+
checkLegacyUp("C1<int>", "N<C1<String>>", "Object");
7474

7575
// The least upper bound of C2<int> and N<C2<String>> is Object since the
7676
// supertypes are
7777
// {C2<int>, N<N<C2<N<C2<int>>>>>, Object} for C2<int> and
7878
// {N<C2<String>>, Object} for N<C2<String>> and
7979
// Object is the most specific type in the intersection of the supertypes.
80-
checkLegacyUp("C2<int*>*", "N<C2<String*>*>*", "Object*");
80+
checkLegacyUp("C2<int>", "N<C2<String>>", "Object");
8181
}
8282

8383
Future<void> test_getLegacyLeastUpperBound_generic() async {
8484
await parseComponent("""
8585
class A;
8686
class B<T> implements A;
8787
class C<U> implements A;
88-
class D<T, U> implements B<T*>, C<U*>;
89-
class E implements D<int*, double*>;
90-
class F implements D<int*, bool*>;
88+
class D<T, U> implements B<T>, C<U>;
89+
class E implements D<int, double>;
90+
class F implements D<int, bool>;
9191
""");
9292

9393
checkLegacyUp(
94-
"D<int*, double*>*", "D<int*, double*>*", "D<int*, double*>*");
95-
checkLegacyUp("D<int*, double*>*", "D<int*, bool*>*", "B<int*>*");
96-
checkLegacyUp("D<int*, double*>*", "D<bool*, double*>*", "C<double*>*");
97-
checkLegacyUp("D<int*, double*>*", "D<bool*, int*>*", "A*");
98-
checkLegacyUp("E*", "F*", "B<int*>*");
94+
"D<int, double>", "D<int, double>", "D<int, double>");
95+
checkLegacyUp("D<int, double>", "D<int, bool>", "B<int>");
96+
checkLegacyUp("D<int, double>", "D<bool, double>", "C<double>");
97+
checkLegacyUp("D<int, double>", "D<bool, int>", "A");
98+
checkLegacyUp("E", "F", "B<int>");
9999
}
100100

101101
Future<void> test_getLegacyLeastUpperBound_nonGeneric() async {
@@ -111,13 +111,13 @@ class H implements C, D, E;
111111
class I implements C, D, E;
112112
""");
113113

114-
checkLegacyUp("A*", "B*", "Object*");
115-
checkLegacyUp("A*", "Object*", "Object*");
116-
checkLegacyUp("Object*", "B*", "Object*");
117-
checkLegacyUp("C*", "D*", "A*");
118-
checkLegacyUp("C*", "A*", "A*");
119-
checkLegacyUp("A*", "D*", "A*");
120-
checkLegacyUp("F*", "G*", "A*");
121-
checkLegacyUp("H*", "I*", "A*");
114+
checkLegacyUp("A", "B", "Object");
115+
checkLegacyUp("A", "Object", "Object");
116+
checkLegacyUp("Object", "B", "Object");
117+
checkLegacyUp("C", "D", "A");
118+
checkLegacyUp("C", "A", "A");
119+
checkLegacyUp("A", "D", "A");
120+
checkLegacyUp("F", "G", "A");
121+
checkLegacyUp("H", "I", "A");
122122
}
123123
}

0 commit comments

Comments
 (0)