Skip to content

Commit 39810ff

Browse files
chloestefantsovaCommit Queue
authored andcommitted
[cfe] Cleanup interface of subtype queries
Under the hood, there is no difference between `isSubtypeWhenUsingNullabilities` and `isSubtypeWhenIgnoringNullabilities` by now. This CL makes the corresponding renames and removals in the CFE and its clients. TEST=existing Change-Id: I22060c29834179c30ba62562aa254146b1d7530d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433480 Reviewed-by: Ömer Ağacan <[email protected]> Reviewed-by: Johnni Winther <[email protected]> Reviewed-by: Mayank Patke <[email protected]> Reviewed-by: Alexander Markov <[email protected]>
1 parent d194fce commit 39810ff

File tree

54 files changed

+3473
-2447
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+3473
-2447
lines changed

pkg/_js_interop_checks/lib/src/transformations/js_util_optimizer.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1228,7 +1228,6 @@ class ExtensionIndex {
12281228
_typeEnvironment.isSubtypeOf(
12291229
type,
12301230
InterfaceType(_javaScriptObject, Nullability.nullable),
1231-
SubtypeCheckMode.withNullabilities,
12321231
))) {
12331232
return _coreInteropTypeIndex[reference] = reference;
12341233
}

pkg/_js_interop_checks/lib/src/transformations/static_interop_mock_validator.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,6 @@ class StaticInteropMockValidator {
264264
return _typeEnvironment.isSubtypeOf(
265265
typeParameterResolver.resolve(dartType),
266266
typeParameterResolver.resolve(interopType),
267-
SubtypeCheckMode.withNullabilities,
268267
);
269268
}
270269

pkg/compiler/lib/src/ir/impact_data.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,6 @@ class ImpactBuilder extends ir.RecursiveVisitor implements ImpactRegistry {
305305
final isCalculatedTypeSubtype = typeEnvironment.isSubtypeOf(
306306
operandType,
307307
node.type,
308-
ir.SubtypeCheckMode.withNullabilities,
309308
);
310309
if (!isCalculatedTypeSubtype) {
311310
// Only register needed cast.

pkg/compiler/lib/src/ssa/builder.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7607,7 +7607,6 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault<void>
76077607
.computeTypeShapeCheckSufficiency(
76087608
expressionStaticType: operandType,
76097609
checkTargetType: checkedType,
7610-
subtypeCheckMode: ir.SubtypeCheckMode.withNullabilities,
76117610
);
76127611

76137612
// If `true` the caller only needs to check nullabillity and the actual

pkg/dart2bytecode/lib/bytecode_generator.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import 'package:kernel/target/targets.dart' show Target;
1515
import 'package:kernel/type_algebra.dart'
1616
show Substitution, containsTypeParameter;
1717
import 'package:kernel/type_environment.dart'
18-
show StatefulStaticTypeContext, SubtypeCheckMode, TypeEnvironment;
18+
show StatefulStaticTypeContext, TypeEnvironment;
1919

2020
import 'package:vm/transformations/pragma.dart';
2121

@@ -2322,9 +2322,7 @@ class BytecodeGenerator extends RecursiveVisitor {
23222322
asm.emitPushConstant(
23232323
name != null ? cp.addName(name) : cp.addString(message!));
23242324
bool isIntOk = typeEnvironment.isSubtypeOf(
2325-
typeEnvironment.coreTypes.intNonNullableRawType,
2326-
type,
2327-
SubtypeCheckMode.ignoringNullabilities);
2325+
typeEnvironment.coreTypes.intNonNullableRawType, type);
23282326
int subtypeTestCacheCpIndex = cp.addSubtypeTestCache();
23292327
asm.emitAssertAssignable(isIntOk ? 1 : 0, subtypeTestCacheCpIndex);
23302328
}

pkg/dart2wasm/lib/code_generator.dart

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4348,14 +4348,10 @@ class SwitchInfo {
43484348
// required. See #60375 for more details.
43494349
bool canInvokeTypeEquality() =>
43504350
translator.typeEnvironment.isSubtypeOf(
4351-
switchExprType,
4352-
translator.coreTypes.typeNullableRawType,
4353-
SubtypeCheckMode.withNullabilities) ||
4351+
switchExprType, translator.coreTypes.typeNullableRawType) ||
43544352
node.cases.expand((c) => c.expressions).any((e) =>
4355-
translator.typeEnvironment.isSubtypeOf(
4356-
codeGen.dartTypeOf(e),
4357-
translator.coreTypes.typeNonNullableRawType,
4358-
SubtypeCheckMode.withNullabilities));
4353+
translator.typeEnvironment.isSubtypeOf(codeGen.dartTypeOf(e),
4354+
translator.coreTypes.typeNonNullableRawType));
43594355

