scala / bug

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

Quickfix for method type inserts type before parameter list #12939

Closed coreywoodfield closed 4 months ago

coreywoodfield commented 4 months ago

Reproduction steps

Scala version: 2.13.12

Test.scala:

trait Trait {
  def foo(): Unit
}

class Test[A] extends Trait[A] {
  override def foo() = ???
}

Compiling with -Xsource:3 -quickfix:any prints

Test.scala:7: error: [rewritten by -quickfix] under -Xsource:3, inferred Unit instead of Nothing
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=Test.foo
  override def foo() = ???
               ^
1 error

and updates the file to

trait Trait {
  def foo(): Unit
}

class Test extends Trait {
  override def foo: Nothing() = ???
}

which is incorrect

Problem

The type signature should be added after the parameter list, not before it

som-snytt commented 4 months ago

Thanks for the report.

This has been fixed.

7c7
<   override def foo() = ???
---
>   override def foo(): Nothing = ???

Duplicates https://github.com/scala/bug/issues/12860