@@ -1689,7 +1689,8 @@ trait Applications extends Compatibility {
16891689 if selType <:< unapplyArgType then
16901690 unapp.println(i " case 1 $unapplyArgType ${ctx.typerState.constraint}" )
16911691 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.
16931694 else
16941695 if ! ctx.mode.is(Mode .InTypeTest ) then
16951696 checkMatchable(selType, tree.srcPos, pattern = true )
@@ -1711,7 +1712,7 @@ trait Applications extends Compatibility {
17111712 val unapplyPatterns = UnapplyArgs (unapplyApp.tpe, unapplyFn, unadaptedArgs, tree.srcPos)
17121713 .typedPatterns(qual, this )
17131714 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
17151716 else tryWithTypeTest(Typed (result, TypeTree (ownType)), selType)
17161717 case tp =>
17171718 val unapplyErr = if (tp.isError) unapplyFn else notAnExtractor(unapplyFn)
0 commit comments