-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Description
When the cha
library processes a method call on an interface value, it must calculate the concrete methods that it may call at runtime. It does this by finding all methods whose name matches the selector, and whose type satisfies the interface. The name matching is done using plain string equality, but this is not quite right, because unexported identifiers in different packages are always considered different, even if they are spelled the same.
Performing the string matching on the output of go/types.Id
for the selector and method names would fix this.
See the test program in https://go.dev/cl/574955 for an example. There, a type S1
which embeds a types.Object
, and a method order
are defined:
type S1 struct {
types.Object
X int
}
func (s *S1) order(x int) int {
return s.X + x
}
S1
satisfies the go/types.Object
interface, but code in go/types
that calls order
on a types.Object
value cannot call the order
method of S1
defined here, it can only call an order
method of the embedded types.Object
which was defined in go/types
.