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