go-sumtype
go-sumtype copied to clipboard
check: fix false positive when an interface implements a sum type
Sometimes it is possible for a sum type interface to be implemented by another interface. For example, we have a sum type called T including 3 variants, A, B, C. We also have an U interface embedding T and thus implementing T. Assuming that B and C implement U, a type switch statement can be considered exhaustive if all of A, B, C are listed. It should also be considered exhaustive if only A and U are listed.
However, go-sumtype does not distinguish between concrete and interface types. It fails in both cases, requiring all of A, B, C, U to be listed. It is unlikely to code to be written in this way. U already covers B and C, and it is unnecessary to list them in a type switch statement. This commit fixes the problem by handling interfaces specially.
Closes: https://github.com/BurntSushi/go-sumtype/issues/1 Closes: https://github.com/BurntSushi/go-sumtype/issues/3
Ping again ... I hope you have seen my reply. Do you have any new comment? There has been no activity on the pull request for 3 weeks.
Because I'm busy. Please be patient. I don't have a reply yet because I need to try this out for myself.