With a directory structure like:
./go.mod
./c/c.go
./a/ssa/a.go
./b/ssa/b.go
go.mod:
a.go:
package ssa
type T struct {
}
func (t *T) setNum(n int) {
}
var X interface{} = &T{}
func Run() {
X.(interface {
setNum(int)
}).setNum(0)
}
b.go:
package ssa
type T struct {
}
func (t *T) setNum(n int) {
}
var X interface{} = &T{}
func Run() {
X.(interface {
setNum(int)
}).setNum(0)
}
c.go:
package main
import (
a "modpath/a/ssa"
b "modpath/b/ssa"
)
func main() {
a.Run()
b.Run()
}
Then do
It fails with:
panic: interface conversion: *ssa.T is not interface { ssa.setNum(int) }: missing method setNum
goroutine 1 [running]:
modpath/b/ssa.Run(...)
/usr/local/google/home/khr/gowork/matloob/b/ssa/b.go:12
main.main()
/usr/local/google/home/khr/gowork/matloob/c/c.go:10 +0x90
This bug requires that both interfaces in a and b be anonymous. Somehow they are being unified (by the linker?) and the test in package b is using the anonymous interface from package a, and failing because the unexported methods must match packages.
I suspect we qualify the unexported methods with only the package name, not the package path. The two anonymous interfaces here have the same linker name when using just the package names.
@matloob
With a directory structure like:
go.mod:a.go:b.go:c.go:Then do
It fails with:
This bug requires that both interfaces in
aandbbe anonymous. Somehow they are being unified (by the linker?) and the test in packagebis using the anonymous interface from packagea, and failing because the unexported methods must match packages.I suspect we qualify the unexported methods with only the package name, not the package path. The two anonymous interfaces here have the same linker name when using just the package names.
@matloob