Closed
Description
In the following code, invoking f2
throws an error.
class FunctionEmulator implements Function {
call(a, b);
noSuchMethod(i) => 'NSM ${i.positionalArguments}';
}
getF() => new FunctionEmulator();
main() {
var f1 = new FunctionEmulator();
print(f1(1, 2));
var f2 = getF();
print(f2(3, 4));
}
Here's the full output of executing this program:
NSM [1, 2]
require.js:143 Uncaught TypeError: Cannot read property 'noSuchMethod' of undefined
at call (example__list__main.js:20)
at Object.dart._checkAndCall (dart_sdk.js:2269)
at Object.dart.dcall (dart_sdk.js:2293)
at Object.list__main.main (example__list__main.js:42)
at main.dart.bootstrap.js:97
at Object.execCb (require.js:1696)
at Module.check (require.js:878)
at Module.<anonymous> (require.js:1139)
at require.js:134
at require.js:1189
Looking at the output, it seems that the second one uses dart.dcall
:
let f1 = new list__main.FunctionEmulator.new();
core.print(f1(1, 2));
let f2 = list__main.getF();
core.print(dart.dcall(f2, 3, 4));
It's worth noting that adding a return type getF
results in dart.dcall
not being used, and the example works as expected:
-getF() => new FunctionEmulator();
+FunctionEmulator getF() => new FunctionEmulator();
This issue is present in Dart 1.24.0 and 1.25.0-dev.1.0