Closed
Description
I'm getting spurious warnings for the following example code with Scala 2.13 & -Xsource:2.13
:
object example {
trait ModuleBase
trait Binding
trait ModuleMake[T <: ModuleBase] {
def make(bindings: Set[Binding]): T
final def empty: T = make(Set.empty)
}
final class X(s: Set[Binding]) extends ModuleBase
object X {
def make(s: Set[Binding]): X = new X(s)
implicit val moduleApi: ModuleMake[X] = X.make
}
}
[warn] example.scala:16:47: Eta-expansion performed to meet expected type example.ModuleMake[example.X], which is SAM-equivalent to Set[example.Binding] => example.X,
[warn] even though trait ModuleMake is not annotated with `@FunctionalInterface`;
[warn] to suppress warning, add the annotation or write out the equivalent function literal.
According to scala -W
, Xlint:eta-sam
warning must fire only for Java-defined interfaces non-annotated , but ModuleMake
is a native Scala-defined trait and probably shouldn't trigger the warning.
-Xlint:eta-sam Warn on eta-expansion to meet a Java-defined functional interface that is not explicitly annotated with @FunctionalInterface.