Last active
June 7, 2019 19:37
-
-
Save Blaisorblade/3e5a1102c0699f05f1c11333d785a077 to your computer and use it in GitHub Desktop.
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
object Test { | |
abstract class ExprBase { s => | |
type A | |
} | |
abstract class Lit extends ExprBase { s => | |
type A = Int | |
val n: A | |
} | |
def castTest1(e1: ExprBase)(e2: e1.type)(x: e1.A): e2.A = x | |
def castTest2(e1: ExprBase { type A = Int })(e2: e1.type)(x: e1.A): e2.A = x | |
def castTest3(e1: ExprBase)(e2: ExprBase with e1.type)(x: e2.A): e1.A = x | |
def castTest4(e1: ExprBase { type A = Int })(e2: ExprBase with e1.type)(x: e2.A): e1.A = x | |
//fail: | |
// def castTestFail1(e1: ExprBase)(e2: Lit with e1.type)(x: e1.A): e2.A = x | |
// def castTestFail2(e1: ExprBase)(e2: Lit with e1.type)(x: e2.A): e1.A = x | |
def castTestFail3(e1: ExprBase)(e2: Lit with e1.type)(x: e1.A): e2.A = { | |
val y: e1.type with e2.type = e2 | |
val z = x: y.A | |
z | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment