Skip to content

Commit 385c006

Browse files
nshahanCommit Queue
authored and
Commit Queue
committed
[ddc] Cleanup extension type erasure helper
A better API is now available from the kernel nodes directly. Issue: #49735 Change-Id: I1b4b36e44292cadc3f9d6c495ae93ae20e0db970 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335944 Reviewed-by: Mark Zhou <[email protected]> Commit-Queue: Nicholas Shahan <[email protected]>
1 parent f1219f2 commit 385c006

File tree

2 files changed

+2
-11
lines changed

2 files changed

+2
-11
lines changed

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -7233,8 +7233,7 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
72337233

72347234
@override
72357235
js_ast.Expression visitIsExpression(IsExpression node) {
7236-
return _emitIsExpression(
7237-
node.operand, shallowExtensionTypeErasure(node.type));
7236+
return _emitIsExpression(node.operand, node.type.extensionTypeErasure);
72387237
}
72397238

72407239
js_ast.Expression _emitIsExpression(Expression operand, DartType type) {
@@ -7271,7 +7270,7 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
72717270
var fromExpr = node.operand;
72727271
var jsFrom = _visitExpression(fromExpr);
72737272
if (node.isUnchecked) return jsFrom;
7274-
var to = shallowExtensionTypeErasure(node.type);
7273+
var to = node.type.extensionTypeErasure;
72757274
var from = fromExpr.getStaticType(_staticTypeContext);
72767275

72777276
// If the check was put here by static analysis to ensure soundness, we

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

-8
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,6 @@ Never throwUnsupportedAuxiliaryType(AuxiliaryType type) =>
1717
throw UnsupportedError(
1818
'Unsupported auxiliary type $type (${type.runtimeType}).');
1919

20-
/// Returns [type] with the immediate type erasure applied.
21-
///
22-
/// When [type] is an [ExtensionType] this is equivalent to `type.typeErasure`.
23-
/// The immediately returned value will not be an [ExtensionType] but it could
24-
/// still contain other [ExtensionType]s embedded within.
25-
DartType shallowExtensionTypeErasure(DartType type) =>
26-
type is ExtensionType ? type.extensionTypeErasure : type;
27-
2820
Constructor? unnamedConstructor(Class c) =>
2921
c.constructors.firstWhereOrNull((c) => c.name.text == '');
3022

0 commit comments

Comments
 (0)