小编dam*_*irv的帖子

使用Precog配置模式的Scala cake-pattern编译错误

关于这个问题,我现在有以下内容:

case class Pet(val name: String)

trait ConfigComponent {
  type Config

  def config: Config
}

trait VetModule extends ConfigComponent {
  type Config <: VetModuleConfig

  def vet: Vet

  trait Vet {
    def vaccinate(pet: Pet)
  }

  trait VetModuleConfig {
    def extra: String
  }

}

trait VetModuleImpl extends VetModule {
  override def vet: Vet = VetImpl

  object VetImpl extends Vet {
    def vaccinate(pet: Pet) = println("Vaccinate:" + pet + " " + config.extra)
  }

}

trait AnotherModule extends ConfigComponent {
  type …
Run Code Online (Sandbox Code Playgroud)

scala compiler-errors existential-type cake-pattern

4
推荐指数
1
解决办法
338
查看次数