@@ -1686,7 +1686,8 @@ trait Applications extends Compatibility {
16861686 if selType <:< unapplyArgType then
16871687 unapp.println(i " case 1 $unapplyArgType ${ctx.typerState.constraint}" )
16881688 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.
16901691 else
16911692 if ! ctx.mode.is(Mode .InTypeTest ) then
16921693 checkMatchable(selType, tree.srcPos, pattern = true )
@@ -1708,7 +1709,7 @@ trait Applications extends Compatibility {
17081709 val unapplyPatterns = UnapplyArgs (unapplyApp.tpe, unapplyFn, unadaptedArgs, tree.srcPos)
17091710 .typedPatterns(qual, this )
17101711 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
17121713 else tryWithTypeTest(Typed (result, TypeTree (ownType)), selType)
17131714 case tp =>
17141715 val unapplyErr = if (tp.isError) unapplyFn else notAnExtractor(unapplyFn)
0 commit comments