dice icon indicating copy to clipboard operation
dice copied to clipboard

Different behavior between VM an dart2js version / Uncaught exception in js_helper

Open MikeMitterer opened this issue 9 years ago • 2 comments

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

MikeMitterer avatar Feb 08 '16 12:02 MikeMitterer

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);
}

MikeMitterer avatar Feb 08 '16 13:02 MikeMitterer

Will look into this ASAP

ltackmann avatar Feb 09 '16 08:02 ltackmann