1
0
mirror of https://github.com/golang/go synced 2024-11-21 23:44:39 -07:00

template: slightly simplify the test for assignability of arguments

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4951066
This commit is contained in:
Rob Pike 2011-09-06 15:59:21 -07:00
parent d45e808c91
commit 62b10ad0ba

View File

@ -511,7 +511,7 @@ func (s *state) validateType(value reflect.Value, typ reflect.Type) reflect.Valu
// are much more constrained, so it makes more sense there than here.
// Besides, one is almost always all you need.
switch {
case value.Kind() == reflect.Ptr && value.Elem().Type().AssignableTo(typ):
case value.Kind() == reflect.Ptr && value.Type().Elem().AssignableTo(typ):
value = value.Elem()
case reflect.PtrTo(value.Type()).AssignableTo(typ) && value.CanAddr():
value = value.Addr()