Change-Id: Ib51bcdf023910d244739ec176880a16e700851e7
Reviewed-on: https://go-review.googlesource.com/c/go/+/357915
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
goto Error
}
- switch utyp := optype(base).(type) {
+ switch utyp := singleUnder(base).(type) {
case *Struct:
if len(e.ElemList) == 0 {
break
--- /dev/null
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Composite literals with parameterized types
+
+package comp_literals
+
+type myStruct struct {
+ f int
+}
+
+type slice[E any] []E
+
+func struct_literals[S struct{f int}|myStruct]() {
+ _ = S{}
+ _ = S{0}
+ _ = S{f: 0}
+
+ _ = slice[int]{1, 2, 3}
+ _ = slice[S]{{}, {0}, {f:0}}
+}