Skip to content

Instantly share code, notes, and snippets.

@susisu
Created December 24, 2017 13:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save susisu/79f212977658c19ff2f0755ec5b40b33 to your computer and use it in GitHub Desktop.
Save susisu/79f212977658c19ff2f0755ec5b40b33 to your computer and use it in GitHub Desktop.
trait SourceInfo {
type NoInfoType <: this.type
val NoInfo: NoInfoType
def showMessage(msg: String): String
}
object NoPositionInfo extends PositionInfo(NoPosition) {
override def showMessage(msg: String): String = s"${pos.toString}: $msg"
}
class PositionInfo(val pos: Position) {
type NoInfoType = NoPositionInfo.type
val NoInfo = NoPositionInfo
def showMessage(msg: String): String = s"${pos.toString}: $msg\n${pos.longString}"
}
trait SourceInfo {
type NoInfoType <: this.type
val NoInfo: NoInfoType
def showMessage(msg: String): String
}
object NoPositionInfo extends PositionInfo(NoPosition) with SourceInfo {
override def showMessage(msg: String): String = s"${pos.toString}: $msg"
}
class PositionInfo(val pos: Position) {
self: SourceInfo =>
type NoInfoType = NoPositionInfo.type
val NoInfo = NoPositionInfo
def showMessage(msg: String): String = s"${pos.toString}: $msg\n${pos.longString}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment