dice
dice copied to clipboard
Different behavior between VM an dart2js version / Uncaught exception in js_helper
Just want to let you know there is a problem between the VM and the dart2js version.
abstract class Name {
String get firstName;
}
// Fails if compiled to JS - it works with "extends"!!!!!!
class NameImpl implements Name {
@override
String get firstName => "Mike";
}
class ExampleModule extends dice.Module {
configure() {
register(Name).toInstance(new NameImpl());
}
}
main() async {
final dice.Injector injector = new dice.Injector(new ExampleModule());
final Name name = injector.getInstance(Name);
print(name.firstName);
}
More infos here: https://github.com/dart-lang/sdk/issues/25715#issuecomment-181338864
This should also work but fails in dart2js
abstract class Name {
String get firstName;
}
class NameImpl extends Name {
@override
String get firstName => "Mike";
}
class ExampleModule extends dice.Module {
configure() {
//register(Name).toInstance(new NameImpl());
// concrete implementation!
register(NameImpl);
}
}
main() async {
final dice.Injector injector = new dice.Injector(new ExampleModule());
final Name name = injector.getInstance(NameImpl);
print(name.firstName);
}
Will look into this ASAP