-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
To call invoke, you pass in positional arguments and named arguments.
InstanceMirror invoke(Symbol memberName, List positionalArguments, [Map<Symbol, dynamic> namedArguments])
Invoke throws an error if you call invoke on member that has no named arguments and you pass in an empty Map. Same for the positional arguments and an empty list.
The problem is if you get this info from an Invocation object, like from noSuchMethod, and you call invocationObj.namedArguments or invocationObject.positionalArguments they return empty lists if that member doesn't have any named/positional arguments.
As a result, to use invoke and noSuchMethod effectively, you have to individually determine if the invocation is a getter/setter/method/accessor and call invoke on each of those cases differently!
This defeats the purpose of noSuchMethod and invoke. So we probably just need to align our APIs so that either Invocation.namedArguments returns null instead of an empty list if that method/getter/etc doesn't take any arguments, or don't throw an error in invoke if we pass an empty list to a getter.