Skip to content

Commit 5d2f10e

Browse files
committed
Fix tests crashing under strict pattern binding warnings
Before this commit, the tests listed below would crash when the stricter pattern binding rules were enforced (whether using `-source future` or now enabled by default) - neg/parser-stability-14.scala - neg/i4453.scala - fuzzy/CCE-aafcaa9cd2611d22f63273738d637f5bec6e7152.scala - fuzzy/comment3.scala with a common stack trace: dotty.tools.dotc.core.Types$PreviousErrorType cannot be cast to dotty.tools.dotc.core.Types$TermRef dotty.tools.dotc.transform.patmat.SpaceEngine$.isIrrefutable(Space.scala:316) dotty.tools.dotc.typer.Checking.recur$1(Checking.scala:828) dotty.tools.dotc.typer.Checking.checkIrrefutable(Checking.scala:843) dotty.tools.dotc.typer.Checking.checkIrrefutable$(Checking.scala:775) dotty.tools.dotc.typer.Typer.checkIrrefutable(Typer.scala:119) ...
1 parent 7eb227f commit 5d2f10e

File tree

1 file changed

+3
-3
lines changed
  • compiler/src/dotty/tools/dotc/transform/patmat

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,9 @@ object SpaceEngine {
312312
* @param unapp The unapply function tree
313313
*/
314314
def isIrrefutable(unapp: tpd.Tree, argLen: Int)(using Context): Boolean = {
315-
val fun1 = tpd.funPart(unapp)
316-
val funRef = fun1.tpe.asInstanceOf[TermRef]
317-
isIrrefutable(funRef, argLen)
315+
tpd.funPart(unapp).tpe match
316+
case funRef: TermRef => isIrrefutable(funRef, argLen)
317+
case _: ErrorType => false
318318
}
319319
}
320320

0 commit comments

Comments
 (0)