Skip to content

-Wunused gives endless false positives on macros #16863

Closed
@markehammons

Description

@markehammons

Compiler version

3.3.0-RC2

Minimized code

Unused implicit parameter

import scala.quoted.* 

def fn(using Quotes) = 
	val x = Expr(1)
	'{$x + 2}

https://scastie.scala-lang.org/mfwnZy5NSjW9nGh43ufJqQ

import scala.quoted.* 

def fn[A](using Quotes, Type[A]) = 
	val numeric = Expr.summon[Numeric[A]].getOrElse(???)
	'{$numeric.fromInt(3)}

https://scastie.scala-lang.org/6VG2SNfEQCCo7002RzYlfg

Unused local definition

import scala.quoted.* 

def fn[A](expr: Expr[Any])(using Quotes) = 
	val imp = expr match 
		case '{${_}: a} => Expr.summon[Numeric[a]]

	println(imp)

https://scastie.scala-lang.org/QCGlRnK7QrKX0eIIq7TjiQ

Unused import

import scala.quoted.* 
import scala.compiletime.asMatchable

def fn[A](using Quotes, Type[A]) = 
  import quotes.reflect.*
  val imp = TypeRepr.of[A].widen.asMatchable match 
    case Refinement(_,_,_) => ()
  println(imp)

https://scastie.scala-lang.org/X0hFgQK3Rz2K5jVXDyD2BA

Output

There are false positives on non-use of quotes and type in these examples.

Expectation

There shouldn't be false positives.

Metadata

Metadata

Assignees

Labels

area:lintingLinting warnings enabled with -W or -Xlintitype:bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions