mirror of
https://github.com/golang/go
synced 2024-11-07 15:46:23 -07:00
1a2435c95f
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>
24 lines
429 B
Go
24 lines
429 B
Go
// run -gcflags=-G=3
|
|
|
|
// Copyright 2022 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.
|
|
|
|
package main
|
|
|
|
type (
|
|
S struct{ f int }
|
|
PS *S
|
|
)
|
|
|
|
func a() []*S { return []*S{{f: 1}} }
|
|
func b() []PS { return []PS{{f: 1}} }
|
|
|
|
func c[P *S]() []P { return []P{{f: 1}} }
|
|
func d[P PS]() []P { return []P{{f: 1}} }
|
|
|
|
func main() {
|
|
c[*S]()
|
|
d[PS]()
|
|
}
|