Is your feature request related to a problem? Please describe.
Currently, unused named parameters give the following warning. The type is not shown, but having the name available makes it easy to figure out which parameter is unused.
// parameter value arg in method unusedParam is never used
def unusedParam(arg: Int): Unit = { }
// parameter value arg in method unusedParam is never used
def unusedImplicit(implicit arg: Int): Unit = { }
However, when using context bounds, implicit arguments have auto-generated names like evidence$1, making it difficult to identify the steps needed to resolve the warning, especially in cases where there are several type parameters each with their own context bounds.
object UnusedExample {
abstract class Foo[T] {
def foo(arg: T): Unit
}
abstract class Bar[T] {
def bar(arg: T): Unit
}
// parameter value evidence$2 in method useFoo is never used
def unusedFoo[A: Foo: Bar](a: A): Unit = {
val foo = implicitly[Foo[A]]
foo.foo(a)
}
}
Describe the solution you'd like
Warning messages generated by -Wunused:params should include both the name AND type of the unused parameter. For example,
// parameter value `arg: Int` in method unusedParam is never used
def unusedParam(arg: Int): Unit = { }
// parameter value `arg: Int` in method unusedParam is never used
def unusedImplicit(implicit arg: Int): Unit = { }
object UnusedExample {
abstract class Foo[T] {
def foo(arg: T): Unit
}
abstract class Bar[T] {
def bar(arg: T): Unit
}
// parameter value `evidence$2: Bar` in method useFoo is never used
def unusedFoo[A: Foo: Bar](a: A): Unit = {
val foo = implicitly[Foo[A]]
foo.foo(a)
}
}
Describe alternatives you've considered
Without these more descriptive error messages, the only way to identify the source of an unused evidence$n warning is to count up to the nth context bound in the method signature.
In certain cases, the squiggly red/yellow underline will be drawn directly under the unused context bound, making it easy to see which context bound is unused. However, in some cases it will be drawn under the method name itself (which is probably a bug, although I was not able to reproduce it for my simple example).
Additional contex
Is this the right place to make this request? It wasn't clear to me if the message is generated by metals, bloop, or some other tool. I searched the source of metals, bloop, and vscode-metals for the text "never used" but found no results. Please point me in the right direction!
Search terms
unused parameter, context bound, unused implicit
Is your feature request related to a problem? Please describe.
Currently, unused named parameters give the following warning. The type is not shown, but having the name available makes it easy to figure out which parameter is unused.
However, when using context bounds, implicit arguments have auto-generated names like
evidence$1, making it difficult to identify the steps needed to resolve the warning, especially in cases where there are several type parameters each with their own context bounds.Describe the solution you'd like
Warning messages generated by
-Wunused:paramsshould include both the name AND type of the unused parameter. For example,Describe alternatives you've considered
Without these more descriptive error messages, the only way to identify the source of an
unused evidence$nwarning is to count up to thenth context bound in the method signature.In certain cases, the squiggly red/yellow underline will be drawn directly under the unused context bound, making it easy to see which context bound is unused. However, in some cases it will be drawn under the method name itself (which is probably a bug, although I was not able to reproduce it for my simple example).
Additional contex
Is this the right place to make this request? It wasn't clear to me if the message is generated by metals, bloop, or some other tool. I searched the source of metals, bloop, and vscode-metals for the text "never used" but found no results. Please point me in the right direction!
Search terms
unused parameter, context bound, unused implicit