reflect: panic on Invalid Interface call

This was initially pushed as part of CL 4876046, found
when logic in exp/template was using the method on
an Invalid value.

R=rsc
CC=golang-dev
https://golang.org/cl/4890043
This commit is contained in:
Gustavo Niemeyer 2011-08-15 14:14:15 -03:00
parent 241a262fe5
commit a2bb0159d6
1 changed files with 3 additions and 0 deletions

View File

@ -860,6 +860,9 @@ func (v Value) Interface() interface{} {
}
func (iv internalValue) Interface() interface{} {
if iv.kind == 0 {
panic(&ValueError{"reflect.Value.Interface", iv.kind})
}
if iv.method {
panic("reflect.Value.Interface: cannot create interface value for method with bound receiver")
}