scala / scala3

The Scala 3 compiler, also known as Dotty.
https://dotty.epfl.ch
Apache License 2.0
5.72k stars 1.04k forks source link

3.5.0-RC2 regression: false positive unused warning on given import with wildcard #20860

Open SethTisue opened 2 days ago

SethTisue commented 2 days ago

I'm on vacation and don't have time to really think about this or dig deeper, but since it's a regression I thought I should report it promptly.

//> using scala 3.5.0-RC2
//> using option -Wunused:imports

def test =
  import Ordering.Implicits.{given Ordering[?]}
  summon[Ordering[Seq[Int]]]

on 3.5.0-RC2 this gives:

[warn] unused import
[warn]   import Ordering.Implicits.{given Ordering[?]}
[warn]                              ^^^^^^^^^^^^^^^^^

but the import is definitely used — the code doesn't compile without it

note that I can write import Ordering.Implicits.seqOrdering instead, which is better code anyway, the original code is admittedly peculiar (I don't remember what I might have been thinking when I wrote it)

minimized from https://github.com/SethTisue/Project-Euler/blob/main/src/test/scala/54.scala

som-snytt commented 2 days ago

warns with https://github.com/scala/scala3/commit/975df4a136910fe0451514ef0dc34aa29a60aef7

of the refactor https://github.com/scala/scala3/pull/20321

(I was going to follow up for some ticket but haven't looked yet.)

Edit: maybe the refactor tightened some screws; the PR just tweaks by half a turn.