ClojureDart
ClojureDart copied to clipboard
interop support of extensions
I'd like to expose extensions as regular functions, I don't like pretending they are member of classes.
The design issues with extensions support:
How to compile (.ext_method not-hinted-value)? Not forgetting too take into account that a class may have a method going by the same name as ext_method...
Possible answers (not necessarily mutually exclusive):
1/ namespaced methods like (.fa/AnimateWidgetExtensions.animate w) (cheap to implement but ugly)
2/ on dynamic call when method name matches a known (= in a required package) extension then add type checks against the extended to the emitted dart code
if (target is Widget) { // there may be multiple matching extensions
(target as Widget).animate(....)
} else {
(target as dynamic).animate(....)
}
Solution 2 is the best one as it assumes little knowledge on the user side (don't have to know it's an ext method) and would work even in dynamic calls.
Closed by accident, because commit message had "should fix #10"
sorry, did not know that written "should fix" automatically closed a PR...