runtime: print/panic complex

This commit is contained in:
visualfc
2024-06-20 15:52:56 +08:00
parent 32883b4e18
commit 02a5375503
7 changed files with 114 additions and 9 deletions

View File

@@ -211,7 +211,7 @@ func (p Program) Index(typ Type) Type {
func (p Program) Field(typ Type, i int) Type {
var fld *types.Var
switch t := typ.raw.Type.(type) {
switch t := typ.raw.Type.Underlying().(type) {
case *types.Tuple:
fld = t.At(i)
case *types.Basic:
@@ -223,7 +223,7 @@ func (p Program) Field(typ Type, i int) Type {
}
panic("Field: basic type doesn't have fields")
default:
fld = t.Underlying().(*types.Struct).Field(i)
fld = t.(*types.Struct).Field(i)
}
return p.rawType(fld.Type())
}