package main
//go-sumtype:decl Animal
type Animal interface {
MakeSound()
sealed()
}
type Dog struct{}
func (*Dog) sealed() {}
func (*Dog) MakeSound() {
println("WOOF")
}
type Canine interface {
Animal
Breed() string
}
func test(animal Animal) {
switch animal.(type) {
case *Dog:
println("is dog")
}
}
func main() {
test(&Dog{})
}
Fails:
$ go-sumtype main.go
main.go:24:2: exhaustiveness check failed for sum type 'Animal': missing cases for Canine
I did not expect this to fail, as the switch is exhaustive on all concrete types of the interface and there aren't even any structs implementing the second one. The checks fail even there are structs which implement both or one of them.
Test case:
Fails:
I did not expect this to fail, as the switch is exhaustive on all concrete types of the interface and there aren't even any structs implementing the second one. The checks fail even there are structs which implement both or one of them.