Skip to content

Commit 7c3acdc

Browse files
bishaboshatgodzik
authored andcommitted
prevent crash when extension not found
[Cherry-picked 04a65dd]
1 parent 9241544 commit 7c3acdc

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ object Implicits:
413413

414414
/** A failed search */
415415
case class SearchFailure(tree: Tree) extends SearchResult {
416+
require(tree.tpe.isInstanceOf[SearchFailureType], s"unexpected type for ${tree}")
416417
final def isAmbiguous: Boolean = tree.tpe.isInstanceOf[AmbiguousImplicits | TooUnspecific]
417418
final def reason: SearchFailureType = tree.tpe.asInstanceOf[SearchFailureType]
418419
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3663,8 +3663,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
36633663
val remembered = // report AmbiguousReferences as priority, otherwise last error
36643664
(errs.filter(_.msg.isInstanceOf[AmbiguousReference]) ++ errs).take(1)
36653665
for err <- remembered do
3666+
val tree = if app.isEmpty then qual else app
36663667
rememberSearchFailure(qual,
3667-
SearchFailure(app.withType(FailedExtension(app, selectionProto, err.msg))))
3668+
SearchFailure(tree.withType(FailedExtension(tree, selectionProto, err.msg))))
36683669
catch case ex: TypeError => nestedFailure(ex)
36693670

36703671
// try an implicit conversion or given extension

0 commit comments

Comments
 (0)