我有以下内容:
case class Location(name: String, level: Location.Level)
object Location {
trait Level
case object City extends Level
case object State extends Level
}
如果我尝试访问City
(从另一个源文件),我会收到一条错误消息,例如
found : model.Location.City.type
required: model.Level
我可以想到一些变通办法,但我想知道是否有办法让我的名字保持不变,即我想City
通过键入来访问Location.City
。
编辑:
我正在像这样访问它:
import the.package.name._
Location.City