summaryrefslogtreecommitdiffstats
path: root/src/internal/types/testdata/fixedbugs/issue50929.go
blob: 45e075191da6898c7568508e0b27973bb61ccdae (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
// 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.

// This file is tested when running "go test -run Manual"
// without source arguments. Use for one-off debugging.

package p

import "fmt"

type F[A, B any] int

func G[A, B any](F[A, B]) {
}

func _() {
	// TODO(gri) only report one error below (issue #50932)
	var x F /* ERROR got 1 arguments but 2 type parameters */ [int]
	G(x /* ERROR does not match */)
}

// test case from issue
// (lots of errors but doesn't crash anymore)

type RC[G any, RG any] interface {
	~[]RG
}

type RG[G any] struct{}

type RSC[G any] []*RG[G]

type M[Rc RC[G, RG], G any, RG any] struct {
	Fn func(Rc)
}

type NFn[Rc RC[G, RG], G any, RG any] func(Rc)

func NC[Rc RC[G, RG], G any, RG any](nFn NFn[Rc, G, RG]) {
	var empty Rc
	nFn(empty)
}

func NSG[G any](c RSC[G]) {
	fmt.Println(c)
}

func MMD[Rc RC /* ERROR got 1 arguments */ [RG], RG any, G any]() M /* ERROR got 2 arguments */ [Rc, RG] {

	var nFn NFn /* ERROR got 2 arguments */ [Rc, RG]

	var empty Rc
	switch any(empty).(type) {
	case BC /* ERROR undefined: BC */ :

	case RSC[G]:
		nFn = NSG /* ERROR cannot use NSG\[G\] */ [G]
	}

	return M /* ERROR got 2 arguments */ [Rc, RG]{
		Fn: func(rc Rc) {
			NC(nFn /* ERROR does not match */ )
		},
	}

	return M /* ERROR got 2 arguments */ [Rc, RG]{}
}