typeof(this) return wrong type

Andrey via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Apr 22 04:33:22 PDT 2017


Hello, I trying to add custom attribute OnClickListener, the 
problem is that typeof always return BaseView type instead of 
MyView.
> struct OnClickListener {
>     string id;
> }
>
> class BaseView {
>     void onCreate() {
>         writeln(getSymbolsByUDA!(typeof(this), 
> OnClickListener).stringof);
>     }
> }
>
> class MyView : BaseView {
>     @OnClickListener("okButton")
>     void onOkButtonClick() {
>         writeln("Hello world!");
>     }
> }


More information about the Digitalmars-d-learn mailing list