diff --git a/mtags/src/main/scala-2/scala/meta/internal/pc/InferredTypeProvider.scala b/mtags/src/main/scala-2/scala/meta/internal/pc/InferredTypeProvider.scala index ecbd687fcfb..15a94337fc0 100644 --- a/mtags/src/main/scala-2/scala/meta/internal/pc/InferredTypeProvider.scala +++ b/mtags/src/main/scala-2/scala/meta/internal/pc/InferredTypeProvider.scala @@ -109,7 +109,8 @@ final class InferredTypeProvider( * turns into * `val a: Int = 1` or `var b: Int = 2` */ - case vl @ ValDef(_, name, tpt, rhs) if !vl.symbol.isParameter => + case vl @ ValDef(_, name, tpt, rhs) + if !vl.symbol.isParameter && tpt.pos.isDefined => val nameEnd = findNameEnd(tpt.pos.start, name) val nameEndPos = tpt.pos.withEnd(nameEnd).withStart(nameEnd).toLsp adjustOpt.foreach(adjust => nameEndPos.setEnd(adjust.adjustedEndPos)) @@ -124,7 +125,8 @@ final class InferredTypeProvider( * turns into * `.map((a: Int) => a + a)` */ - case vl @ ValDef(_, name, tpt, _) if vl.symbol.isParameter => + case vl @ ValDef(_, name, tpt, _) + if vl.symbol.isParameter && tpt.pos.isDefined => val nameEnd = findNameEnd(vl.pos.start, name) val namePos = tpt.pos.withEnd(nameEnd).withStart(nameEnd).toLsp diff --git a/mtags/src/main/scala-2/scala/meta/internal/pc/SignatureHelpProvider.scala b/mtags/src/main/scala-2/scala/meta/internal/pc/SignatureHelpProvider.scala index 8f2df9c7667..d2e020b99a7 100644 --- a/mtags/src/main/scala-2/scala/meta/internal/pc/SignatureHelpProvider.scala +++ b/mtags/src/main/scala-2/scala/meta/internal/pc/SignatureHelpProvider.scala @@ -478,18 +478,21 @@ class SignatureHelpProvider(val compiler: MetalsGlobal) { if (activeSignature == null) { activeSignature = 0 } - val mainSignature = infos(activeSignature) - val deduplicated = infos - .filter { sig => - sig != mainSignature && sig.getLabel() != mainSignature.getLabel() - } - .distinctBy(_.getLabel()) + if (infos.isEmpty) new SignatureHelp() + else { + val mainSignature = infos(activeSignature) + val deduplicated = infos + .filter { sig => + sig != mainSignature && sig.getLabel() != mainSignature.getLabel() + } + .distinctBy(_.getLabel()) - new SignatureHelp( - (mainSignature :: deduplicated).asJava, - 0, - activeParameter - ) + new SignatureHelp( + (mainSignature :: deduplicated).asJava, + 0, + activeParameter + ) + } } def mparamss(