-
Notifications
You must be signed in to change notification settings - Fork 0
The noSuchMethod invocation instance isn't fine-grained enough. #2
Description
When tearing-off a non-existing member of an object, the noSuchMethod of the object is called, but with insufficient information for the method to recognize it as a tear-off.
The spec says:
Otherwise, a new instance im of the predefined class Invocation is created, such that :
- If m is a setter name, im.isSetter evaluates to true; otherwise im.isMethod evaluates to true.
- im.memberName evaluates to ’m’.
- im.positionalArguments evaluates to the value of const [].
- im.namedArguments evaluates to the value of const {}.
This means that tearing off a getter and a method are indistinguishable from calling a method.
This makes it impossible for the object to emulate the tear-off with noSuchMethod.
A method tear-off like o#foo should be emulated by returning a function, but calling the method o.foo() should execute the emulated function instead. The two accesses have the same Invocation instance, and cannot be distinguished.
Changing the invocation to im.isGetter instead won't fix that, because it breaks getter access/tear-off instead.