dart-archive / smoke

Smoke is a Dart package that exposes a reduced reflective system API. This API includes accessing objects in a dynamic fashion (read properties, write properties, and call methods), inspecting types (for example, whether a method exists), and symbol/string convention.
https://pub.dartlang.org/packages/smoke
BSD 3-Clause "New" or "Revised" License
12 stars 3 forks source link

smoke.invoke + adjust fails with function fields #16

Open DartBot opened 9 years ago

DartBot commented 9 years ago

Issue by sigmundch Originally opened as dart-lang/sdk#20799


Using

  smoke.invoke(new A(), #foo, [1, 2, 3], adjust: true);

may fail if #foo is declared as a function field, not a method:

  class A {     Function foo;   }

With the mirror implementation this fails because we currently try to find the method via:

  receiverMirror.type.declarations[#foo]

but the declaration only has VariableMirror, so we actually need to do:

  receiverMirror.getField(#foo).type

instead.

The recorder might also have issues with this.

Because we use 'adjust' for event dispatching in polymer, users that want to use a dynamic function for an event handler should declare the function to take 3 arguments (so adjust is not relevant in that case)