I'm reading Scala in depth now. Here is an excerpt from the book:
All path-dependent types are type projections. A path-dependent type
foo.Bar
is rewritten asfoo.type#Bar
by the compiler...In Scala, all type references can be written as projects against named entities. The type scala.String is shorthand for
scala.type#String
where the namescala
refers to the packagescala
and the typeString
is defined by theString
class on the scala package.
Obviously, there isn't scala.String
class, but I failed to reproduce this with Null
.
scala> type N = scala.type#Null
<console>:7: error: type mismatch;
found : type
required: AnyRef
type N = scala.type#Null
So, my questions are as follows. Are path-dependent types type projections? Is it just inner compiler representation or can be expressed in scala code?