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)
|
p.record(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// no embedded interfaces with gc compiler
|
var embeddeds []*types.Named
|
||||||
if p.int() != 0 {
|
for n := p.int(); n > 0; n-- {
|
||||||
errorf("unexpected embedded interface")
|
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 {
|
if p.trackAllTypes {
|
||||||
p.typList[n] = t
|
p.typList[n] = t
|
||||||
}
|
}
|
||||||
|
|
|
@ -249,7 +249,7 @@ var importedObjectTests = []struct {
|
||||||
}{
|
}{
|
||||||
{"math.Pi", "const Pi untyped float"},
|
{"math.Pi", "const Pi untyped float"},
|
||||||
{"io.Reader", "type Reader interface{Read(p []byte) (n int, err error)}"},
|
{"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"},
|
{"math.Sin", "func Sin(x float64) float64"},
|
||||||
// TODO(gri) add more tests
|
// TODO(gri) add more tests
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue