@@ -1686,7 +1686,8 @@ trait Applications extends Compatibility {
1686
1686
if selType <:< unapplyArgType then
1687
1687
unapp.println(i " case 1 $unapplyArgType ${ctx.typerState.constraint}" )
1688
1688
fullyDefinedType(unapplyArgType, " pattern selector" , tree.srcPos)
1689
- selType.dropAnnot(defn.UncheckedAnnot ) // need to drop @unchecked. Just because the selector is @unchecked, the pattern isn't.
1689
+ if selType.isNothingType then unapplyArgType
1690
+ else selType.dropAnnot(defn.UncheckedAnnot ) // need to drop @unchecked. Just because the selector is @unchecked, the pattern isn't.
1690
1691
else
1691
1692
if ! ctx.mode.is(Mode .InTypeTest ) then
1692
1693
checkMatchable(selType, tree.srcPos, pattern = true )
@@ -1708,7 +1709,7 @@ trait Applications extends Compatibility {
1708
1709
val unapplyPatterns = UnapplyArgs (unapplyApp.tpe, unapplyFn, unadaptedArgs, tree.srcPos)
1709
1710
.typedPatterns(qual, this )
1710
1711
val result = assignType(cpy.UnApply (tree)(newUnapplyFn, unapplyImplicits(dummyArg, unapplyApp), unapplyPatterns), ownType)
1711
- if (ownType.stripped eq selType.stripped) || ownType.isError then result
1712
+ if (ownType.stripped eq selType.stripped) || selType.isNothingType || ownType.isError then result
1712
1713
else tryWithTypeTest(Typed (result, TypeTree (ownType)), selType)
1713
1714
case tp =>
1714
1715
val unapplyErr = if (tp.isError) unapplyFn else notAnExtractor(unapplyFn)
0 commit comments