[ddc] Handle Object members on extension types

Erase extension types when deciding to dispatch directly or to a helper
method for Object members.

Issue: https://github.com/dart-lang/sdk/issues/49735
Change-Id: I31081bf4ec64a0f667c8d40b08b94773e229ebe1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335601
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
This commit is contained in:
Nicholas Shahan 2023-11-17 22:24:37 +00:00 committed by Commit Queue
parent 2b4b9cb753
commit 30b530bce7

View file

@ -5434,7 +5434,7 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
/// members at runtime.
bool _shouldCallObjectMemberHelper(Expression e) {
if (isNullable(e)) return true;
var type = e.getStaticType(_staticTypeContext);
var type = e.getStaticType(_staticTypeContext).extensionTypeErasure;
if (type is RecordType || type is FunctionType) return false;
if (type is InterfaceType) {
// TODO(nshahan): This could be expanded to any classes where we know all
@ -5460,7 +5460,7 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
/// This is a simple approach and not an exhaustive search.
bool _triviallyConstNoInterop(Expression? e) {
if (e is ConstantExpression) {
var type = e.constant.getType(_staticTypeContext);
var type = e.constant.getType(_staticTypeContext).extensionTypeErasure;
if (type is InterfaceType) return !usesJSInterop(type.classNode);
} else if (e is StaticGet && e.target.isConst) {
var target = e.target;