mirror of https://github.com/golang/go.git
cmd/compile: preserve 'any' type alias in unified IR
When exporting the "any" empty interface type for unified IR, write it out as a reference to the "any" alias, rather than to the underlying empty interface. This matches how "byte" and "rune" are handled. Verified to fix the issue demonstrated in CL 369975. Change-Id: Ic2844b0acc3b17c20b3a40aaf262f62ec653eb5a Reviewed-on: https://go-review.googlesource.com/c/go/+/370374 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
parent
ece493eb83
commit
8ff254e30b
|
|
@ -229,6 +229,8 @@ func (pw *pkgWriter) pkgIdx(pkg *types2.Package) int {
|
||||||
|
|
||||||
// @@@ Types
|
// @@@ Types
|
||||||
|
|
||||||
|
var anyTypeName = types2.Universe.Lookup("any").(*types2.TypeName)
|
||||||
|
|
||||||
func (w *writer) typ(typ types2.Type) {
|
func (w *writer) typ(typ types2.Type) {
|
||||||
w.typInfo(w.p.typIdx(typ, w.dict))
|
w.typInfo(w.p.typIdx(typ, w.dict))
|
||||||
}
|
}
|
||||||
|
|
@ -350,6 +352,12 @@ func (pw *pkgWriter) typIdx(typ types2.Type, dict *writerDict) typeInfo {
|
||||||
w.structType(typ)
|
w.structType(typ)
|
||||||
|
|
||||||
case *types2.Interface:
|
case *types2.Interface:
|
||||||
|
if typ == anyTypeName.Type() {
|
||||||
|
w.code(typeNamed)
|
||||||
|
w.obj(anyTypeName, nil)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
w.code(typeInterface)
|
w.code(typeInterface)
|
||||||
w.interfaceType(typ)
|
w.interfaceType(typ)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue