delve/_fixtures/pkgrenames.go
aarzilli f62bf8d1e3 proc: Names of concrete types of interfaces parsing their runtime._type
Generate names of the concrete types stored inside interface variables
by fully parsing their runtime._type instead of simply using the str
field.

This allows delve to read the contents of an interface variable when
the program imports multiple packages that have the same name. It also
allows delve to correctly interpret some complex anonymous types.

Fixes #455
2016-10-27 09:56:15 +02:00

56 lines
1.7 KiB
Go

package main
import (
"fmt"
"reflect"
"runtime"
pkg1 "go/ast"
pkg2 "net/http"
"dir0/pkg"
"dir0/renamedpackage"
dir1pkg "dir1/pkg"
)
func main() {
var badexpr interface{} = &pkg1.BadExpr{1, 2}
var req interface{} = &pkg2.Request{Method: "amethod"}
var amap interface{} = map[pkg1.BadExpr]pkg2.Request{pkg1.BadExpr{2, 3}: pkg2.Request{Method: "othermethod"}}
var amap2 interface{} = &map[pkg1.BadExpr]pkg2.Request{pkg1.BadExpr{2, 3}: pkg2.Request{Method: "othermethod"}}
var dir0someType interface{} = &pkg.SomeType{3}
var dir1someType interface{} = dir1pkg.SomeType{1, 2}
var amap3 interface{} = map[pkg.SomeType]dir1pkg.SomeType{pkg.SomeType{4}: dir1pkg.SomeType{5, 6}}
var anarray interface{} = [2]pkg.SomeType{pkg.SomeType{1}, pkg.SomeType{2}}
var achan interface{} = make(chan pkg.SomeType)
var aslice interface{} = []pkg.SomeType{pkg.SomeType{3}, pkg.SomeType{4}}
var afunc interface{} = func(a pkg.SomeType, b dir1pkg.SomeType) {}
var astruct interface{} = &struct {
A dir1pkg.SomeType
B pkg.SomeType
}{
A: dir1pkg.SomeType{1, 2},
B: pkg.SomeType{3},
}
var astruct2 interface{} = &struct {
dir1pkg.SomeType
X int
}{
SomeType: dir1pkg.SomeType{1, 2},
X: 10,
}
var iface interface {
AMethod(x int) int
AnotherMethod(x int) int
} = &pkg.SomeType{4}
var iface2iface interface{} = &iface
var iface3 interface{} = &realname.SomeType{A: true}
runtime.Breakpoint()
t := reflect.ValueOf(iface2iface).Elem().Type()
m := t.Method(0)
fmt.Println(m.Type.In(0))
fmt.Println(m.Type.String())
fmt.Println(badexpr, req, amap, amap2, dir0someType, dir1someType, amap3, anarray, achan, aslice, afunc, astruct, astruct2, iface2iface, iface3)
}