-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Drop refinements in approxParent (refineUsingParent)
This allows classes that can be refined (non-final, non-case) to be considered subtypes of a refined type, and thus avoid being dropped as SpaceEngine's decompose.
- Loading branch information
Showing
7 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
abstract sealed class ||[+A, +B] extends Product with Serializable | ||
final case class LHS[+A, +B](value: A) extends (A || B) | ||
final case class RHS[+A, +B](value: B) extends (A || B) | ||
|
||
abstract sealed class A { type Self } | ||
abstract class B extends A | ||
final class C extends B { type Self = C } | ||
|
||
class Test: | ||
def t1[T <: A { type Self = T }](x: String || T): Unit = x match | ||
case RHS(_) => () | ||
case LHS(_) => () |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
abstract sealed class ||[+A, +B] extends Product with Serializable | ||
final case class LHS[+A, +B](value: A) extends (A || B) | ||
final case class RHS[+A, +B](value: B) extends (A || B) | ||
|
||
abstract sealed class A { type Self } | ||
object B extends A | ||
|
||
class Test: | ||
def t1[T <: A { type Self = T }](x: String || T): Unit = x match | ||
case RHS(_) => () // warn: unreachable | ||
case LHS(_) => () |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
abstract sealed class ||[+A, +B] extends Product with Serializable | ||
final case class LHS[+A, +B](value: A) extends (A || B) | ||
final case class RHS[+A, +B](value: B) extends (A || B) | ||
|
||
abstract sealed class A { type Self } | ||
abstract class B extends A | ||
final class C extends B { type Self = C } | ||
|
||
class Test: | ||
def t2[T <: A { type Self = T; type I = A }](x: String || T): Unit = x match | ||
case RHS(_) => () | ||
case LHS(_) => () | ||
|
||
def t3[T <: A { type I = A; type Self = T }](x: String || T): Unit = x match | ||
case RHS(_) => () | ||
case LHS(_) => () |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
object ReachableUnreachableCase { | ||
|
||
sealed trait SuperTrait { | ||
type Self | ||
} | ||
|
||
trait SubTrait extends SuperTrait | ||
|
||
case class Foo() extends SubTrait { | ||
type Self = Foo | ||
} | ||
|
||
def printError[T <: SuperTrait { type Self = T }](x: Either[String, T]): Unit = { | ||
x match { | ||
case Right(_) => println("No error found") | ||
case Left(message) => println(message) | ||
} | ||
} | ||
|
||
@main def main(): Unit = { | ||
printError(Right(Foo())) | ||
printError(Left("Error!")) | ||
} | ||
} |