hi there,

I am a bit confused by go/types and defined named types:

https://play.golang.org/p/izESp473jOq

the above link shows a program using the go/types package and shows how
the four types T0, T1, T2 and T3:

```
package p

type T0 struct { F int}
type T1 struct { T0 }
type T2 T1
type T3 T0
```

map to types defined in go/types:

T0: type p.T0 struct{F int} -- obj=*types.TypeName typ=*types.Named -- 
under=*types.Struct
T1: type p.T1 struct{p.T0}  -- obj=*types.TypeName typ=*types.Named -- 
under=*types.Struct
T2: type p.T2 struct{p.T0}  -- obj=*types.TypeName typ=*types.Named -- 
under=*types.Struct
T3: type p.T3 struct{F int} -- obj=*types.TypeName typ=*types.Named -- 
under=*types.Struct

how would I use go/types to differentiate between T1 and T2?
they are 2 named types whose underlying types are (eventually):
 'struct { T0 }'

but, from the doc string of Type.Underlying:
```
// Underlying returns the underlying type of a type
// w/o following forwarding chains. Only used by
// client packages (here for backward-compatibility).
```

I was actually expecting to get:
- *types.Struct for t1.Underlying()
- *types.Named  for t2.Underlying()

so: how could I differentiate between a named type that's defined from
another named type and one that's defined (directly) from a struct ?


-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CEFLY6WPOVY6.1VEGTAPD57RSO%40clrinfopc42.

Reply via email to