Reputation: 613
This does not compile:
trait FileSystem {
type P <: Path[this.type]
}
trait Path[S <: FileSystem] { self: fileSystem.P =>
val fileSystem: S
}
How can a self-type constraint be dependent on a value member in that trait?
Upvotes: 4
Views: 193
Reputation: 3120
Well I wouldn't do it, but you can; just put Path
inside FileSystem
:
trait AnyPath[S <: FileSystem] { self: S#P =>
val fileSystem: S
}
trait FileSystem { thisFileSystem =>
type P <: Path
trait Path extends AnyPath[thisFileSystem.type]{ self: thisFileSystem.P =>
lazy val fileSystem = thisFileSystem
}
}
case object SomeFileSystem extends FileSystem {
type P = ReallyConcretePath
case class ReallyConcretePath() extends Path
}
Upvotes: 1
Reputation: 9158
It cannot (and not sure what it would mean).
trait FileSystem {
type P <: Path[this.type]
}
trait Path[S <: FileSystem] { self: S#P =>
val fileSystem: S
}
Upvotes: 4