Last active
August 29, 2015 14:11
-
-
Save johnynek/dd4351f158b13a1db130 to your computer and use it in GitHub Desktop.
Bug with dependent types in scala 2.10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Path { | |
type A | |
} | |
trait Reader { self => | |
def read(p: Path): Option[p.A] | |
def orElse(that: Reader): Reader = ComposedReader(this, that) | |
} | |
case class ComposedReader(first: Reader, second: Reader) extends Reader { | |
// this works | |
def read(p: Path): Option[p.A] = first.read(p).orElse(second.read(p)) | |
/* this gives the error below | |
def read(p: Path) = first.read(p).orElse(second.read(p)) | |
*/ | |
} | |
/** | |
* This gives me a confusing message in scala 2.10.4: | |
[tw-mbp-oscar deptype-bug]$ scalac test.scala | |
test.scala:9: error: type mismatch; | |
found : Option[p.A] | |
required: Option[p.A] | |
def read(p: Path) = self.read(p).orElse(that.read(p)) | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment