Why can't the compiler specify a type parameter for a package object (while it works fine for an object)?
Scala 2.11.4
Foo.scala
trait Echo [T] {
def echo(t: T): Unit
}
trait IntEcho extends Echo[Int] {
def echo(t: Int) = println(t)
}
object echo extends IntEcho
package object echo1 extends IntEcho
After compiling this file and loading it into scala repl, I ran the following test
scala> :t echo.echo _ Int => Unit
scala> :t echo1.echo _ T => Unit
Why isn't T allowed for Int?
+3
source to share