Skip to content

Unused warning for NotGiven is not useful #22969

Closed
@eejbyfeldt

Description

@eejbyfeldt

Compiler version

3.7.0-RC1

Minimized example

import scala.util.NotGiven

object Test {
  def f[T](a: Int)(using NotGiven[T <:< Int]) = a + 2
}

Output Error/Warning message

-- [E198] Unused Symbol Warning: unused_notgiven.scala:4:25 ----------------------------------
4 |  def f[T](a: Int)(using NotGiven[T <:< Int]) = a + 2
  |                         ^
  |                         unused implicit parameter
1 warning found

Why this Error/Warning was not helpful

The unused warning is not useful as NotGiven is just used for evidence and not expected to be used explicitly.

Suggested improvement

It could be made more helpful if no warning was produced. I belive NotGiven could be excluded here

case dd.DummyImplicitClass | dd.SubTypeClass | dd.SameTypeClass => true
with the same motivation as <:< and =:=.

Metadata

Metadata

Assignees

Labels

area:lintingLinting warnings enabled with -W or -Xlintarea:reportingError reporting including formatting, implicit suggestions, etcbetter-errorsIssues concerned with improving confusing/unhelpful diagnostic messagesitype:enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions