Skip to content

-Wunused:locals gives false positives for some calls to transparent inline functions #17753

Closed
@matil019

Description

@matil019

Compiler version

3.3.0

Minimized code

//> using option -Wunused:locals
//> using scala 3.3.0

class PartiallyApplied[A] {
  transparent inline def func[B](): Nothing = ???
}

def call[A] = new PartiallyApplied[A]

def good = call[Int].func[String]()
def bad = { call[Int].func[String]() }

Output

-- Warning: /home/...snip.../Foo.scala:11:34 -------------------
11 |def bad = { call[Int].func[String]() }
   |                                  ^
   |                                  unused local definition
1 warning found

Expectation

No warnings are issued.

Other

This affects Monocle's macros such as GenLens.

I'm not certain whether or not my example can be minimized further. Interestingly, calling a transparent inline function directly doesn't trigger any warnings.

//> using option -Wunused:locals
//> using scala 3.3.0

transparent inline def func2[A]() = ???

def good2a = func2[Int]()
def good2b = { func2[Int]() }

Metadata

Metadata

Assignees

No one assigned

    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