为什么 T 在扩展类型指示符 C.this.type#T 中是 this.type 的类型投影
Why is T a type projection of this.type in expanded type designator C.this.type#T
trait C {
type T
val x: T
}
扩展到
trait C {
type T
val x: C.this.type#T
}
我熟悉单例类型中的 .type
表示法,但我不确定它如何转换为 C.this.type#T
。例如。 this.type
部分试图通过 C#T
表达什么?
在 Scala 规范中,主要概念是类型投影而不是路径相关类型。
路径相关类型是根据类型投影(和单例类型)定义的。
例如 val c: C
类型 c.T
根据定义是 c.type#T
。
并且 c.x
具有类型 c.T
又名 c.type#T
。
Inside trait C
这种类型(当实例 c
不固定时)可以称为 T
aka this.T
aka this.type#T
aka C.this.T
又名 C.this.type#T
.
trait C {
type T
val x: T
}
扩展到
trait C {
type T
val x: C.this.type#T
}
我熟悉单例类型中的 .type
表示法,但我不确定它如何转换为 C.this.type#T
。例如。 this.type
部分试图通过 C#T
表达什么?
在 Scala 规范中,主要概念是类型投影而不是路径相关类型。
路径相关类型是根据类型投影(和单例类型)定义的。
例如 val c: C
类型 c.T
根据定义是 c.type#T
。
并且 c.x
具有类型 c.T
又名 c.type#T
。
Inside trait C
这种类型(当实例 c
不固定时)可以称为 T
aka this.T
aka this.type#T
aka C.this.T
又名 C.this.type#T
.