aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/text
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2012-06-25 16:20:03 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2012-06-25 16:20:03 +0000
commit08a680a8879ce9da16d808644730f7cfacaf667f (patch)
tree5dfe28c3f573ae57b971ed4d9a1c99a76f0a70c4 /libgo/go/text
parent72de8622ae2d5aaeb58173f454aed87640a989b5 (diff)
downloadgcc-08a680a8879ce9da16d808644730f7cfacaf667f.zip
gcc-08a680a8879ce9da16d808644730f7cfacaf667f.tar.gz
gcc-08a680a8879ce9da16d808644730f7cfacaf667f.tar.bz2
libgo: Update to Go 1.0.2 release.
From-SVN: r188943
Diffstat (limited to 'libgo/go/text')
-rw-r--r--libgo/go/text/template/exec.go7
-rw-r--r--libgo/go/text/template/exec_test.go6
2 files changed, 13 insertions, 0 deletions
diff --git a/libgo/go/text/template/exec.go b/libgo/go/text/template/exec.go
index feb434a..aba21ce 100644
--- a/libgo/go/text/template/exec.go
+++ b/libgo/go/text/template/exec.go
@@ -518,6 +518,13 @@ func (s *state) validateType(value reflect.Value, typ reflect.Type) reflect.Valu
}
}
if !value.Type().AssignableTo(typ) {
+ if value.Kind() == reflect.Interface && !value.IsNil() {
+ value = value.Elem()
+ if value.Type().AssignableTo(typ) {
+ return value
+ }
+ // fallthrough
+ }
// Does one dereference or indirection work? We could do more, as we
// do with method receivers, but that gets messy and method receivers
// are much more constrained, so it makes more sense there than here.
diff --git a/libgo/go/text/template/exec_test.go b/libgo/go/text/template/exec_test.go
index 37d25f4..f4ae50f 100644
--- a/libgo/go/text/template/exec_test.go
+++ b/libgo/go/text/template/exec_test.go
@@ -311,6 +311,7 @@ var execTests = []execTest{
{".VariadicFuncInt", "{{call .VariadicFuncInt 33 `he` `llo`}}", "33=<he+llo>", tVal, true},
{"if .BinaryFunc call", "{{ if .BinaryFunc}}{{call .BinaryFunc `1` `2`}}{{end}}", "[1=2]", tVal, true},
{"if not .BinaryFunc call", "{{ if not .BinaryFunc}}{{call .BinaryFunc `1` `2`}}{{else}}No{{end}}", "No", tVal, true},
+ {"Interface Call", `{{stringer .S}}`, "foozle", map[string]interface{}{"S": bytes.NewBufferString("foozle")}, true},
// Erroneous function calls (check args).
{".BinaryFuncTooFew", "{{call .BinaryFunc `1`}}", "", tVal, false},
@@ -507,6 +508,10 @@ func vfunc(V, *V) string {
return "vfunc"
}
+func stringer(s fmt.Stringer) string {
+ return s.String()
+}
+
func testExecute(execTests []execTest, template *Template, t *testing.T) {
b := new(bytes.Buffer)
funcs := FuncMap{
@@ -516,6 +521,7 @@ func testExecute(execTests []execTest, template *Template, t *testing.T) {
"typeOf": typeOf,
"vfunc": vfunc,
"zeroArgs": zeroArgs,
+ "stringer": stringer,
}
for _, test := range execTests {
var tmpl *Template