0

If I'm not wrong, this code should print:

 "dart.core.dynamic"

but following is printed:

 "dynamic"

My code:

    import 'dart:mirrors';

    main() {
      var mirror = reflectType(dynamic);
      var symbol = mirror.qualifiedName;
      print(symbol); // -> "dynamic"
    }
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
Tiago
  • 143
  • 5

2 Answers2

1

I think "dynamic" is a perfectly good result.

The usual qualified name prefixes the type name with the declaring library's name. You are expecting it to prefix "dart.core", which is the name of the "dart:core" library, but "dynamic" is not declared in that library (https://api.dartlang.org/docs/channels/stable/latest/dart_core.html), so that would be the wrong prefix to use.

The "dynamic" type is a synthetic type that is not declared in any library - there is no "class" or "typedef" declaration that could declare a type behaving as "dynamic" does. It's only specified by the specification and implemented internally in the compilers and runtime systems.

Having a qualified name with no prefix makes perfect sense in this case. It's the same you get for "void".

lrn
  • 64,680
  • 7
  • 105
  • 121
0

here is the answer How do I get the qualified name from a Type instance, in Dart?

you have forgotten about

 Symbol symbol = mirror.qualifiedName;
 String qualifiedName = MirrorSystem.getName(symbol);
Community
  • 1
  • 1
Bzik
  • 78
  • 7
  • my question is not about getting the qualified name but if the qualified name returned is correct. Even if I use `MirrorSystem.getName (symbol)` the output is `"dynamic"` not `"dart.code.dynamic"` – Tiago Nov 28 '13 at 12:26