-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.
Description
According to Dart specification "10.2.2 The Method noSuchMethod"
A noSuchMethod forwarder is a concrete member of C with the signature
taken from the interface of C, and with the same default value for each optional
parameter
But in case of mixin application on VM default values of optional parameters are missed. Proof
String log = "";
class C {
int m1(int v, [String s = "s1"]);
int m2(int v, {String s = "s2"});
dynamic noSuchMethod(Invocation inv) {
for (int i = 0; i < inv.positionalArguments.length; i++) {
log += "${inv.positionalArguments[i]};";
}
for (int i = 0; i < inv.namedArguments.length; i++) {
log += "s=${inv.namedArguments[Symbol("s")]};";
}
return 42;
}
}
mixin M {
int m1(int v, [String s = "s1"]);
int m2(int v, {String s = "s2"});
dynamic noSuchMethod(Invocation inv) {
for (int i = 0; i < inv.positionalArguments.length; i++) {
log += "${inv.positionalArguments[i]};";
}
for (int i = 0; i < inv.namedArguments.length; i++) {
log += "s=${inv.namedArguments[Symbol("s")]};";
}
return 42;
}
}
class MA = Object with M;
main() {
C().m1(1);
print(log); // 1;s1;
log = "";
C().m2(2);
print(log); // 2;s=s2;
log = "";
MA().m1(1);
print(log); // 1;
log = "";
MA().m2(2);
print(log); // 2;
}
No this issue on DartPad. DartPad output is
1;s1;
2;s=s2;
1;s1;
2;s=s2;
So, I believe, this is VM issue
Tested on Dart SDK version: 3.2.0-202.0.dev (dev) (Tue Sep 26 21:06:42 2023 -0700) on "windows_x64"
Metadata
Metadata
Assignees
Labels
area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.