aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/noder/expr.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2022-01-26 13:46:45 -0800
committerMatthew Dempsky <mdempsky@google.com>2022-01-27 19:55:38 +0000
commit1a2435c95f8c68c7d21d172c8a80c6cc96aa9cf5 (patch)
tree7468d51b438512549d4e88438026eb6091e0c7c1 /src/cmd/compile/internal/noder/expr.go
parentb7b44b3173f151a2313da7072afd25de80511605 (diff)
downloadgo-1a2435c95f8c68c7d21d172c8a80c6cc96aa9cf5.tar.xz
go/types, cmd/compile: fix composite literal structural typing
For a composite literal expression like []T{{f: 1}}, we allow T to be a pointer to struct type, so it's consistent to allow T to also be a type parameter whose structural type is a pointer to struct type. Fixes #50833. Change-Id: Ib0781ec4a4f327c875ea25b97740ff2c0c86b916 Reviewed-on: https://go-review.googlesource.com/c/go/+/381075 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Robert Griesemer <gri@golang.org> Trust: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/noder/expr.go')
-rw-r--r--src/cmd/compile/internal/noder/expr.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/noder/expr.go b/src/cmd/compile/internal/noder/expr.go
index 6891d1ec30..8a9afeb095 100644
--- a/src/cmd/compile/internal/noder/expr.go
+++ b/src/cmd/compile/internal/noder/expr.go
@@ -332,7 +332,7 @@ func (g *irgen) exprs(exprs []syntax.Expr) []ir.Node {
}
func (g *irgen) compLit(typ types2.Type, lit *syntax.CompositeLit) ir.Node {
- if ptr, ok := typ.Underlying().(*types2.Pointer); ok {
+ if ptr, ok := types2.StructuralType(typ).(*types2.Pointer); ok {
n := ir.NewAddrExpr(g.pos(lit), g.compLit(ptr.Elem(), lit))
n.SetOp(ir.OPTRLIT)
return typed(g.typ(typ), n)