Skip to content

Commit

Permalink
go/gcimporter15: backport interface embedding support
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
mdempsky committed Mar 21, 2017
1 parent 23ca8a2 commit b08393c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions go/gcimporter15/bimport.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion go/gcimporter15/gcimporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit b08393c

Please sign in to comment.