Skip to content

Commit 04a65dd

Browse files
committed
prevent crash when extension not found
1 parent dc1e35a commit 04a65dd

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Implicits.scala

+1
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@ object Implicits:
431431

432432
/** A failed search */
433433
case class SearchFailure(tree: Tree) extends SearchResult {
434+
require(tree.tpe.isInstanceOf[SearchFailureType], s"unexpected type for ${tree}")
434435
final def isAmbiguous: Boolean = tree.tpe.isInstanceOf[AmbiguousImplicits | TooUnspecific]
435436
final def reason: SearchFailureType = tree.tpe.asInstanceOf[SearchFailureType]
436437
}

compiler/src/dotty/tools/dotc/typer/Typer.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -3625,8 +3625,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
36253625
val remembered = // report AmbiguousReferences as priority, otherwise last error
36263626
(errs.filter(_.msg.isInstanceOf[AmbiguousReference]) ++ errs).take(1)
36273627
for err <- remembered do
3628+
val tree = if app.isEmpty then qual else app
36283629
rememberSearchFailure(qual,
3629-
SearchFailure(app.withType(FailedExtension(app, selectionProto, err.msg))))
3630+
SearchFailure(tree.withType(FailedExtension(tree, selectionProto, err.msg))))
36303631
catch case ex: TypeError => nestedFailure(ex)
36313632

36323633
// try an implicit conversion or given extension

0 commit comments

Comments
 (0)