Description
This issue was originally filed by [email protected]
I'm writing a framework that does RPC. Something like this:
someRpcFunction(Foo f, Bar b) { ... }
exportForRpc(someRpcFunction);
The framework calls the function is using Function.apply() after deserializing the arguments.
Dart will check the parameter types, but only in checked mode. This gives a false sense of security. To get the same checking in production mode, you have to check the types again:
rpcFunction(Foo f, Bar b) {
if (!(f is Foo) || !(b is Bar)) {
throw "function called with bad arguments";
}
}
This is redundant and makes it easy to make mistakes.
So, it would be nice if there were a @checked annotation to keep argument type-checking on all the time for a particular function, and a way to test whether a given function is @checked. Then the framework can ensure that all functions exported for RPC have their arguments checked all the time.