]> Cypherpunks repositories - gostls13.git/commit
go/types: permit embedding of non-defined interfaces via alias type names
authorRobert Griesemer <gri@golang.org>
Wed, 23 May 2018 23:35:56 +0000 (16:35 -0700)
committerRobert Griesemer <gri@golang.org>
Thu, 24 May 2018 16:47:26 +0000 (16:47 +0000)
commitc730a93fb9845740b09b9b0cef917b30098286cc
tree2c628202201f7564e8097bf3b22dc2767d2b2965
parent29957c52df59795ba21a6832662f66e9f1f298cf
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/114317
Reviewed-by: Alan Donovan <adonovan@google.com>
src/go/internal/gccgoimporter/parser.go
src/go/internal/gcimporter/bimport.go
src/go/internal/gcimporter/gcimporter_test.go
src/go/internal/gcimporter/iimport.go
src/go/internal/gcimporter/testdata/issue25301.go [new file with mode: 0644]
src/go/types/testdata/issues.src
src/go/types/type.go
src/go/types/typestring_test.go
src/go/types/typexpr.go
src/go/types/universe.go