Open
Description
Reproduction steps
Scala version: 2.13.11-20230420-132558-28eef15
import annotation._
trait TypesApi
trait Types extends TypesApi with TypeConstraints {
this: Table =>
@tailrec
final def f(i: Int): Int = f(i + 1)
}
abstract class Table extends Types
trait TypeConstraints {
this: Table =>
@tailrec
private final def f(i: Int): Int = f(i - 1)
}
Problem
Scala 2 says
badshadow.scala:19: warning: private method f in trait TypeConstraints is never used
private final def f(i: Int): Int = f(i - 1)
^
badshadow.scala:19: error: @tailrec annotated method contains no recursive calls
private final def f(i: Int): Int = f(i - 1)
^
1 warning
1 error
Scala 3 says
-- [E049] Reference Error: badshadow.scala:19:37 -----------------------------------------------------------------------
19 | private final def f(i: Int): Int = f(i - 1)
| ^
| Reference to f is ambiguous.
| It is both defined in trait TypeConstraints
| and inherited subsequently in trait TypeConstraints
|
| longer explanation available when compiling with `-explain`
-- Warning: badshadow.scala:19:20 --------------------------------------------------------------------------------------
19 | private final def f(i: Int): Int = f(i - 1)
| ^
| unused private member
1 warning found
1 error found