aboutsummaryrefslogtreecommitdiff
path: root/test/typeparam
diff options
context:
space:
mode:
authorRobert Findley <rfindley@google.com>2022-02-24 14:18:24 -0500
committerRobert Findley <rfindley@google.com>2022-03-07 21:18:15 +0000
commit28fab5ef21d8aef72634f9c251fbeb4039dababa (patch)
treeb9262889d9cef0ef18acef89ad33e75a206d5d9b /test/typeparam
parent20dd9a42fb80ed4919d79bfb4644c16ab9e09e72 (diff)
downloadgo-28fab5ef21d8aef72634f9c251fbeb4039dababa.tar.xz
go/types, types2: disable inference for type instances
Inference for type instances has dependencies on type-checking order that can lead to subtle bugs. As explained in #51527, disable it for 1.18. Fixes #51527 Change-Id: I42795bad30ce53abecfc5a4914599ae5a2041a9e Reviewed-on: https://go-review.googlesource.com/c/go/+/387934 Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'test/typeparam')
-rw-r--r--test/typeparam/issue51232.go12
-rw-r--r--test/typeparam/issue51233.go16
2 files changed, 17 insertions, 11 deletions
diff --git a/test/typeparam/issue51232.go b/test/typeparam/issue51232.go
index 44d114d235..0d25e1863d 100644
--- a/test/typeparam/issue51232.go
+++ b/test/typeparam/issue51232.go
@@ -1,4 +1,4 @@
-// compile
+// errorcheck
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
@@ -13,19 +13,19 @@ type RC[RG any] interface {
type Fn[RCT RC[RG], RG any] func(RCT)
type F[RCT RC[RG], RG any] interface {
- Fn() Fn[RCT]
+ Fn() Fn[RCT] // ERROR "got 1 arguments"
}
type concreteF[RCT RC[RG], RG any] struct {
- makeFn func() Fn[RCT]
+ makeFn func() Fn[RCT] // ERROR "got 1 arguments"
}
-func (c *concreteF[RCT, RG]) Fn() Fn[RCT] {
+func (c *concreteF[RCT, RG]) Fn() Fn[RCT] { // ERROR "got 1 arguments"
return c.makeFn()
}
-func NewConcrete[RCT RC[RG], RG any](Rc RCT) F[RCT] {
- return &concreteF[RCT]{
+func NewConcrete[RCT RC[RG], RG any](Rc RCT) F[RCT] { // ERROR "got 1 arguments"
+ return &concreteF[RCT]{ // ERROR "cannot use" "got 1 arguments"
makeFn: nil,
}
}
diff --git a/test/typeparam/issue51233.go b/test/typeparam/issue51233.go
index 9411f2e6b5..96a25ddb9c 100644
--- a/test/typeparam/issue51233.go
+++ b/test/typeparam/issue51233.go
@@ -1,22 +1,28 @@
-// compile
+// errorcheck
// 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
+// As of issue #51527, type-type inference has been disabled.
+
type RC[RG any] interface {
~[]RG
}
+
type Fn[RCT RC[RG], RG any] func(RCT)
-type FFn[RCT RC[RG], RG any] func() Fn[RCT]
+
+type FFn[RCT RC[RG], RG any] func() Fn[RCT] // ERROR "got 1 arguments"
+
type F[RCT RC[RG], RG any] interface {
- Fn() Fn[RCT]
+ Fn() Fn[RCT] // ERROR "got 1 arguments"
}
+
type concreteF[RCT RC[RG], RG any] struct {
- makeFn FFn[RCT]
+ makeFn FFn[RCT] // ERROR "got 1 arguments"
}
-func (c *concreteF[RCT, RG]) Fn() Fn[RCT] {
+func (c *concreteF[RCT, RG]) Fn() Fn[RCT] { // ERROR "got 1 arguments"
return c.makeFn()
}