From 90e00f872d715c6d54742e6bbcafa2ce4f033dc8 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 17 Apr 2015 18:19:44 +0000 Subject: re PR go/65755 (incorrect reflection of struct fields with gccgo) PR go/65755 compiler, runtime, reflect: Use reflection string for type comparisons. Change the runtime and reflect libraries to always use only the type reflection string to determine whether two types are equal. It previously used the PkgPath and Name values for a type name, but that required a PkgPath that did not match the gc compiler. Change the compiler to use the same PkgPath value as the gc compiler in all cases. Change the compiler to put the receiver type in the reflection string for a type defined inside a method. From-SVN: r222194 --- libgo/go/reflect/type.go | 8 +------- libgo/runtime/go-typedesc-equal.c | 11 ----------- 2 files changed, 1 insertion(+), 18 deletions(-) (limited to 'libgo') diff --git a/libgo/go/reflect/type.go b/libgo/go/reflect/type.go index 5cbf7e5..7f0c6a8 100644 --- a/libgo/go/reflect/type.go +++ b/libgo/go/reflect/type.go @@ -1940,13 +1940,7 @@ func canonicalize(t Type) Type { if t == nil { return nil } - u := t.uncommon() - var s string - if u == nil || u.PkgPath() == "" { - s = t.rawString() - } else { - s = u.PkgPath() + "." + u.Name() - } + s := t.rawString() canonicalTypeLock.RLock() if r, ok := canonicalType[s]; ok { canonicalTypeLock.RUnlock() diff --git a/libgo/runtime/go-typedesc-equal.c b/libgo/runtime/go-typedesc-equal.c index f8474fc..90079f2 100644 --- a/libgo/runtime/go-typedesc-equal.c +++ b/libgo/runtime/go-typedesc-equal.c @@ -24,16 +24,5 @@ __go_type_descriptors_equal (const struct __go_type_descriptor *td1, return 0; if (td1->__code != td2->__code || td1->__hash != td2->__hash) return 0; - if (td1->__uncommon != NULL && td1->__uncommon->__name != NULL) - { - if (td2->__uncommon == NULL || td2->__uncommon->__name == NULL) - return 0; - return (__go_ptr_strings_equal (td1->__uncommon->__name, - td2->__uncommon->__name) - && __go_ptr_strings_equal (td1->__uncommon->__pkg_path, - td2->__uncommon->__pkg_path)); - } - if (td2->__uncommon != NULL && td2->__uncommon->__name != NULL) - return 0; return __go_ptr_strings_equal (td1->__reflection, td2->__reflection); } -- cgit v1.1