Open
Description
Compiler version
3.3.0
Minimized code
class Box[T](t: T)
def f[T](l: List[Box[T]] = List.empty): Unit = ???
def g[T] = f[T]()
Output
[error] ./inference2.scala:5:12
[error] Found: List[Box[Nothing]]
[error] Required: List[Box[T]]
[error] def g[T] = f[T]()
[error] ^^^^
Syntax tree after typer:
package <empty> {
trait Box[T >: Nothing <: Any]() extends Object {
T
}
final lazy module val inference2$package: inference2$package =
new inference2$package()
final module class inference2$package() extends Object() {
this: inference2$package.type =>
def f[T >: Nothing <: Any](l: List[Box[T]]): Unit = ???
def f$default$1[T >: Nothing <: Any]: List[Box[Nothing]] =
List.empty[Box[Nothing]]
def g[T >: Nothing <: Any]: Unit = f[T](inference2$package.f$default$1[T])
}
}
Expectation
The return type of f$default$1
should not be List[Box[Nothing]]
. I believe it should be List[Box[T]]
, although List[Nothing]
would also work fine in this case.