Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: completion of args in method w/ default args #7089

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ trait ArgCompletions { this: MetalsGlobal =>
pos.withStart(ident.pos.start).withEnd(pos.start).toLsp
val funPos = apply.fun.pos
val method: Tree = typedTreeAt(funPos) match {
case Apply(Block(defParams, app: Apply), _)
// Functions calls with default arguments expand into this form
case Apply(Block(defParams, app @ (_: Apply | _: Select)), _)
if defParams.forall(p => p.isInstanceOf[ValDef]) =>
app
case New(c) => c
Expand Down
17 changes: 17 additions & 0 deletions tests/cross/src/test/scala/tests/pc/CompletionArgSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,23 @@ class CompletionArgSuite extends BaseCompletionSuite {
topLines = Some(2)
)

check(
"default-args7",
"""|trait Foo {
| def bar(fst: String = null, snd: Int = 3 + 2, thd: Int = 23)
|}
|object Main {
| def foo: Foo = ???
| foo.bar(@@)
|}
|""".stripMargin,
"""|fst = : String
|snd = : Int
|thd = : Int
|""".stripMargin,
topLines = Some(3)
)

checkSnippet( // see: https://github.com/scalameta/metals/issues/2400
"explicit-dollar",
"""
Expand Down
Loading