diff options
| author | Dan Scales <danscales@google.com> | 2021-12-28 18:40:12 -0800 |
|---|---|---|
| committer | Dan Scales <danscales@google.com> | 2022-01-10 19:51:05 +0000 |
| commit | 7de2249a08aab44c512d0ea86f50481d76e135f1 (patch) | |
| tree | 4bdd2ad91a8b9ab37c48e8d623f662f950257b3e /test/typeparam | |
| parent | 933f6685f7d33f3865d6ef062cbb0944d3f5d2fc (diff) | |
| download | go-7de2249a08aab44c512d0ea86f50481d76e135f1.tar.xz | |
cmd/compile, test: updated comments in crawler.go, added test
Added a test to make sure that the private methods of a local generic
type are properly exported, if there is a global variable with that
type.
Added comments in crawler.go, to give more detail and to give more about
the overall purpose.
Fixed one place where t.isFullyInstantiated() should be replaced by
isPtrFullyInstantiated(t), so that we catch pointers to generic types
that may be used as a method receiver.
Change-Id: I9c42d14eb6ebe14d249df7c8fa39e889f7cd3f22
Reviewed-on: https://go-review.googlesource.com/c/go/+/374754
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'test/typeparam')
| -rw-r--r-- | test/typeparam/gencrawler.dir/a.go | 27 | ||||
| -rw-r--r-- | test/typeparam/gencrawler.dir/main.go | 12 | ||||
| -rw-r--r-- | test/typeparam/gencrawler.go | 10 | ||||
| -rw-r--r-- | test/typeparam/gencrawler.out | 2 |
4 files changed, 51 insertions, 0 deletions
diff --git a/test/typeparam/gencrawler.dir/a.go b/test/typeparam/gencrawler.dir/a.go new file mode 100644 index 0000000000..50d6b4adeb --- /dev/null +++ b/test/typeparam/gencrawler.dir/a.go @@ -0,0 +1,27 @@ +// 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 + +var V val[int] + +type val[T any] struct { + valx T +} + +func (v *val[T]) Print() { + v.print1() +} + +func (v *val[T]) print1() { + println(v.valx) +} + +func (v *val[T]) fnprint1() { + println(v.valx) +} + +func FnPrint[T any](v *val[T]) { + v.fnprint1() +} diff --git a/test/typeparam/gencrawler.dir/main.go b/test/typeparam/gencrawler.dir/main.go new file mode 100644 index 0000000000..063de7f350 --- /dev/null +++ b/test/typeparam/gencrawler.dir/main.go @@ -0,0 +1,12 @@ +// 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.V.Print() + a.FnPrint(&a.V) +} diff --git a/test/typeparam/gencrawler.go b/test/typeparam/gencrawler.go new file mode 100644 index 0000000000..7c268aed51 --- /dev/null +++ b/test/typeparam/gencrawler.go @@ -0,0 +1,10 @@ +// 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. + +// Testing that all methods of a private generic type are exported, if a variable +// with that type is exported. + +package ignored diff --git a/test/typeparam/gencrawler.out b/test/typeparam/gencrawler.out new file mode 100644 index 0000000000..aa47d0d46d --- /dev/null +++ b/test/typeparam/gencrawler.out @@ -0,0 +1,2 @@ +0 +0 |
