提交 5f0f77f4 编写于 作者: A aarzilli 提交者: Derek Parker

proc: automatically dereference interfaces on member access

If 'iv' is an interface variable with a struct as a concrete value let
'iv.A' evaluate to the access to field 'A' of the concrete value of
'iv'.
上级 844762a8
......@@ -670,6 +670,11 @@ func (v *Variable) structMember(memberName string) (*Variable, error) {
case reflect.Chan:
v = v.clone()
v.RealType = resolveTypedef(&(v.RealType.(*godwarf.ChanType).TypedefType))
case reflect.Interface:
v.loadInterface(0, false, LoadConfig{})
if len(v.Children) > 0 {
v = &v.Children[0]
}
}
structVar := v.maybeDereference()
structVar.Name = v.Name
......
......@@ -552,6 +552,8 @@ func TestEvalExpression(t *testing.T) {
{"err2", true, "error(*main.bstruct) *{a: main.astruct {A: 1, B: 2}}", "error(*main.bstruct) 0x…", "error", nil},
{"errnil", true, "error nil", "error nil", "error", nil},
{"iface1", true, "interface {}(*main.astruct) *{A: 1, B: 2}", "interface {}(*main.astruct) 0x…", "interface {}", nil},
{"iface1.A", false, "1", "1", "int", nil},
{"iface1.B", false, "2", "2", "int", nil},
{"iface2", true, "interface {}(string) \"test\"", "interface {}(string) \"test\"", "interface {}", nil},
{"iface3", true, "interface {}(map[string]go/constant.Value) []", "interface {}(map[string]go/constant.Value) []", "interface {}", nil},
{"iface4", true, "interface {}([]go/constant.Value) [4]", "interface {}([]go/constant.Value) [...]", "interface {}", nil},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册