【发布时间】:2014-03-14 14:27:15
【问题描述】:
为什么 Scala 会这样?
更重要的是,如何修复此代码?
我问这个问题是因为我有复杂的类型,需要在几个子类的构造函数声明中使用,我想留下 DRY。
class Parent{
type IntAlias=Int
}
class Child (val i1:IntAlias=3) extends Parent{ //Compilation error, why ?
val i2:IntAlias= 1 //No problem here!
}
编译器错误:
not found: type IntAlias
class Child (val i1:IntAlias=3) extends Parent{
^
【问题讨论】:
标签: scala type-alias