aboutsummaryrefslogtreecommitdiff
path: root/gopls/internal/lsp/analysis/unusedparams/testdata/src/typeparams/typeparams.go
blob: 93af2681b947415abbb9266404dc3501a0969153 (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
// 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 typeparams

import (
	"bytes"
	"fmt"
	"net/http"
)

type parent[T any] interface {
	n(f T)
}

type yuh[T any] struct {
	a T
}

func (y *yuh[int]) n(f bool) {
	for i := 0; i < 10; i++ {
		fmt.Println(i)
	}
}

func a[T comparable](i1 int, i2 T, i3 int) int { // want "potentially unused parameter: 'i2'"
	i3 += i1
	_ = func(z int) int { // want "potentially unused parameter: 'z'"
		_ = 1
		return 1
	}
	return i3
}

func b[T any](c bytes.Buffer) { // want "potentially unused parameter: 'c'"
	_ = 1
}

func z[T http.ResponseWriter](h T, _ *http.Request) { // want "potentially unused parameter: 'h'"
	fmt.Println("Before")
}

func l(h http.Handler) http.Handler {
	return http.HandlerFunc(z[http.ResponseWriter])
}

func mult(a, b int) int { // want "potentially unused parameter: 'b'"
	a += 1
	return a
}

func y[T any](a T) {
	panic("yo")
}