OSDN Git Service

reflect: Fix bug comparing struct field types.
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 10 Nov 2012 20:27:41 +0000 (20:27 +0000)
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 10 Nov 2012 20:27:41 +0000 (20:27 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@193396 138bc75d-0d04-0410-961f-82ee72b054a4

libgo/go/reflect/type.go

index 93021ba..f2675c5 100644 (file)
@@ -1230,8 +1230,19 @@ func directlyAssignable(T, V *commonType) bool {
                for i := range t.fields {
                        tf := &t.fields[i]
                        vf := &v.fields[i]
-                       if tf.name != vf.name || tf.pkgPath != vf.pkgPath ||
-                               tf.typ != vf.typ || tf.tag != vf.tag || tf.offset != vf.offset {
+                       if tf.name != vf.name && (tf.name == nil || vf.name == nil || *tf.name != *vf.name) {
+                               return false
+                       }
+                       if tf.pkgPath != vf.pkgPath && (tf.pkgPath == nil || vf.pkgPath == nil || *tf.pkgPath != *vf.pkgPath) {
+                               return false
+                       }
+                       if tf.typ != vf.typ {
+                               return false
+                       }
+                       if tf.tag != vf.tag && (tf.tag == nil || vf.tag == nil || *tf.tag != *vf.tag) {
+                               return false
+                       }
+                       if tf.offset != vf.offset {
                                return false
                        }
                }