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

Missing dot-completion on higher-order function #5836

Open
harpocrates opened this issue Nov 14, 2023 · 3 comments
Open

Missing dot-completion on higher-order function #5836

harpocrates opened this issue Nov 14, 2023 · 3 comments
Labels
bug Something that is making a piece of functionality unusable completions Tickets related to completion functionality Scala 2 upstream-fix-needed Waiting on a fix upstream

Comments

@harpocrates
Copy link

Describe the bug

Given this self-contained code snippet:

class Foo {
  def Bar: Double = 2.0
  def Baz: Double = 1.0
}

object Bar {
  
  def higherOrder1(f: Foo => Double): Nothing = ???
  def higherOrder2(f: Foo => Double, s: String): Nothing = ???
}

Then, if I try to call higherOrder2 the suggested completions for an anonymous function are missing:

  higherOrder1(_. )
  //             ^ cursor is here   
  // I correctly see `Bar: Double` and `Baz: Double` being suggested

  higherOrder2(_. )
  //             ^ cursor is here   
  // I don't see either `Bar: Double` or `Bar: Double` being suggested
}

Note that if I fill in the second argument of higherOrder2, completions do start showing up when I go back to the first parameter (but that's inconvenient - I usually expect to just type from left to write - not filling in a parameter then hopping back to the first parameter after).

Expected behavior

I would like to see all of the same completions for higherOrder1 as higherOrder2.

Operating system

macOS

Editor/Extension

VS Code

Version of Metals

1.1.0

Extra context or search terms

No response

tgodzik added a commit to tgodzik/metals that referenced this issue Nov 15, 2023
Previously, Scala 2 would not show anything when at `f(_.@@)` and f had more than one parameter. The completions from the compiler would be empty.

Now, we retry with a coma in that case.

Scala 3 was working properly.

Fixes scalameta#5836
@tgodzik
Copy link
Contributor

tgodzik commented Nov 15, 2023

Thanks for reporting! It seems that the presentation compiler for Scala 2 is at fault here, but I made a workaround in Metals.

@tgodzik tgodzik added bug Something that is making a piece of functionality unusable completions Tickets related to completion functionality Scala 2 labels Nov 15, 2023
@tgodzik
Copy link
Contributor

tgodzik commented Nov 16, 2023

After double checking the PR it seems we need to fix it in the compiler itself.

I suspect migrating https://github.com/lampepfl/dotty/pull/14695/files to Scala 2 would be needed. I don't think I will be able to work on that any time soon.

@tgodzik
Copy link
Contributor

tgodzik commented Nov 20, 2023

Reported it upstream in scala/bug#12909

@kasiaMarek kasiaMarek added the upstream-fix-needed Waiting on a fix upstream label Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that is making a piece of functionality unusable completions Tickets related to completion functionality Scala 2 upstream-fix-needed Waiting on a fix upstream
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants