scala> List(42, "")
^
warning: a type was inferred to be `Any`; this may indicate a programming error.
val res0: List[Any] = List(42, "")
scala> val b = collection.mutable.ListBuffer.empty[Int]
val b: scala.collection.mutable.ListBuffer[Int] = ListBuffer()
scala> def f(i: Int, t: Boolean) = if (t) b += i
def f(i: Int, t: Boolean): Any
Problem
It inferred Any, so it should tell me so. It may indicate a programming error!
In this case, b.+= is not Unit. The RHS and the result of f is inferred Any.
Reproduction steps
Scala version: 2.13.11
Problem
It inferred
Any
, so it should tell me so. It may indicate a programming error!In this case,
b.+=
is notUnit
. The RHS and the result off
is inferredAny
.Noticed at https://github.com/scala/scala/pull/10466#issuecomment-1636059262