You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 22, 2018. It is now read-only.
classM {
call(x,y) => x+y;
}
main() {
M m =newM();
print(m(1,2)); // worksprint(m(1,2,3)); // NoSuchMethodError at runtime. analyzer fails to catchprint(m.call(1,2,3)); // analyzer correctly detects this
}
This blows up due to wrong number of arguments at runtime. However, I don't see any warnings or errors from dart2js or dartanalyzer.
DDC does not really catch this either. It is treated as dynamic dispatch and allowed, for some reason, even though we could've caught it statically.
Turns out that in checker.dart we only look at:
if (type.isDynamic || type.isDartCoreFunction || type is!FunctionType) { ...
we should additionaly check if the type implements call and use it's type instead:
if (type isInterfaceType) {
var callMethod = type.lookUpMethod("call", _current.library);
if (callMethod !=null) type = callMethod.type;
}
...
The text was updated successfully, but these errors were encountered:
Yeah. Interesting to check some corner cases too, like obj.method(123). Where obj.method is a getter that returns an object with 'call' (I think that works, and we should be able to statically analyze it)
The analyzer seems to have fixed the issue that allows m(1, 2, 3). There is another bug which seems to cause it to treat the return types incorrectly (dartbug.com/23252). I have a CL pending which fixes the dynamic dispatch issue.
Copied from John:
Turns out that in checker.dart we only look at:
we should additionaly check if the type implements
call
and use it's type instead:The text was updated successfully, but these errors were encountered: