Skip to content

dart2js: Reflective superclass access fails for classes with mixin invocations in their superclass chain #12055

Closed
@jmesserly

Description

@jmesserly

this is the dart2js bug corresponding to VM bug:
https://code.google.com/p/dart/issues/detail?id=9434

given:

library test;
import 'dart:mirrors';

class FooMixin {
  foo() => print('foo');
}

class Qux {
  qux() => print('qux');
}

class Bar extends Qux with FooMixin {
  bar() => print('bar');
}

main() {
  var b = new Bar()..foo()..bar()..qux();

  var mirror = reflect(b);
  for (var type = mirror.type;
    // Note: checking qualifiedName here to workaround bugs with the superclass of Object
    type.qualifiedName != const Symbol('dart.core.Object');
    type = type.superclass) {
    print('> ${type.qualifiedName}');
    for (var i in type.superinterfaces) {
      print(' + ${i.qualifiedName}');
    }
  }
}

VM (after fix) outputs:

foo
bar
qux
> Symbol("test.Bar")
> Symbol("test.Qux&FooMixin")
  + Symbol("test.FooMixin")
> Symbol("test.Qux")

dart2js outputs:

foo
bar
qux
> Symbol("test.Bar")
out.js:4012: UnimplementedError
  throw $.wrapException(ex);
          ^
Error
    at wrapException (out.js:4002:11)
    at throwExpression (out.js:4012:11)
    at JsClassMirror.get$superinterfaces (out.js:9109:14)
    at Closure$main.main as call$0
    at _IsolateContext.eval$1 (out.js:2291:21)
    at startRootIsolate (out.js:1945:15)
    at out.js:28559:7
    at out.js:28756:3

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions