go/types: permit embedding of non-defined interfaces via alias type names
Embedded interfaces in interfaces must take the form of a (possibly qualified) type name. Before alias types, a type name always denoted a defined (formerly "named") type. The introduction of alias types enabled embedding of non-defined types via alias type names, as in: type T interface { E } type E interface { m() } Both cmd/compile and gccgo accept this kind of code, and the spec does not prohibit it. There may be code in the wild that makes use of this. go/types was written under the assumption that embedded interfaces were always defined types; and that assumption was even reflected in the go/types API. This change removes this restriction in the implementation (which happens to make it simpler), and in the API (by adding additional functions and deprecating the corresponding older versions). It also replaces uses of NewInterface and Embedded (old API) by NewInterface2 and EmbeddedType (new API) in dependent packages (importers). The old API remains in place for backward compatibility and is marked as deprecated. Fixes #25301. Change-Id: I272acd498754179efaf0590ca49d3eb4eee4348e Reviewed-on: https://go-review.googlesource.com/114317Reviewed-by: Alan Donovan <adonovan@google.com>
Showing
Please register or sign in to comment