dart - Dart2js brackets Symbol in metadata annotation -
i can run code on dart vm:
@mirrorsused(metatargets: tag) import 'dart:mirrors'; class tag { final symbol name; const tag(this.name); } @proxy @tag(#[]) class tagged { nosuchmethod(invocation invocation) { instancemirror instancemirror = reflect(this); classmirror classmirror = instancemirror.type; classmirror.metadata.foreach((em) { if (em.reflectee tag && em.reflectee.name == invocation.membername) print(invocation.positionalarguments); }); } } void main() { var tagged = new tagged(); tagged[42]; tagged.foo(); tagged["dart"]; }
output:
[42]
[dart]
but when try compile dart2js fails error:
[error dart2js]:
bin\dart2jswithbracketanotation.dart:9:7:
expected identifier, got '['.
@tag(#[])
so 1 has bug?:
- (dart vm) because can run @ all.
- (dart2js) because doesn't compile js.
update: i reported bug
i think it's bug in dart2js because operator should allowed @ position.
Comments
Post a Comment