Closed
Description
This is just one example of where the current interface type-checking still goes wrong (this assumes https://golang.org/cl/190258):
package p
type A interface {
a() interface {
AB
}
}
type B interface {
a() interface {
AB
}
}
type AB interface {
a() interface {
A
B
}
b() interface {
A
B
}
}
go/types testing reports:
$ go test -run Check$ -files=$HOME/tmp/x.go -errlist
--- FAIL: TestCheck (0.00s)
check_test.go:271: /Users/gri/tmp/x.go:18:3: duplicate method a
check_test.go:271: /Users/gri/tmp/x.go:17:3: other declaration of a
check_test.go:271: /Users/gri/tmp/x.go:22:3: duplicate method a
check_test.go:271: /Users/gri/tmp/x.go:21:3: other declaration of a
FAIL
exit status 1
FAIL go/types 0.079s
Yet, with the spec change for #6977 (and CL 190258) this should not result in any errors.
(Note that cmd/compile
also has trouble with this code if changes https://golang.org/cl/187519 et. al.) are in. The corresponding compiler issue is #6589).
Not urgent as this is a rather esoteric case. But at some point we should rethink type-checking of such mutually recursive data structures.