Skip to content

ClassMirror.superinterfaces throws UnimplementedError on dart2js #11863

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jmesserly opened this issue Jul 17, 2013 · 12 comments
Closed

ClassMirror.superinterfaces throws UnimplementedError on dart2js #11863

jmesserly opened this issue Jul 17, 2013 · 12 comments
Assignees
Labels
library-mirrors P1 A high priority bug; for example, a single project is unusable or has many test failures web-dart2js

Comments

@jmesserly
Copy link

splitting this out of https://code.google.com/p/dart/issues/detail?id=9434

// test program:

library test;
import 'dart:mirrors';

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

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

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

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

// output:

$ dart2js ~/scratch/test.dart && ./third_party/d8/linux/d8 out.js
Dart file ~/scratch/test.dart compiled to JavaScript: out.js
foo
bar
qux
> Symbol("test.Bar")
out.js:4723: UnimplementedError
  throw $.wrapException(ex);
          ^
Error
    at wrapException (out.js:4713:11)
    at throwExpression (out.js:4723:11)
    at JsClassMirror.get$superinterfaces (out.js:9144:14)
    at Closure$main.main as call$0
    at _IsolateContext.eval$1 (out.js:1983:21)
    at startRootIsolate (out.js:3153:15)
    at out.js:27682:7

$ dart ~/scratch/test.dart
foo
bar
qux
> Symbol("test.Bar")
  + Symbol("test.FooMixin")
> Symbol("test.Qux")

@peter-ahe-google
Copy link
Contributor

Set owner to @peter-ahe-google.
Removed Area-Library label.
Added Area-Dart2JS, Accepted labels.

@peter-ahe-google
Copy link
Contributor

Issue #12055 has been merged into this issue.


cc @justinfagnani.

@justinfagnani
Copy link
Contributor

Removed Priority-Unassigned label.
Added Priority-High label.

@jmesserly
Copy link
Author

@justin, just to make sure we're on the same page, high priority is for the "superclass" issue, not the "superinterfaces" ?

@justinfagnani
Copy link
Contributor

It should be for both. If you're looking up a member in a class you need to visit the superclass and superinterfaces.

@peter-ahe-google
Copy link
Contributor

Short term, what would be the purpose of searching the interfaces?

The members of a class are determined by itself and its superclasses, not its interfaces.

@justinfagnani
Copy link
Contributor

I use superinterfaces to look up members that aren't in the implementation, because they could be implemented via noSuchMethod. This of course won't work for classes that "implement" methods via nSM that aren't declared, but it's the best I can do for now.

@peter-ahe-google
Copy link
Contributor

Marked this as blocking #6490.

@peter-ahe-google
Copy link
Contributor

Added Started label.

@peter-ahe-google
Copy link
Contributor

Added Accepted label.

@peter-ahe-google
Copy link
Contributor

@peter-ahe-google
Copy link
Contributor

Fixed in r26185.


Added Fixed label.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
library-mirrors P1 A high priority bug; for example, a single project is unusable or has many test failures web-dart2js
Projects
None yet
Development

No branches or pull requests

3 participants