@@ -563,12 +563,15 @@ object Completion:
563563 case _ : MethodOrPoly => tpe
564564 case _ => ExprType (tpe)
565565
566+ // Try added due to https://github.com/scalameta/metals/issues/7872
566567 def tryApplyingReceiverToExtension (termRef : TermRef ): Option [SingleDenotation ] =
567- ctx.typer.tryApplyingExtensionMethod(termRef, qual)
568- .map { tree =>
569- val tpe = asDefLikeType(tree.typeOpt.dealias)
570- termRef.denot.asSingleDenotation.mapInfo(_ => tpe)
571- }
568+ try
569+ ctx.typer.tryApplyingExtensionMethod(termRef, qual)
570+ .map { tree =>
571+ val tpe = asDefLikeType(tree.typeOpt.dealias)
572+ termRef.denot.asSingleDenotation.mapInfo(_ => tpe)
573+ }
574+ catch case NonFatal (_) => None
572575
573576 def extractMemberExtensionMethods (types : Seq [Type ]): Seq [(TermRef , TermName )] =
574577 object DenotWithMatchingName :
@@ -666,13 +669,13 @@ object Completion:
666669 * @param qual The argument to which the implicit conversion should be applied.
667670 * @return The set of types after `qual` implicit conversion.
668671 */
669- private def implicitConversionTargets (qual : tpd.Tree )(using Context ): Set [SearchSuccess ] = {
672+ private def implicitConversionTargets (qual : tpd.Tree )(using Context ): Set [SearchSuccess ] = try {
670673 val typer = ctx.typer
671674 val conversions = new typer.ImplicitSearch (defn.AnyType , qual, pos.span).allImplicits
672675
673676 interactiv.println(i " implicit conversion targets considered: ${conversions.toList}%, % " )
674677 conversions
675- }
678+ } catch case NonFatal (_) => Set .empty
676679
677680 /** Filter for names that should appear when looking for completions. */
678681 private object completionsFilter extends NameFilter :
0 commit comments