@@ -591,12 +591,15 @@ object Completion:
591591 case _ : MethodOrPoly => tpe
592592 case _ => ExprType (tpe)
593593
594+ // Try added due to https://github.com/scalameta/metals/issues/7872
594595 def tryApplyingReceiverToExtension (termRef : TermRef ): Option [SingleDenotation ] =
595- ctx.typer.tryApplyingExtensionMethod(termRef, qual)
596- .map { tree =>
597- val tpe = asDefLikeType(tree.typeOpt.dealias)
598- termRef.denot.asSingleDenotation.mapInfo(_ => tpe)
599- }
596+ try
597+ ctx.typer.tryApplyingExtensionMethod(termRef, qual)
598+ .map { tree =>
599+ val tpe = asDefLikeType(tree.typeOpt.dealias)
600+ termRef.denot.asSingleDenotation.mapInfo(_ => tpe)
601+ }
602+ catch case NonFatal (_) => None
600603
601604 def extractMemberExtensionMethods (types : Seq [Type ]): Seq [(TermRef , TermName )] =
602605 object DenotWithMatchingName :
@@ -694,13 +697,13 @@ object Completion:
694697 * @param qual The argument to which the implicit conversion should be applied.
695698 * @return The set of types after `qual` implicit conversion.
696699 */
697- private def implicitConversionTargets (qual : tpd.Tree )(using Context ): Set [SearchSuccess ] = {
700+ private def implicitConversionTargets (qual : tpd.Tree )(using Context ): Set [SearchSuccess ] = try {
698701 val typer = ctx.typer
699702 val conversions = new typer.ImplicitSearch (defn.AnyType , qual, pos.span, Set .empty).allImplicits
700703
701704 interactiv.println(i " implicit conversion targets considered: ${conversions.toList}%, % " )
702705 conversions
703- }
706+ } catch case NonFatal (_) => Set .empty
704707
705708 /** Filter for names that should appear when looking for completions. */
706709 private object completionsFilter extends NameFilter :
0 commit comments