From bdbed61ce90a99d11608b4841998d2c72f7f0ed7 Mon Sep 17 00:00:00 2001 From: Jakub Ciesluk <323892@uwr.edu.pl> Date: Wed, 20 Mar 2024 18:37:36 +0100 Subject: [PATCH] bugfix: Arg completions on null symbol in Scala 2 --- .../pc/completions/ArgCompletions.scala | 8 ++++--- .../scala/tests/pc/CompletionArgSuite.scala | 22 +++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/mtags/src/main/scala-2/scala/meta/internal/pc/completions/ArgCompletions.scala b/mtags/src/main/scala-2/scala/meta/internal/pc/completions/ArgCompletions.scala index bda448b11fe..edc6f60c7ff 100644 --- a/mtags/src/main/scala-2/scala/meta/internal/pc/completions/ArgCompletions.scala +++ b/mtags/src/main/scala-2/scala/meta/internal/pc/completions/ArgCompletions.scala @@ -208,9 +208,11 @@ trait ArgCompletions { this: MetalsGlobal => } override def contribute: List[Member] = { - params.distinct.map(param => - new NamedArgMember(param) - ) ::: findPossibleDefaults() ::: fillAllFields() + if (methodSym == null) Nil + else + params.distinct.map(param => + new NamedArgMember(param) + ) ::: findPossibleDefaults() ::: fillAllFields() } case class MethodParams(params: List[Symbol], isNamed: Set[Name]) { diff --git a/tests/cross/src/test/scala/tests/pc/CompletionArgSuite.scala b/tests/cross/src/test/scala/tests/pc/CompletionArgSuite.scala index f35b03a76e8..42bdf5cb13f 100644 --- a/tests/cross/src/test/scala/tests/pc/CompletionArgSuite.scala +++ b/tests/cross/src/test/scala/tests/pc/CompletionArgSuite.scala @@ -1216,4 +1216,26 @@ class CompletionArgSuite extends BaseCompletionSuite { topLines = Some(1) ) + check( + "null-symbol", + """|object O { + | val t1 = true + | val t2 = true + | val f1 = false + | + | (t1, t2, f1) match { + | case (_, false, false) => prinl=t@@n() + | case (true, _, true) => println("KO") + | case _ => println("OK") + | } + |} + |""".stripMargin, + "", + compat = Map( + "3" -> """|t1: Boolean + |""".stripMargin + ), + topLines = Some(1) + ) + }