This is my code:
import macros
type
FooType = object
one: string
two: int
BarType[T] = object
one: string
two: T
var
foo = FooType(one: "one", two: 2)
bar = BarType[string](one: "one", two: "two")
template echoType(T: typedesc) =
const o = getType(T).treeRepr
echo o
proc echoObject[O: object](obj: O) =
echoType(O)
echo obj.repr
echoObject(foo)
echoObject(bar)
The output I get:
ObjectTy
Empty
RecList
Sym "one"
Sym "two"
[one = 0x1051e7050"one",
two = 2]
Sym "BarType"
[one = 0x1051e7078"one",
two = 0x1051e70a0"two"]
Why does getType return a Sym for the second type? How do I get the treeRepr of the actually declared type BarType[T]?