mirror of
https://github.com/golang/go
synced 2024-11-18 19:54:44 -07:00
go/gcimporter15: backport interface embedding support
Backports golang.org/cl/38392 from go/internal/gcimporter. Updates golang/go#16369. Change-Id: Ic805f96e6565590987a5dae9f0f76c206fceab05 Reviewed-on: https://go-review.googlesource.com/38429 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
parent
23ca8a2633
commit
b08393ce6d
@ -493,12 +493,13 @@ func (p *importer) typ(parent *types.Package) types.Type {
|
||||
p.record(nil)
|
||||
}
|
||||
|
||||
// no embedded interfaces with gc compiler
|
||||
if p.int() != 0 {
|
||||
errorf("unexpected embedded interface")
|
||||
var embeddeds []*types.Named
|
||||
for n := p.int(); n > 0; n-- {
|
||||
p.pos()
|
||||
embeddeds = append(embeddeds, p.typ(parent).(*types.Named))
|
||||
}
|
||||
|
||||
t := types.NewInterface(p.methodList(parent), nil)
|
||||
t := types.NewInterface(p.methodList(parent), embeddeds)
|
||||
if p.trackAllTypes {
|
||||
p.typList[n] = t
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ var importedObjectTests = []struct {
|
||||
}{
|
||||
{"math.Pi", "const Pi untyped float"},
|
||||
{"io.Reader", "type Reader interface{Read(p []byte) (n int, err error)}"},
|
||||
{"io.ReadWriter", "type ReadWriter interface{Read(p []byte) (n int, err error); Write(p []byte) (n int, err error)}"},
|
||||
{"io.ReadWriter", "type ReadWriter interface{Reader; Writer}"},
|
||||
{"math.Sin", "func Sin(x float64) float64"},
|
||||
// TODO(gri) add more tests
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user