Created
January 15, 2018 14:37
-
-
Save slavaschmidt/504c4a45205953b734208b363e7d25fe to your computer and use it in GitHub Desktop.
An example of an abstract class definition breaking compilation of spray-shapeless dependent code
This file contains hidden or 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
| import fommil.sjs.FamilyFormats | |
| import shapeless.cachedImplicit | |
| import spray.json.{DefaultJsonProtocol, RootJsonFormat} | |
| sealed trait SomeTrait { | |
| def key: String | |
| def value: String | |
| } | |
| // compiles | |
| class SomeClass(override val key: String, override val value: String) extends SomeTrait | |
| case class SomeCaseClass(override val key: String, override val value: String) extends SomeTrait | |
| case object SomeSingleton extends SomeClass("b", "c") | |
| object TestValue { | |
| val a = new SomeClass("a", "b") | |
| val b = SomeCaseClass("a", "b") | |
| val d = SomeSingleton | |
| } | |
| /* | |
| abstract class SomeAbstractClass(override val key: String, override val value: String) extends SomeTrait // does not compile | |
| case object SomeAbstractSingleton extends SomeAbstractClass("b", "c") | |
| */ | |
| object TestFormats extends DefaultJsonProtocol with FamilyFormats { | |
| implicit val crmReasonFormats: RootJsonFormat[SomeTrait] = cachedImplicit | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment