Skip to content

Commit 9d5e032

Browse files
committed
handle @unchecked inside type arguments
1 parent fdef860 commit 9d5e032

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,11 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
417417
case tp @ AppliedType(tycon, args) =>
418418
if (tycon.isRef(defn.ArrayClass)) tp.derivedAppliedType(tycon, args.map(erase))
419419
else {
420-
val ignoreWarning = args.forall(p => p.typeSymbol.is(BindDefinedType) || p.isInstanceOf[TypeBounds])
420+
val ignoreWarning = args.forall { p =>
421+
p.typeSymbol.is(BindDefinedType) ||
422+
p.hasAnnotation(defn.UncheckedAnnot) ||
423+
p.isInstanceOf[TypeBounds]
424+
}
421425
if (!ignoreWarning)
422426
warn("type arguments are not checked since they are eliminated by erasure")
423427

tests/patmat/3144b.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
class Test {
22
def f(x: Any): Int = x match {
33
case xs: List[Int] @unchecked => xs.head
4+
case xs: List[Int @unchecked] => xs.head
5+
case xs: Array[List[Int]] => 3
46
case _ => 0
57
}
68
}

0 commit comments

Comments
 (0)