Created
December 8, 2020 14:26
-
-
Save pedrofurla/89facaa14ef020f7480145136f513576 to your computer and use it in GitHub Desktop.
Stackoverflow 65178794 (AUX Pattern, path dependency)
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
sealed trait Kind | |
case object B extends Kind | |
case object C extends Kind | |
sealed trait Test { | |
type K <: Kind | |
val kind: K | |
} | |
object Test { | |
type Aux[KK <: Kind] = Test { type K = KK } | |
def test[KK <: Kind](kk: KK): Aux[KK] = new Test{ type K = KK; val kind = kk } | |
} | |
sealed trait Suite{ | |
type K <: Kind | |
val kind: K | |
val tests: List[Test.Aux[K]] | |
} | |
object SuiteB extends Suite { | |
type K = B.type | |
val kind:K = B | |
val tests = List(Test.test(B), Test.test(B)) | |
} | |
object SuiteC extends Suite { | |
type K = C.type | |
val kind:K = C | |
val tests = List(Test.test(C), Test.test(C)) | |
} | |
def runSuite(suite: Suite): Unit = { | |
val x: suite.K = suite.kind | |
suite match { | |
case s@SuiteB => | |
val tests: List[Test.Aux[B.type]] = s.tests | |
// | |
case s@SuiteC => | |
val tests: List[Test.Aux[C.type]] = s.tests | |
// | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment