In ClojureDart deftype
(and reify
) can extend abstract classes and, as a consequence, we need a way to call super implementations (even on fields because of getters/setters).
For example, this Dart
class WebViewExampleState extends State<WebViewExample> {
@override
void initState() {
super.initState();
if (Platform.isAndroid) WebView.platform = SurfaceAndroidWebView();
}
...
}
can be translated to this ClojureDart:
(deftype WebViewExampleState
:extends #/(State WebViewExample)
(initState [^{:super daddy} self]
(.initState daddy)
(when Platform/isAndroid (set! WebView/platform (SurfaceAndroidWebView.)))
...)
So the :super
metadata on the this
parameter of a method allows to introduce a name for super
.
Super calls can even occur in closures (fns or reifies) they'll act on the right instance, not on the super of the closure!