diff options
author | Dan Scales <danscales@google.com> | 2021-09-14 08:39:08 -0700 |
---|---|---|
committer | Dan Scales <danscales@google.com> | 2021-09-14 23:07:15 +0000 |
commit | 137543bb93e15286b54d58d17d51e609ed49339a (patch) | |
tree | 8ee82e36cdfef6019960c82f4eaac4d8437fc82b /test | |
parent | 3a72175cdcbfb64cca5968be52ac964f69d3a44a (diff) | |
download | go-137543bb93e15286b54d58d17d51e609ed49339a.tar.gz go-137543bb93e15286b54d58d17d51e609ed49339a.zip |
cmd/compile: set IsShape based on type being in the Shapes pkg
Move ShapePkg to types, and change types.NewNamed to automatically set
IsShape/HasShape if a type is in the shapes pkg. This means that
imported shape types will automatically have the correct
IsShape/HasShape flags, even though we are not explicitly
exporting/importing those flags.
Updates #48337
Change-Id: I8b6131a663205f73f395943c9d0c8bdb2a213401
Reviewed-on: https://go-review.googlesource.com/c/go/+/349869
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/typeparam/issue48337b.dir/a.go | 25 | ||||
-rw-r--r-- | test/typeparam/issue48337b.dir/main.go | 11 | ||||
-rw-r--r-- | test/typeparam/issue48337b.go | 7 |
3 files changed, 43 insertions, 0 deletions
diff --git a/test/typeparam/issue48337b.dir/a.go b/test/typeparam/issue48337b.dir/a.go new file mode 100644 index 0000000000..a3c2e88a2f --- /dev/null +++ b/test/typeparam/issue48337b.dir/a.go @@ -0,0 +1,25 @@ +// Copyright 2021 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 a + +type Container[T any] struct { + X T +} + +func NewContainer[T any](x T) *Container[T] { + return &Container[T]{x} +} + +type MetaContainer struct { + C *Container[Value] +} + +type Value struct{} + +func NewMetaContainer() *MetaContainer { + c := NewContainer(Value{}) + // c := &Container[Value]{Value{}} // <-- this works + return &MetaContainer{c} +} diff --git a/test/typeparam/issue48337b.dir/main.go b/test/typeparam/issue48337b.dir/main.go new file mode 100644 index 0000000000..0b2814cbc0 --- /dev/null +++ b/test/typeparam/issue48337b.dir/main.go @@ -0,0 +1,11 @@ +// Copyright 2021 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 + +import "a" + +func main() { + a.NewMetaContainer() +} diff --git a/test/typeparam/issue48337b.go b/test/typeparam/issue48337b.go new file mode 100644 index 0000000000..76930e5e4f --- /dev/null +++ b/test/typeparam/issue48337b.go @@ -0,0 +1,7 @@ +// rundir -G=3 + +// Copyright 2021 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 ignored |