Closed
Description
Compiler version
3.7
Minimized code
//> using options -Vprint:typer -Wunused:all
class C {
def f: Runnable = new Runnable {
def run() = ()
def g = 42
}
}
Output
Dotty is silent but Scala 2 says
unused-priv.scala:7: warning: private method g in <$anon: Runnable> is never used
def g = 42
^
because the method is made private.
Expectation
A warning that the method is unused (because effectively private if not actually).
Note that the inferred type in Scala 2 is the refinement. An expected type is required for the behavior.
As noticed by tpolecat https://mastodon.social/@tpolecat/114078274060499612