aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types2/testdata/fixedbugs/issue41124.go2
blob: 60650432a47982f1f725b5ef8474d1cf6e3373af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// Copyright 2020 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

// Test case from issue.

type Nat interface {
	Zero|Succ
}

type Zero struct{}
type Succ struct{
	Nat // ERROR interface contains type constraints
}

// Struct tests.

type I1 interface {
	comparable
}

type I2 interface {
	~int
}

type I3 interface {
	I1
	I2
}

type _ struct {
	f I1 // ERROR interface is .* comparable
}

type _ struct {
	comparable // ERROR interface is .* comparable
}

type _ struct{
	I1 // ERROR interface is .* comparable
}

type _ struct{
	I2 // ERROR interface contains type constraints
}

type _ struct{
	I3 // ERROR interface is .* comparable
}

// General composite types.

type (
	_ [10]I1 // ERROR interface is .* comparable
	_ [10]I2 // ERROR interface contains type constraints

	_ []I1 // ERROR interface is .* comparable
	_ []I2 // ERROR interface contains type constraints

	_ *I3 // ERROR interface is .* comparable
	_ map[I1 /* ERROR interface is .* comparable */ ]I2 // ERROR interface contains type constraints
	_ chan I3 // ERROR interface is .* comparable
	_ func(I1 /* ERROR interface is .* comparable */ )
	_ func() I2 // ERROR interface contains type constraints
)

// Other cases.

var _ = [...]I3 /* ERROR interface is .* comparable */ {}

func _(x interface{}) {
	_ = x.(I3 /* ERROR interface is .* comparable */ )
}

type T1[_ any] struct{}
type T3[_, _, _ any] struct{}
var _ T1[I2 /* ERROR interface contains type constraints */ ]
var _ T3[int, I2 /* ERROR interface contains type constraints */ , float32]

func f1[_ any]() int
var _ = f1[I2 /* ERROR interface contains type constraints */ ]()
func f3[_, _, _ any]() int
var _ = f3[int, I2 /* ERROR interface contains type constraints */ , float32]()

func _(x interface{}) {
	switch x.(type) {
	case I2 /* ERROR interface contains type constraints */ :
	}
}