- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Why is type checking not transparent wrt. type alias?
Sat, 2010-08-21, 14:48
Hello,
I'm struggling to understand why the following session produces
compilation error:
scala> type Nil = Nil.type
defined type alias Nil
scala> val n :Nil = Nil
:6: error: type mismatch;
found : n.type (with underlying type Nil)
required: Nil
val n :Nil = Nil
^
However if I don't use type alias, it works no problem:
scala> val n:Nil.type = Nil
n: scala.collection.immutable.Nil.type = List()
Thank you in advance for your help,
Eugene.