mirror of
https://github.com/golang/go
synced 2024-11-11 20:20:23 -07:00
test: add compiler regress tests for #46461
gri@ reports that types2 now correctly handles when type parameters recursively refer back to the parameterized type, so we might as well add tests to exercise that. Unified IR also correctly handles importing and exporting these types, but -G=3 currently does not. Updates #46461. Change-Id: I272102aa08c40c980b9aeeca9f834291dfbbcc3e Reviewed-on: https://go-review.googlesource.com/c/go/+/348738 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
parent
b9e1a24581
commit
fb84e99eb7
@ -167,6 +167,8 @@ func TestImportTypeparamTests(t *testing.T) {
|
||||
skip := map[string]string{
|
||||
"equal.go": "inconsistent embedded sorting", // TODO(rfindley): investigate this.
|
||||
"nested.go": "fails to compile", // TODO(rfindley): investigate this.
|
||||
|
||||
"issue46461.go": "known issue with type parameter constraints referring back to parameterized type",
|
||||
}
|
||||
|
||||
for _, entry := range list {
|
||||
|
@ -2188,6 +2188,8 @@ var g3Failures = setOf(
|
||||
|
||||
"typeparam/nested.go", // -G=3 doesn't support function-local types with generics
|
||||
|
||||
"typeparam/issue46461b.go", // -G=3 fails when type parameters refer back to the parameterized type itself
|
||||
|
||||
"typeparam/mdempsky/4.go", // -G=3 can't export functions with labeled breaks in loops
|
||||
)
|
||||
|
||||
|
13
test/typeparam/issue46461.go
Normal file
13
test/typeparam/issue46461.go
Normal file
@ -0,0 +1,13 @@
|
||||
// compile -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 p
|
||||
|
||||
type T[U interface{ M() T[U] }] int
|
||||
|
||||
type X int
|
||||
|
||||
func (X) M() T[X] { return 0 }
|
7
test/typeparam/issue46461b.dir/a.go
Normal file
7
test/typeparam/issue46461b.dir/a.go
Normal file
@ -0,0 +1,7 @@
|
||||
// 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 T[U interface{ M() T[U] }] int
|
11
test/typeparam/issue46461b.dir/b.go
Normal file
11
test/typeparam/issue46461b.dir/b.go
Normal file
@ -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 b
|
||||
|
||||
import "./a"
|
||||
|
||||
type X int
|
||||
|
||||
func (X) M() a.T[X] { return 0 }
|
7
test/typeparam/issue46461b.go
Normal file
7
test/typeparam/issue46461b.go
Normal file
@ -0,0 +1,7 @@
|
||||
// compiledir -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
|
Loading…
Reference in New Issue
Block a user