In your definition, IntAlias
is a member of class Parent
. So without an instance of Parent
you cannot access that member. You can read your second case as val i2: this.IntAlias = 1
. Here you have access to the instance this
.
This is similar to the following for values instead of types:
class Parent {
def intValue: Int = 1234
}
class Child(val x: Int = intValue) extends Parent // does not compile
So you must put that member in a different scope, for example a companion object:
object Parent {
type IntAlias = Int
}
import Parent.IntAlias
class Child(val i1: IntAlias = 3) extends Parent {
val i2: IntAlias = 1
}