From 167a7123997c42e91d69de2203fc4c156897f0a2 Mon Sep 17 00:00:00 2001 From: Nodir Turakulov Date: Tue, 13 Oct 2015 19:09:32 -0700 Subject: text/template: resolve non-empty interface Read what a non-empty interface points to. The deleted lines were added in https://codereview.appspot.com/4810060/, which attempted to break an infinite loop. That was a long time ago. If I just delete these lines with current codebase, the test "bug1" (added in that CL) does not fail. All new tests fail without this fix. Fixes #12924 Change-Id: I9370ca44facd6af3019850aa065b936e5a482d37 Reviewed-on: https://go-review.googlesource.com/15809 Reviewed-by: Andrew Gerrand --- src/text/template/exec.go | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src/text/template/exec.go') diff --git a/src/text/template/exec.go b/src/text/template/exec.go index 16839a8d6d..233d34a02b 100644 --- a/src/text/template/exec.go +++ b/src/text/template/exec.go @@ -829,16 +829,11 @@ func (s *state) evalEmptyInterface(dot reflect.Value, n parse.Node) reflect.Valu } // indirect returns the item at the end of indirection, and a bool to indicate if it's nil. -// We indirect through pointers and empty interfaces (only) because -// non-empty interfaces have methods we might need. func indirect(v reflect.Value) (rv reflect.Value, isNil bool) { for ; v.Kind() == reflect.Ptr || v.Kind() == reflect.Interface; v = v.Elem() { if v.IsNil() { return v, true } - if v.Kind() == reflect.Interface && v.NumMethod() > 0 { - break - } } return v, false } -- cgit v1.3-5-g9baa