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

Incorrect highlighting and renames with multi val statement #7086

Open
tgodzik opened this issue Jan 3, 2025 · 2 comments
Open

Incorrect highlighting and renames with multi val statement #7086

tgodzik opened this issue Jan 3, 2025 · 2 comments
Labels
presentation-compiler Something relating to the presentation compiler Scala 2 upstream-fix-needed Waiting on a fix upstream

Comments

@tgodzik
Copy link
Contributor

tgodzik commented Jan 3, 2025

Describe the bug


  def runtimeResources: List[AbsolutePath] = platform match {
    case jvm: Platform.Jvm =>
      // single files cannot be added on the classpath
      val (sin@@gleFiles, correctEntries) =
        jvm.resources.partition(path => path.isFile && !path.syntax.endsWith(".jar"))
      val tempResources = Files.createTempDirectory("runtime")
      for (file <- singleFiles) {
        Files.copy(file.underlying, tempResources, StandardCopyOption.REPLACE_EXISTING)
      }
      AbsolutePath(tempResources) :: correctEntries
    case _ => resources
  }

Expected behavior

Only one of singleFiles or correctEntries should be highlighted.

Should reproduce with some more simple cases

This is in the Bloop repository with Scala 2.12.20

Operating system

Linux

Editor/Extension

VS Code

Version of Metals

v1.4.2

Extra context or search terms

highlighting rename multi val

@tgodzik tgodzik added presentation-compiler Something relating to the presentation compiler Scala 2 labels Jan 3, 2025
@kasiaMarek
Copy link
Contributor

Smaller reproduction of the issue:

object O {
    def runtimeResources = {
        val (singleFiles, correctEntries) = (???, ???)
    }
}

@kasiaMarek
Copy link
Contributor

kasiaMarek commented Jan 9, 2025

This is caused by incorrect positions in the rhs of a synthetic definition. Upstream issue: scala/bug#13078. Alternatively, as a workaround, we can avoid traversing children of synthetic definition (I'm not sure that this will never break go to references but I did not find an example where it would).

@kasiaMarek kasiaMarek added the upstream-fix-needed Waiting on a fix upstream label Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
presentation-compiler Something relating to the presentation compiler Scala 2 upstream-fix-needed Waiting on a fix upstream
Projects
None yet
Development

No branches or pull requests

2 participants