Skip to content

False positive unused given in extensions #23125

Open
@WojciechMazur

Description

@WojciechMazur

Compiler version

3.7.0
3.7.1-RC1

Fixed in 3.7.2-RC1-NIGHTLY

Bisect points it was fixed in 32defdf

Minimized code

//> using options -Wunused:all 

trait MonadThrow[F[_]]
extension [T](value: T) def liftTo[F[_]](using MonadThrow[F]): F[T] = ???

trait Api[F[_]]:
  def setMaxAge(value: Int): F[Unit]
  def truncate(): F[Unit]

trait MetaStreamsSyntax:
  extension [F[_]](ms: Api[F])(using MonadThrow[F]) // warns: 
    def withMaxAge(): F[Unit] = 
      val lifted = 0.liftTo[F] // uses MonadThrow
      assert(lifted != null) // to enusre this val is used
      assert(ms != null) // to ensure ms is used
      ???
      
    def truncated(): F[Unit] = 
      ms.truncate() // required to trigger warning, does not warn if ms is not used

Output

[warn] ./example.scala:11:38
[warn] unused implicit parameter
[warn]   extension [F[_]](ms: Api[F])(using MonadThrow[F])
[warn]            

Expectation

Should not warn. Bisected fix should be backported to 3.7.1-RC2 and regression test should be added

Metadata

Metadata

Assignees

Labels

area:lintingLinting warnings enabled with -W or -Xlintitype:bugregressionThis worked in a previous version but doesn't anymorestat:fixed in nightlyThis issue may be present in the latest stable or RC version of Next, but has been since fixed.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions