Skip to content

Commit b2cd914

Browse files
nshahanCommit Queue
authored and
Commit Queue
committed
[ddc] Erase extension types in assertions
Ensures the same optimizations to expressions statically typed as extension types. Issue: #49735 Change-Id: Id9b944d3f716faf38bb4770eb9b90ccc708056ce Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/342104 Reviewed-by: Mark Zhou <[email protected]>
1 parent 66a955b commit b2cd914

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -4699,14 +4699,16 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
46994699
js_ast.Statement visitAssertStatement(AssertStatement node) {
47004700
if (!_options.enableAsserts) return js_ast.EmptyStatement();
47014701
var condition = node.condition;
4702-
var conditionType = condition.getStaticType(_staticTypeContext);
4702+
var conditionType =
4703+
condition.getStaticType(_staticTypeContext).extensionTypeErasure;
47034704
var jsCondition = _visitExpression(condition);
47044705

47054706
if (conditionType != _coreTypes.boolLegacyRawType &&
47064707
conditionType != _coreTypes.boolNullableRawType &&
47074708
conditionType != _coreTypes.boolNonNullableRawType) {
47084709
jsCondition = runtimeCall('dtest(#)', [jsCondition]);
47094710
} else if (isNullable(condition)) {
4711+
// TODO(nshahan): Is this branch even reachable in null safe code?
47104712
jsCondition = runtimeCall('test(#)', [jsCondition]);
47114713
}
47124714

0 commit comments

Comments
 (0)