43604356
if (node.cases.every((c) =>
43614357
c.expressions.isEmpty && c.isDefault ||

pkg/dart2wasm/lib/compile.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,7 @@ void _patchMainTearOffs(CoreTypes coreTypes, Component component) {
375375

376376
final typeEnv =
377377
TypeEnvironment(coreTypes, ClassHierarchy(component, coreTypes));
378-
bool mainHasType(DartType type) => typeEnv.isSubtypeOf(
379-
mainMethodType, type, SubtypeCheckMode.withNullabilities);
378+
bool mainHasType(DartType type) => typeEnv.isSubtypeOf(mainMethodType, type);
380379

381380
final internalLib = coreTypes.index.getLibrary('dart:_internal');
382381
(Procedure, DartType) lookupAndInitialize(String name) {

pkg/dart2wasm/lib/intrinsics.dart

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import 'package:kernel/ast.dart';
66
import 'package:kernel/core_types.dart';
7-
import 'package:kernel/type_environment.dart';
87
import 'package:wasm_builder/wasm_builder.dart' as w;
98

109
import 'abi.dart' show kWasmAbiEnumIndex;
@@ -1072,10 +1071,8 @@ class Intrinsifier {
10721071
}
10731072

10741073
bool canBeValueType(DartType type) =>
1075-
translator.typeEnvironment.isSubtypeOf(
1076-
doubleType, type, SubtypeCheckMode.withNullabilities) ||
1077-
translator.typeEnvironment
1078-
.isSubtypeOf(intType, type, SubtypeCheckMode.withNullabilities);
1074+
translator.typeEnvironment.isSubtypeOf(doubleType, type) ||
1075+
translator.typeEnvironment.isSubtypeOf(intType, type);
10791076

10801077
if (!canBeValueType(firstType) || !canBeValueType(secondType)) {
10811078
final nullableEqRefType = w.RefType.eq(nullable: true);

pkg/dart2wasm/lib/js/util.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -491,9 +491,7 @@ class CoreTypesUtil {
491491

492492
for (final entry in _jsifyMap.entries) {
493493
if (typeEnv.isSubtypeOf(
494-
valueType,
495-
InterfaceType(entry.key, Nullability.nonNullable),
496-
SubtypeCheckMode.withNullabilities)) {
494+
valueType, InterfaceType(entry.key, Nullability.nonNullable))) {
497495
return entry.value;
498496
}
499497
}

pkg/dart2wasm/lib/translator.dart

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,9 +1506,7 @@ class Translator with KernelNodes {
15061506

15071507
// Check that type of the receiver is a subtype of
15081508
if (!typeEnvironment.isSubtypeOf(
1509-
lambdaDartType,
1510-
node.receiver.getStaticType(typeContext),
1511-
SubtypeCheckMode.withNullabilities)) {
1509+
lambdaDartType, node.receiver.getStaticType(typeContext))) {
15121510
return null;
15131511
}
15141512

@@ -1530,9 +1528,7 @@ class Translator with KernelNodes {
15301528
functions.getLambdaFunction(lambda, member, enclosingMemberClosures);
15311529

15321530
if (!typeEnvironment.isSubtypeOf(
1533-
lambdaDartType,
1534-
node.receiver.getStaticType(typeContext),
1535-
SubtypeCheckMode.withNullabilities)) {
1531+
lambdaDartType, node.receiver.getStaticType(typeContext))) {
15361532
return null;
15371533
}
15381534

@@ -1726,16 +1722,14 @@ class Translator with KernelNodes {
17261722
if (name == 'iterator' && nodeCount <= 20) {
17271723
if (typeEnvironment.isSubtypeOf(
17281724
klass.getThisType(coreTypes, Nullability.nonNullable),
1729-
coreTypes.iterableRawType(Nullability.nonNullable),
1730-
SubtypeCheckMode.ignoringNullabilities)) {
1725+
coreTypes.iterableRawType(Nullability.nonNullable))) {
17311726
return true;
17321727
}
17331728
}
17341729
if (name == 'current' && nodeCount <= 5) {
17351730
if (typeEnvironment.isSubtypeOf(
17361731
klass.getThisType(coreTypes, Nullability.nonNullable),
1737-
coreTypes.iteratorRawType(Nullability.nonNullable),
1738-
SubtypeCheckMode.ignoringNullabilities)) {
1732+
coreTypes.iteratorRawType(Nullability.nonNullable))) {
17391733
return true;
17401734
}
17411735
}

0 commit comments

Comments
 (0)