Skip to content

Commit 7c7d7f4

Browse files
committed
Fix #11118: check irrefutable pattern def in 3.0
After #10793, we can perform the check in 3.0
1 parent d8aab99 commit 7c7d7f4

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Checking.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,6 @@ trait Checking {
700700
def check(pat: Tree, pt: Type): Boolean = (pt <:< pat.tpe) || fail(pat, pt)
701701

702702
def recur(pat: Tree, pt: Type): Boolean =
703-
!sourceVersion.isAtLeast(`3.1`) || // only for 3.1 for now since mitigations work only after this PR
704703
pt.hasAnnotation(defn.UncheckedAnnot) || {
705704
patmatch.println(i"check irrefutable $pat: ${pat.tpe} against $pt")
706705
pat match {

tests/neg/i11118.check

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- Error: tests/neg/i11118.scala:2:6 -----------------------------------------------------------------------------------
2+
2 | val (a,b) = (1,2,3) // error
3+
| ^
4+
| this case is unreachable since type (Int, Int, Int) is not a subclass of class Tuple2

tests/neg/i11118.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class Foo {
2+
val (a,b) = (1,2,3) // error
3+
}

0 commit comments

Comments
 (0)