Skip to content

Commit d162c63

Browse files
askeksaCommit Bot
authored andcommitted
[dart2wasm] Support casting to and calling Function
Also fix parameter type of ClassID.getID These changes are necessary to support the hash implementation changes in https://dart-review.googlesource.com/c/sdk/+/237582 Change-Id: Ic7448fae647be57a55f9e1d08b3ece780e60fd3b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240402 Reviewed-by: Joshua Litt <joshualitt@google.com> Commit-Queue: Aske Simon Christensen <askesc@google.com>
1 parent 4b322a3 commit d162c63

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

pkg/dart2wasm/lib/code_generator.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,8 +1660,8 @@ class CodeGenerator extends ExpressionVisitor1<w.ValueType, w.ValueType>
16601660
@override
16611661
w.ValueType visitFunctionInvocation(
16621662
FunctionInvocation node, w.ValueType expectedType) {
1663-
FunctionType functionType = node.functionType!;
1664-
int parameterCount = functionType.requiredParameterCount;
1663+
int parameterCount = node.functionType?.requiredParameterCount ??
1664+
node.arguments.positional.length;
16651665
return _functionCall(parameterCount, node.receiver, node.arguments);
16661666
}
16671667

@@ -2057,7 +2057,10 @@ class CodeGenerator extends ExpressionVisitor1<w.ValueType, w.ValueType>
20572057
.getSubtypesOf(type.classNode)
20582058
.where((c) => !c.isAbstract)
20592059
.toList();
2060-
if (concrete.isEmpty) {
2060+
if (type.classNode == translator.coreTypes.functionClass) {
2061+
ClassInfo functionInfo = translator.classInfo[translator.functionClass]!;
2062+
translator.ref_test(b, functionInfo);
2063+
} else if (concrete.isEmpty) {
20612064
b.drop();
20622065
b.i32_const(0);
20632066
} else if (concrete.length == 1) {

sdk/lib/_internal/wasm/lib/class_id.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
@pragma("wasm:entry-point")
88
class ClassID {
9-
external static int getID(Object value);
9+
external static int getID(Object? value);
1010

1111
@pragma("wasm:class-id", "dart.typed_data#_ExternalUint8Array")
1212
external static int get cidExternalUint8Array;

0 commit comments

Comments
 (0)