In the case of a wrong method, we were not ensuring that it was
type-checked before passing it to funcString.
Formatting the missing method error message requires a fully set-up
signature.
Fixes #59848
Change-Id: I1467e036afbbbdd00899bfd627a945500dc709c2
Reviewed-on: https://go-review.googlesource.com/c/go/+/494615
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
obj, _, _ = lookupFieldOrMethodImpl(V, false, m.pkg, m.name, true /* fold case */)
f, _ = obj.(*Func)
if f != nil {
+ // This method is formatted in funcString below, so must be type-checked.
+ if check != nil {
+ check.objDecl(f, nil)
+ }
state = wrongName
}
}
obj, _, _ = lookupFieldOrMethodImpl(V, false, m.pkg, m.name, true /* fold case */)
f, _ = obj.(*Func)
if f != nil {
+ // This method is formatted in funcString below, so must be type-checked.
+ if check != nil {
+ check.objDecl(f, nil)
+ }
state = wrongName
}
}
--- /dev/null
+// Copyright 2023 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package p
+
+type T struct{}
+type I interface{ M() }
+var _ I = T /* ERROR "missing method M" */ {} // must not crash
+func (T) m() {}