Debian Codegraph @

src/internal/types/testdata/fixedbugs/issue48136.go

raw
1 // Copyright 2021 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package p
6
7 func f1[P interface{ *P }]() {}
8 func f2[P interface{ func(P) }]() {}
9 func f3[P, Q interface{ func(Q) P }]() {}
10 func f4[P interface{ *Q }, Q interface{ func(P) }]() {}
11 func f5[P interface{ func(P) }]() {}
12 func f6[P interface { *Tree[P] }, Q any ]() {}
13
14 func _() {
15 f1 /* ERROR "cannot infer P" */ ()
16 f2 /* ERROR "cannot infer P" */ ()
17 f3 /* ERROR "cannot infer P" */ ()
18 f4 /* ERROR "cannot infer P" */ ()
19 f5 /* ERROR "cannot infer P" */ ()
20 f6 /* ERROR "cannot infer P" */ ()
21 }
22
23 type Tree[P any] struct {
24 left, right *Tree[P]
25 data P
26 }
27
28 // test case from issue
29
30 func foo[Src interface { func() Src }]() Src {
31 return foo[Src]
32 }
33
34 func _() {
35 foo /* ERROR "cannot infer Src" */ ()
36 }