aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/noder
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2022-01-26 13:26:45 -0800
committerMatthew Dempsky <mdempsky@google.com>2022-01-27 00:03:31 +0000
commitf4aa021985e9ae4a9a395f8fbe32ad08d2bfda3b (patch)
tree55f9f87d2f9d9a8bd6d0524574f021e5ed91d94e /src/cmd/compile/internal/noder
parentdb48840cfc5ea9f8067cd5238827965ea01cdde1 (diff)
downloadgo-f4aa021985e9ae4a9a395f8fbe32ad08d2bfda3b.tar.xz
cmd/compile: support structural typing in unified IR
This CL updates unified IR to look at the structural type of a composite literal type, rather than merely the underlying type, to determine if it's a structure. This fixes a number of currently failing regress test cases. Updates #50833. Change-Id: I11c040c77ec86c23e8ffefcf1ce1aed548687dc5 Reviewed-on: https://go-review.googlesource.com/c/go/+/381074 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Trust: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Robert Griesemer <gri@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/noder')
-rw-r--r--src/cmd/compile/internal/noder/writer.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/noder/writer.go b/src/cmd/compile/internal/noder/writer.go
index 2bb0b4d5d7..73f2df8e39 100644
--- a/src/cmd/compile/internal/noder/writer.go
+++ b/src/cmd/compile/internal/noder/writer.go
@@ -1218,6 +1218,7 @@ func (w *writer) expr(expr syntax.Expr) {
}
obj := obj.(*types2.Var)
+ assert(!obj.IsField())
assert(targs.Len() == 0)
w.code(exprLocal)
@@ -1337,10 +1338,11 @@ func (w *writer) compLit(lit *syntax.CompositeLit) {
w.typ(tv.Type)
typ := tv.Type
+ // TODO(mdempsky): Use types2.StructuralType here too? See #50833.
if ptr, ok := typ.Underlying().(*types2.Pointer); ok {
typ = ptr.Elem()
}
- str, isStruct := typ.Underlying().(*types2.Struct)
+ str, isStruct := types2.StructuralType(typ).(*types2.Struct)
w.len(len(lit.ElemList))
for i, elem := range lit.ElemList {