scala / bug

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

Missing arity warnings in unrelated super traits #12853

Open som-snytt opened 10 months ago

som-snytt commented 10 months ago

Reproduction steps

Scala version: 2.13.12

➜  scala git:(issue/12851-namepos) cat test/files/neg/t12851b/T_1.scala

trait T1 {
  def f: Int
  def g(): Int
}
trait T2 {
  def f() = 42
  def g = 42
}
➜  scala git:(issue/12851-namepos) cat test/files/neg/t12851b/C_2.scala
// scalac: -Werror
class C extends T1 with T2

Problem

➜  scala git:(issue/12851-namepos) scalac -d /tmp -cp /tmp test/files/neg/t12851b/C_2.scala
warning: method with a single empty parameter list overrides method without any parameter list
1 warning
➜  scala git:(issue/12851-namepos) scalac -d /tmp test/files/neg/t12851b/*.scala
test/files/neg/t12851b/T_1.scala:8: warning: method with a single empty parameter list overrides method without any parameter list
  def f() = 42
      ^
1 warning

should offer both warnings, whether compiled together or separately:

➜  scala git:(issue/12851-namepos) skalac -d /tmp -cp /tmp test/files/neg/t12851b/C_2.scala
test/files/neg/t12851b/C_2.scala:2: warning: method (method f in trait T2) with a single empty parameter list overrides method without any parameter list
class C extends T1 with T2
      ^
test/files/neg/t12851b/C_2.scala:2: warning: method (method g in trait T2) without a parameter list overrides a method with a single empty one
class C extends T1 with T2
      ^
2 warnings
➜  scala git:(issue/12851-namepos) skalac -d /tmp test/files/neg/t12851b/*.scala
test/files/neg/t12851b/C_2.scala:2: warning: method (method f in trait T2) with a single empty parameter list overrides method without any parameter list
class C extends T1 with T2
      ^
test/files/neg/t12851b/C_2.scala:2: warning: method (method g in trait T2) without a parameter list overrides a method with a single empty one
class C extends T1 with T2
      ^
2 warnings

Noticed at https://github.com/scala/bug/issues/12851