scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
230 stars 21 forks source link

quickfixes sometimes don't get successfully applied #12941

Closed coreywoodfield closed 4 months ago

coreywoodfield commented 4 months ago

Reproduction steps

Scala version: 2.13.12

in Test1.scala:

trait Trait[A] {
  def foo: Option[A]
}
object Test1 extends Trait[Any] {
  def foo = None
}

in Test2.scala:

object Test2 {
  def one = Test1.foo
}

scala-2.13.12/bin/scalac -quickfix:any -Xsource:3 Test2.scala Test1.scala prints

Test1.scala:5: error: [rewritten by -quickfix] under -Xsource:3, inferred Option[Any] instead of None.type
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=Test1.foo
  def foo = None
      ^
1 error

but it doesn't actually change Test1.scala at all. If you swap the order the files are provided in the command line, or if you remove the .foo in Test2.scala, the quickfix for Test1.scala gets applied as expected. I.e., scala-2.13.12/bin/scalac -quickfix:any -Xsource:3 Test1.scala Test2.scala has the same output but it actually updates Test1.scala.

Problem

The order of source files passed to scalac shouldn't affect whether quickfixes are applied or not

SethTisue commented 4 months ago

Another nice catch — thanks for the report!

som-snytt commented 4 months ago

Since 2/4/24 (American style) was Willie Mays Day in SF (https://www.mlb.com/news/willie-mays-day-proclaimed-by-san-francisco-mayor):

https://en.wikipedia.org/wiki/The_Catch_(baseball)