forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some of the issues are legitimate
- Loading branch information
Showing
13 changed files
with
158 additions
and
12 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
sealed trait T_A[A, B] | ||
type X = T_A[Byte, Byte] | ||
|
||
case class CC_B[A](a: A) extends T_A[A, X] | ||
|
||
val v_a: T_A[X, X] = CC_B(null) | ||
val v_b = v_a match | ||
case CC_B(_) => 0 // warn: unreachable | ||
case _ => 1 | ||
// for CC_B[A] to match T_A[X, X] | ||
// A := X | ||
// so require X, aka T_A[Byte, Byte] | ||
// which isn't instantiable, outside of null |
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,17 @@ | ||
sealed trait T_B[C, D] | ||
|
||
case class CC_A() | ||
case class CC_B[A, C](a: A) extends T_B[C, CC_A] | ||
case class CC_C[C, D](a: T_B[C, D]) extends T_B[Int, CC_A] | ||
case class CC_E(a: CC_C[Char, Byte]) | ||
|
||
val v_a: T_B[Int, CC_A] = CC_B(CC_E(CC_C(null))) | ||
val v_b = v_a match | ||
case CC_B(CC_E(CC_C(_))) => 0 // warn: unreachable | ||
case _ => 1 | ||
// for CC_B[A, C] to match T_B[C, CC_A] | ||
// C <: Int, ok | ||
// A <: CC_E, ok | ||
// but you need a CC_C[Char, Byte] | ||
// which requires a T_B[Char, Byte] | ||
// which isn't instantiable, outside of null |
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 @@ | ||
sealed trait T_A[A, B] | ||
sealed trait T_B[C] | ||
|
||
case class CC_D[A, C]() extends T_A[A, C] | ||
case class CC_E() extends T_B[Nothing] | ||
case class CC_G[A, C](c: C) extends T_A[A, C] | ||
|
||
val v_a: T_A[Boolean, T_B[Boolean]] = CC_G(null) | ||
val v_b = v_a match { | ||
case CC_D() => 0 | ||
case CC_G(_) => 1 // warn: unreachable | ||
// for CC_G[A, C] to match T_A[Boolean, T_B[Boolean]] | ||
// A := Boolean, which is ok | ||
// C := T_B[Boolean], | ||
// which isn't instantiable, outside of null | ||
} |
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,9 @@ | ||
sealed trait T_A[A] | ||
case class CC_B[A](a: T_A[A]) extends T_A[Byte] | ||
case class CC_E[A](b: T_A[A]) extends T_A[Byte] | ||
|
||
val v_a: T_A[Byte] = CC_E(CC_B(null)) | ||
val v_b: Int = v_a match { // warn: not exhaustive | ||
case CC_E(CC_E(_)) => 0 | ||
case CC_B(_) => 1 | ||
} |
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,14 @@ | ||
sealed trait T_A[A] | ||
case class CC_B[A](a: T_A[A], c: T_A[A]) extends T_A[Char] | ||
case class CC_C[A]() extends T_A[A] | ||
case class CC_G() extends T_A[Char] | ||
|
||
val v_a: T_A[Char] = CC_B(CC_G(), CC_C()) | ||
val v_b: Int = v_a match { // warn: not exhaustive | ||
case CC_C() => 0 | ||
case CC_G() => 1 | ||
case CC_B(CC_B(_, _), CC_C()) => 2 | ||
case CC_B(CC_C(), CC_C()) => 3 | ||
case CC_B(_, CC_G()) => 4 | ||
case CC_B(_, CC_B(_, _)) => 5 | ||
} |
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 @@ | ||
sealed trait T_A[B] | ||
sealed trait T_B[C] | ||
case class CC_B[C]() extends T_A[T_B[C]] | ||
case class CC_C[B, C](c: T_A[B], d: T_B[C]) extends T_B[C] | ||
case class CC_E[C]() extends T_B[C] | ||
|
||
val v_a: T_B[Int] = CC_C(null, CC_E()) | ||
val v_b: Int = v_a match { // warn: not exhaustive | ||
case CC_C(_, CC_C(_, _)) => 0 | ||
case CC_E() => 5 | ||
} |
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,17 @@ | ||
sealed trait Foo | ||
case class Foo1() extends Foo | ||
case class Foo2[A, B]() extends Foo | ||
|
||
sealed trait Bar[A, B] | ||
case class Bar1[A, C, D](a: Bar[C, D]) extends Bar[A, Bar[C, D]] | ||
case class Bar2[ C, D](b: Bar[C, D], c: Foo) extends Bar[Bar1[Int, Byte, Int], Bar[C, D]] | ||
|
||
class Test: | ||
def m1(bar: Bar[Bar1[Int, Byte, Int], Bar[Char, Char]]): Int = bar match | ||
case Bar1(_) => 0 | ||
case Bar2(_, Foo2()) => 1 | ||
def t1 = m1(Bar2(null, Foo1())) | ||
// for Bar2[C, D] to match the scrutinee | ||
// C := Char and D := Char | ||
// which requires a Bar[Char, Char] | ||
// which isn't instantiable, outside of null |
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,8 @@ | ||
sealed trait Foo[A] | ||
case class Bar[C](x: Foo[C]) extends Foo[C] | ||
case class End[B]() extends Foo[B] | ||
class Test: | ||
def m1[M](foo: Foo[M]): Int = foo match // warn: not exhaustive | ||
case End() => 0 | ||
case Bar(End()) => 1 | ||
def t1 = m1[Int](Bar[Int](Bar[Int](End[Int]()))) |
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,8 @@ | ||
sealed trait Foo[A] | ||
case class Bar[C](x: Foo[C]) extends Foo[Int] | ||
case class End[B]() extends Foo[B] | ||
class Test: | ||
def m1[M](foo: Foo[M]): Int = foo match // warn: not exhaustive | ||
case End() => 0 | ||
case Bar(End()) => 1 | ||
def t1 = m1[Int](Bar[Int](Bar[Int](End[Int]()))) |
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,8 @@ | ||
sealed trait Foo[A] | ||
case class Bar[C](x: Foo[C]) extends Foo[Int] | ||
case class End[B]() extends Foo[B] | ||
class Test: | ||
def m1[M](foo: Foo[M]): Int = foo match | ||
case End() => 0 | ||
case Bar(_) => 1 | ||
def t1 = m1[Int](Bar[Int](Bar[Int](End[Int]()))) |
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,9 @@ | ||
sealed trait Foo[A[_]] | ||
|
||
case class Bar[C[_], X](x: C[X]) extends Foo[C] | ||
case class End[B[_]]() extends Foo[B] | ||
|
||
class Test: | ||
def foo[M[_]](foo: Foo[M]): Int = foo match | ||
case End() => 0 | ||
case Bar(_) => 1 |
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,9 @@ | ||
sealed trait A[+T0] | ||
case class A1[+T1](t1: T1) extends A[T1] | ||
case class A2[+T2](t2: T2) extends A[T2] | ||
sealed trait B[+T3] { type AA[+U] <: A[U] ; def a: AA[T3] } | ||
object B { def unapply[T4](b: B[T4]): Some[b.AA[T4]] = Some(b.a) } | ||
class Test: | ||
def m1[X](b: B[X]): X = b match | ||
case B(A1(v1)) => v1 | ||
case B(A2(v2)) => v2 |