reflect: Fix bug calling method on indirect value.
authorIan Lance Taylor <ian@gcc.gnu.org>
Tue, 17 Sep 2013 22:11:43 +0000 (22:11 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Tue, 17 Sep 2013 22:11:43 +0000 (22:11 +0000)
The gccgo-specific iword function was checking v.kind, but for
a method value that is always Func.  Fix to check v.typ.Kind()
instead.

From-SVN: r202670

libgo/go/reflect/value.go

index 45a08587973b5be33eedee57dc8ade0c2a922dcc..69a87031e56683e23415c87b7398abaec6a153cb 100644 (file)
@@ -611,7 +611,13 @@ func methodReceiver(op string, v Value, methodIndex int) (t *rtype, fn unsafe.Po
                }
                fn = unsafe.Pointer(&m.tfn)
                t = m.mtyp
-               rcvr = v.iword()
+               // Can't call iword here, because it checks v.kind,
+               // and that is always Func.
+               if v.flag&flagIndir != 0 && (v.typ.Kind() == Ptr || v.typ.Kind() == UnsafePointer) {
+                       rcvr = loadIword(v.val, v.typ.size)
+               } else {
+                       rcvr = iword(v.val)
+               }
        }
        return
 }