Skip to content

Commit 74f0c8f

Browse files
committed
remove @unchecked from exhaustivity check
1 parent dea5434 commit 74f0c8f

File tree

7 files changed

+3
-24
lines changed

7 files changed

+3
-24
lines changed

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

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -405,35 +405,22 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
405405
Prod(pat.tpe.stripAnnots, fun.tpe.widen, fun.symbol, pats.map(project), irrefutable(fun))
406406
case Typed(pat @ UnApply(_, _, _), _) => project(pat)
407407
case Typed(expr, tpt) =>
408-
val unchecked = expr.tpe.hasAnnotation(ctx.definitions.UncheckedAnnot)
409-
def warn(msg: String): Unit = if (!unchecked) ctx.warning(UncheckedTypePattern(msg), tpt.pos)
410-
Typ(erase(expr.tpe.stripAnnots)(warn), true)
408+
Typ(erase(expr.tpe.stripAnnots), true)
411409
case _ =>
412410
debug.println(s"unknown pattern: $pat")
413411
Empty
414412
}
415413

416414
/* Erase a type binding according to erasure semantics in pattern matching */
417-
def erase(tp: Type)(implicit warn: String => Unit): Type = tp match {
415+
def erase(tp: Type): Type = tp match {
418416
case tp @ AppliedType(tycon, args) =>
419417
if (tycon.isRef(defn.ArrayClass)) tp.derivedAppliedType(tycon, args.map(erase))
420-
else {
421-
val ignoreWarning = args.forall { p =>
422-
p.typeSymbol.is(BindDefinedType) ||
423-
p.hasAnnotation(defn.UncheckedAnnot) ||
424-
p.isInstanceOf[TypeBounds]
425-
}
426-
if (!ignoreWarning)
427-
warn("type arguments are not checked since they are eliminated by erasure")
428-
429-
tp.derivedAppliedType(tycon, args.map(t => WildcardType))
430-
}
418+
else tp.derivedAppliedType(tycon, args.map(t => WildcardType))
431419
case OrType(tp1, tp2) =>
432420
OrType(erase(tp1), erase(tp2))
433421
case AndType(tp1, tp2) =>
434422
AndType(erase(tp1), erase(tp2))
435423
case tp: RefinedType =>
436-
warn("type refinement is not checked since it is eliminated by erasure")
437424
tp.derivedRefinedType(erase(tp.parent), tp.refinedName, WildcardType)
438425
case _ => tp
439426
}

tests/patmat/3144.check

Lines changed: 0 additions & 2 deletions
This file was deleted.

tests/patmat/3144b.check

Lines changed: 0 additions & 2 deletions
This file was deleted.

tests/patmat/enum-HList.check

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/patmat/enum-Tree.check

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/patmat/t3683.check

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/patmat/t3683a.check

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
8: Pattern Match Exhaustivity
21
14: Pattern Match Exhaustivity: XX()

0 commit comments

Comments
 (0)