Skip to content

Commit

Permalink
[ddc] Erase extensions before calling .isTop()
Browse files Browse the repository at this point in the history
The CFE test for top types doesn't and probably shouldn't erase
extension types so now they are earased before calling.

Change-Id: I4d2c9d13149031925fb144aff9c1628eef84941c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364601
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
  • Loading branch information
nshahan authored and Commit Queue committed Apr 26, 2024
1 parent 4c888ab commit ab2dd17
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions pkg/dev_compiler/lib/src/kernel/compiler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2187,7 +2187,8 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
superMemberFunction!.positionalParameters[0])) {
return const [];
}
var setterType = substituteType(superMember.superSetterType);
var setterType =
substituteType(superMember.superSetterType).extensionTypeErasure;
if (_types.isTop(setterType)) return const [];
return [
js_ast.Method(
Expand Down Expand Up @@ -3816,12 +3817,12 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
DartType typeParameterType;
if (t is TypeParameter) {
isCovariantByClass = t.isCovariantByClass;
bound = t.bound;
bound = t.bound.extensionTypeErasure;
name = t.name!;
typeParameterType = TypeParameterType(t, Nullability.undetermined);
} else {
t as StructuralParameter;
bound = t.bound;
bound = t.bound.extensionTypeErasure;
name = t.name!;
typeParameterType =
StructuralParameterType(t, Nullability.undetermined);
Expand Down Expand Up @@ -4691,12 +4692,12 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>

body.add(_visitStatement(node.body).toScopedBlock(vars));
var then = js_ast.Block(body);

var guardType = node.guard.extensionTypeErasure;
// Discard following clauses, if any, as they are unreachable.
if (_types.isTop(node.guard)) return then;
if (_types.isTop(guardType)) return then;

var condition =
_emitIsExpression(VariableGet(exceptionParameter), node.guard);
_emitIsExpression(VariableGet(exceptionParameter), guardType);
return js_ast.If(condition, then, otherwise)
..sourceInformation = _nodeStart(node);
}
Expand Down Expand Up @@ -6841,9 +6842,10 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
}

js_ast.Expression _emitCast(js_ast.Expression expr, DartType type) {
if (_types.isTop(type)) return expr;
var normalizedType = type.extensionTypeErasure;
if (_types.isTop(normalizedType)) return expr;
return js.call('#.#(#)', [
_emitType(type),
_emitType(normalizedType),
_emitMemberName(js_ast.FixedNames.rtiAsField, memberClass: rtiClass),
expr
]);
Expand Down

0 comments on commit ab2dd17

Please sign in to comment.