-
Notifications
You must be signed in to change notification settings - Fork 21
Closed
scala/scala
#9693Description
I tried following snippet on REPL.
trait Foo[A, B]
object Foo {
type Bar[A] = Foo[A, _]
}
trait Base[M[_]] {
def method(in: M[_]): Unit
}
class Concrete extends Base[Foo.Bar] {
def method(in: Foo.Bar[_]): Unit = {}
}
trait Template[M[_]] {
def toBeImplemented: Base[M]
def mark[A]: M[A]
def method2(): Unit = {
toBeImplemented.method(mark[Nothing])
}
}
class Impl extends Template[Foo.Bar] {
def toBeImplemented: Base[Foo.Bar] = new Concrete
def mark[A]: Foo.Bar[A] = new Foo[A, Nothing] {}
}
(new Impl).method2()
This compiles and causes java.lang.AbstractMethodError: Concrete.method(Ljava/lang/Object;)V
.
However, If I change type Bar[A] = Foo[A, _]
to type Bar[A] = Foo[A, Nothing]
, the snippet run successfully. (no error occured)
I think the first snippet should not compile.
environment
- Scala version: 2.11.8 and 2.12.2
- Java version: 1.8.0_77