! unparam .
cmp stdout stdout.golden

-- go.mod --
module testdata.tld/foo
-- stdout.golden --
foo.go:21:24: funcResultAsParam - a is unused
foo.go:25:38: (FooType).methodResultAsParam - a is unused
foo.go:32:29: funcResultsAsParams - b is unused
foo.go:37:31: funcResultNotAsParams - b is unused
foo.go:58:26: returnResultsOwn - result 0 (testdata.tld/foo.FooType) is never used
-- foo.go --
package foo

var DoWork func()

var Sink interface{}

type FooType int

func funcResultAsParams(a, b FooType) FooType {
	DoWork()
	return a + 1
}

func (f FooType) methodResultAsParams(a, b FooType) FooType {
	DoWork()
	return a + 1
}

func generateResults() (a, b FooType) { return }

func funcResultAsParam(a FooType) {
	DoWork()
}

func (f FooType) methodResultAsParam(a FooType) FooType {
	DoWork()
	return 3
}

func generateResult() (a FooType) { return }

func funcResultsAsParams(a, b FooType) FooType {
	DoWork()
	return a + 1
}

func funcResultNotAsParams(a, b FooType) FooType {
	DoWork()
	return a + 1
}

func ResultCalls() {
	a, b := generateResults()
	Sink = funcResultNotAsParams(a, b)

	var f FooType
	Sink = funcResultAsParams(1, 2)
	Sink = funcResultAsParams(generateResults())
	Sink = f.methodResultAsParams(1, 2)
	Sink = f.methodResultAsParams(generateResults())
	go funcResultAsParam(4)
	go funcResultAsParam(generateResult())
	Sink = f.methodResultAsParam(4)
	Sink = f.methodResultAsParam(generateResult())
	Sink = funcResultsAsParams(generateResult(), generateResult())
}

func returnResultsOwn() (FooType, FooType) {
	a := generateResult()
	a++
	return a, a * 2
}

func returnResultsDirectly() (FooType, FooType) {
	return generateResults()
}

func ReturnResultsCalls() {
	_, Sink = returnResultsOwn()
	_, Sink = returnResultsOwn()
	_, Sink = returnResultsDirectly()
	_, Sink = returnResultsDirectly()
}
