我的问题很简单。
为什么这段代码会出错,
abstract class A {
type T <: A.Inner
def toT: T = new A.Inner(this)
}
object A {
class Inner(a: A)
}
// Exiting paste mode, now interpreting.
<console>:16: error: type mismatch;
found : A.Inner
required: A.this.T
def toT: T = new A.Inner(this)
^
而这段代码没有?
abstract class A {
type T = A.Inner
def toT: T = new A.Inner(this)
}
object A {
class Inner(a: A)
}
// Exiting paste mode, now interpreting.
defined class A
defined object A
A.Inner <: A.Inner
. 不是吗?