-
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.
Backport "Handle TupleXXL in match analysis" to LTS (#20791)
Backports #19212 to the LTS branch. PR submitted by the release tooling. [skip ci]
- Loading branch information
Showing
9 changed files
with
116 additions
and
15 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
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,20 @@ | ||
//> using options -Werror | ||
|
||
class Test: | ||
def t1: Unit = | ||
(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23) match | ||
case (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21, x22, x23) => | ||
def t2: Unit = | ||
(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23) match | ||
case (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21, x22, x23, x24) => | ||
def t3: Unit = | ||
(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24) match | ||
case (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21, x22, x23) => | ||
|
||
object Main: | ||
def main(args: Array[String]): Unit = { | ||
val t = new Test | ||
t.t1 | ||
try { t.t2; ??? } catch case _: MatchError => () | ||
try { t.t3; ??? } catch case _: MatchError => () | ||
} |
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 @@ | ||
//> using options -Werror | ||
|
||
class Test: | ||
val x = 42 | ||
val tup23 = (x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x) | ||
|
||
tup23 match { | ||
case (_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => "Tuple Pattern" | ||
} |
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 @@ | ||
//> using options -Werror | ||
|
||
class Test: | ||
val (_, ( | ||
_, _, _, _, _, _, _, _, _, _, // 10 | ||
_, _, _, _, _, _, _, _, _, _, // 20 | ||
_, c22, _ // 23 | ||
)) = // nested pattern has 23 elems | ||
(0, ( | ||
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, | ||
1, 2, 3, 4, 5, 6, 7, 8, 9, 20, | ||
1, 2, 3 | ||
)) // ok, exhaustive, reachable, conforming and irrefutable |
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 @@ | ||
//> using options -Werror | ||
|
||
class Test: | ||
def t1(y: ( | ||
Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, | ||
"Bob", Int, 33, Int, | ||
Int, Int, Int, Int, Int, Int, Int, Int, Int, Int) | ||
): Unit = y match | ||
case b @ (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, | ||
"Bob", y1, 33, y2, | ||
z0, z1, z2, z3, z4, z5, z6, z7, z8, z9) | ||
=> // was: !!! spurious unreachable case warning | ||
() | ||
case _ => () |
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 @@ | ||
|
||
|
||
class Test: | ||
def t1(y: ( | ||
Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, | ||
"Bob", Int, 33, Int, | ||
Int, Int, Int, Int, Int, Int, Int, Int, Int, Int) | ||
): Unit = y match | ||
case b @ (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, | ||
"Bob", y1, 33, y2, | ||
z0, z1, z2, z3, z4, z5, z6, z7, z8, z9) | ||
=> () | ||
case b @ (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, // warn: unreachable | ||
"Bob", y1, 33, y2, | ||
z0, z1, z2, z3, z4, z5, z6, z7, z8, z9) | ||
=> () | ||
case _ => () |