Skip to content

Commit

Permalink
bugfix: Arg completions on null symbol in Scala 2
Browse files Browse the repository at this point in the history
  • Loading branch information
jkciesluk authored and kasiaMarek committed Apr 9, 2024
1 parent 8f40f07 commit bdbed61
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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]) {
Expand Down
22 changes: 22 additions & 0 deletions tests/cross/src/test/scala/tests/pc/CompletionArgSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)

}

0 comments on commit bdbed61

Please sign in to comment.