Skip to content
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

JsVariableMirror.type returns JsMirrorSystem._dynamicType instead of JsClassMirror of variable #12410

Closed
DartBot opened this issue Aug 13, 2013 · 10 comments
Assignees
Labels
closed-obsolete Closed as the reported issue is no longer relevant library-mirrors P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dart2js

Comments

@DartBot
Copy link

DartBot commented Aug 13, 2013

This issue was originally filed by ak...@gmail.com


Problem repeats on Linux and Windows on Chrome, Chromium, FireFox, IE.

I'm expecting to have ClassMirror of 'type' property in VariableMirror and it does really return it in DartVM:

VariableMirror.type => ClassMirror

so I can instantiate variable with 'newInstance' method of ClassMirror.

In JavaScript VM it does return JsTypeMirror of dynamic type:

TypeMirror get type => JsMirrorSystem._dynamicType;

(from https://code.google.com/p/dart/source/browse/trunk/dart/sdk/lib/_internal/compiler/implementation/lib/js_mirrors.dart?r=23894)

and fails with next exception:

Uncaught TypeError: Object #<JsTypeMirror> has no method 'newInstance$2'

Use example code below to test:

import 'dart:html';
import 'dart:mirrors';

void main() {
  DivElement div = query("#sample_container_id");
  div.text = testMirrors();
}

class A {
  
  B b;
}

class B {
  
  String name = "Unknown";
  
  B();
}

String testMirrors() {
  // Make an instance of class A
  A a = new A();
  // Get instance mirror of class A
  InstanceMirror aIM = reflect(a);
  // Get class mirror of class A
  ClassMirror aCM = aIM.type;
  // Find 'b' variable mirror in class mirror of class A
  VariableMirror bVM = aCM.variables.values.first;
  // Get class mirror of variable mirror of 'b'
  ClassMirror bCM = bVM.type;
  try {
    // Instantiate variable 'b'
    InstanceMirror bIM = bCM.newInstance(const Symbol(""), []);
    // Assign instance of variable 'b' to instance of class A
    aIM.setField(const Symbol("b"), bIM.reflectee);
  } on Exception catch(ex) {
    print(ex);
  }
  // Return 'name' of 'b' of 'a'
  return a.b.name;
}

String symbolAsString(Symbol symbol) => MirrorSystem.getName(symbol);

@anders-sandholm
Copy link
Contributor

Added Area-Dart2JS, Library-Mirrors, Triaged labels.

@peter-ahe-google
Copy link
Contributor

Set owner to @peter-ahe-google.
Added Accepted label.

@peter-ahe-google
Copy link
Contributor

Marked this as blocking #6490.

@kasperl
Copy link

kasperl commented Sep 18, 2013

Added this to the M7 milestone.

@kasperl
Copy link

kasperl commented Sep 30, 2013

Removed Priority-Unassigned label.
Added Priority-Medium label.

@kasperl
Copy link

kasperl commented Oct 2, 2013

Removed this from the M7 milestone.
Added this to the M8 milestone.

@kasperl
Copy link

kasperl commented Jun 4, 2014

Removed this from the M8 milestone.
Added this to the 1.6 milestone.

@kasperl
Copy link

kasperl commented Jul 10, 2014

Removed this from the 1.6 milestone.
Added Oldschool-Milestone-1.6 label.

@kasperl
Copy link

kasperl commented Aug 4, 2014

Removed Oldschool-Milestone-1.6 label.

@kevmoo kevmoo added P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed accepted labels Feb 29, 2016
@matanlurey matanlurey added the closed-obsolete Closed as the reported issue is no longer relevant label Mar 3, 2018
@matanlurey
Copy link
Contributor

Mirrors is no longer supported in Dart2JS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-obsolete Closed as the reported issue is no longer relevant library-mirrors P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dart2js
Projects
None yet
Development

No branches or pull requests

6 participants