aboutsummaryrefslogtreecommitdiff
path: root/test/typeparam
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2022-06-24 13:48:30 -0700
committerMatthew Dempsky <mdempsky@google.com>2022-06-24 13:48:41 -0700
commite7100adbca33a654101a8fa5779f6d2f675e3675 (patch)
tree62bae5a829cd54e6d8ea3a352e1db1b2a1646689 /test/typeparam
parent09a838ad86880150f4e297f7b2dec7c7d116623b (diff)
parent5a1c5b8ae741df2d5c53f328c57a84d85ae6c44a (diff)
downloadgo-e7100adbca33a654101a8fa5779f6d2f675e3675.tar.xz
[dev.unified] all: merge master (5a1c5b8) into dev.unified
Conflicts: - test/run.go Textual conflict adding to the known failures list for the nounified frontend. Merge List: + 2022-06-24 5a1c5b8ae7 cmd/go: add per-package indexing for modules outside mod cache + 2022-06-24 b9c4d94fdb cmd/go/internal/list: update help info with Deprecated field + 2022-06-24 73475ef035 go/types, types2: print qualified object names in cycle errors + 2022-06-24 3e58ef6cc7 go/types, types2: better errors for == when type sets are empty + 2022-06-24 d38f1d13fa doc/go1.19: Linux race detector now requires glibc 2.17 + 2022-06-23 de5329f1de debug/dwarf: handle malformed line table with bad program offset + 2022-06-23 15605ca827 embed: document additional file name restrictions + 2022-06-22 2e773a3894 test: add test that causes gofrontend crash + 2022-06-22 ff17b7d0d4 cmd/compile: don't use dictionary convert to shaped empty interface + 2022-06-22 2a3b467d5f cmd/go: make module .zip files group/world readable + 2022-06-22 bdab4cf47a cmd/go, cmd/link: support failure to create _cgo_import.go + 2022-06-22 aca37d16a5 cmd/go: avoid indexing modules in GOROOT + 2022-06-22 111cdb5848 all: update to current golang.org/x/sys revision + 2022-06-22 4045b1bc3f cmd/compile: fix assert condition in generic method call + 2022-06-22 6bad7e8243 compress/gzip: always close bodyReader in Example_compressingReader + 2022-06-22 606c6c371a encoding/xml: check nil pointer in DecodeElement + 2022-06-22 f571518139 cmd/cgo: dont override declared struct type + 2022-06-22 92c9b81447 net: don't set netGo = true on Windows with no cgo + 2022-06-22 be0b2a393a cmd/trace: add basic documentation to main page + 2022-06-22 b004c739b5 go/types, types2: fix parameter order dependence in type inference + 2022-06-21 f2c7e78592 spec: document operations which accept []byte|string constrained types + 2022-06-21 ab422f2749 runtime/trace: ignore fallback stacks in test + 2022-06-21 66685fb7dd doc/go1.19: use correct link to sync/atomic docs + 2022-06-21 4b236b45d0 runtime: convert flaky semaphore linearity test into benchmark + 2022-06-21 530511bacc cmd/go/internal/modindex: avoid walking modules when not needed + 2022-06-21 c2d373d5d1 cmd/compile: allow 128-bit values to be spilled + 2022-06-21 19ed442807 test: add regress test for #53477 + 2022-06-20 3fcbfb07a8 doc/go1.19: fix HTML validation issues + 2022-06-18 527ace0ffa cmd/compile: skip substituting closures in unsafe builtins arguments + 2022-06-17 ec58e3f327 test: add regress test for #53419 + 2022-06-17 103cc661f1 cmd/go/internal/modfetch: prevent duplicate hashes in go.sum + 2022-06-17 d42a48828f sync: add more notes about Cond behavior + 2022-06-17 9e2f289754 cmd/go/internal/work: log clearer detail for subprocess errors in (*Builder).toolID + 2022-06-17 dd2d00f9d5 net: fix flaky *TimeoutMustNotReturn tests + 2022-06-17 6c25ba624f go/token: delete unused File.set field + 2022-06-16 9068c6844d cmd/dist: add package . to 'go test' commands + 2022-06-16 7bad61554e runtime: write much more direct test for semaphore waiter scalability + 2022-06-16 f38a580a51 cmd/go: add more tracing Change-Id: I912c5879165e03f4d7f8ac3ee9241d50fc92a419
Diffstat (limited to 'test/typeparam')
-rw-r--r--test/typeparam/issue53254.go19
-rw-r--r--test/typeparam/issue53390.go20
-rw-r--r--test/typeparam/issue53406.go22
-rw-r--r--test/typeparam/issue53419.go28
-rw-r--r--test/typeparam/issue53477.go34
5 files changed, 123 insertions, 0 deletions
diff --git a/test/typeparam/issue53254.go b/test/typeparam/issue53254.go
new file mode 100644
index 0000000000..afc0f18471
--- /dev/null
+++ b/test/typeparam/issue53254.go
@@ -0,0 +1,19 @@
+// compile
+
+// 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 Interface[T any] interface {
+}
+
+func F[T any]() Interface[T] {
+ var i int
+ return i
+}
+
+func main() {
+ F[int]()
+}
diff --git a/test/typeparam/issue53390.go b/test/typeparam/issue53390.go
new file mode 100644
index 0000000000..52098c520b
--- /dev/null
+++ b/test/typeparam/issue53390.go
@@ -0,0 +1,20 @@
+// compile
+
+// 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 p
+
+import "unsafe"
+
+func F[T any](v T) uintptr {
+ return unsafe.Alignof(func() T {
+ func(any) {}(struct{ _ T }{})
+ return v
+ }())
+}
+
+func f() {
+ F(0)
+}
diff --git a/test/typeparam/issue53406.go b/test/typeparam/issue53406.go
new file mode 100644
index 0000000000..90fe78fb6f
--- /dev/null
+++ b/test/typeparam/issue53406.go
@@ -0,0 +1,22 @@
+// compile
+
+// 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
+
+func main() {
+ f[int]()
+}
+
+func f[T1 any]() {
+ var x Outer[T1, int]
+ x.M()
+}
+
+type Outer[T1, T2 any] struct{ Inner[T2] }
+
+type Inner[_ any] int
+
+func (Inner[_]) M() {}
diff --git a/test/typeparam/issue53419.go b/test/typeparam/issue53419.go
new file mode 100644
index 0000000000..62a226ff9f
--- /dev/null
+++ b/test/typeparam/issue53419.go
@@ -0,0 +1,28 @@
+// run
+
+// 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 T1 struct{}
+type T2 struct{}
+type Both struct {
+ T1
+ T2
+}
+
+func (T1) m() { panic("FAIL") }
+func (T2) m() { panic("FAIL") }
+func (Both) m() {}
+
+func f[T interface{ m() }](c T) {
+ c.m()
+}
+
+func main() {
+ var b Both
+ b.m()
+ f(b)
+}
diff --git a/test/typeparam/issue53477.go b/test/typeparam/issue53477.go
new file mode 100644
index 0000000000..d128a7e848
--- /dev/null
+++ b/test/typeparam/issue53477.go
@@ -0,0 +1,34 @@
+// run
+
+// 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.
+
+// Test that generic interface-interface comparisons resulting from
+// value switch statements are handled correctly.
+
+package main
+
+func main() {
+ f[X](0)
+}
+
+type Mer[T any] interface{ M(T) }
+type MNer[T any] interface {
+ Mer[T]
+ N()
+}
+
+type X int
+
+func (X) M(X) {}
+func (X) N() {}
+
+func f[T MNer[T]](t T) {
+ switch Mer[T](t) {
+ case MNer[T](t):
+ // ok
+ default:
+ panic("FAIL")
+ }
+}