aboutsummaryrefslogtreecommitdiff
path: root/cmp/report_reflect.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmp/report_reflect.go')
-rw-r--r--cmp/report_reflect.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/cmp/report_reflect.go b/cmp/report_reflect.go
index 76c04fd..d9d7323 100644
--- a/cmp/report_reflect.go
+++ b/cmp/report_reflect.go
@@ -282,7 +282,12 @@ func (opts formatOptions) FormatValue(v reflect.Value, parentKind reflect.Kind,
}
defer ptrs.Pop()
- skipType = true // Let the underlying value print the type instead
+ // Skip the name only if this is an unnamed pointer type.
+ // Otherwise taking the address of a value does not reproduce
+ // the named pointer type.
+ if v.Type().Name() == "" {
+ skipType = true // Let the underlying value print the type instead
+ }
out = opts.FormatValue(v.Elem(), t.Kind(), ptrs)
out = wrapTrunkReference(ptrRef, opts.PrintAddresses, out)
out = &textWrap{Prefix: "&", Value: out}
@@ -293,7 +298,6 @@ func (opts formatOptions) FormatValue(v reflect.Value, parentKind reflect.Kind,
}
// Interfaces accept different concrete types,
// so configure the underlying value to explicitly print the type.
- skipType = true // Print the concrete type instead
return opts.WithTypeMode(emitType).FormatValue(v.Elem(), t.Kind(), ptrs)
default:
panic(fmt.Sprintf("%v kind not handled", v.Kind()))