scalameta / metals

Scala language server with rich IDE features 🚀
https://scalameta.org/metals/
Apache License 2.0
2.07k stars 323 forks source link

IDE type info not working for functions imported from a package file #5568

Closed googley42 closed 1 year ago

googley42 commented 1 year ago

Describe the bug

when I use a function from a package file and assign the result to a var, the IDE command + hover feature does not display type information - also the auto type complete feature result in the Any type eg:

package.scala

package object foo {
  def fooInPackage: Int = 10
}

FooModule.scala

package foo

object FooModule {
  def fooInModule: Int = 10
}

Main.scala

package foo

object Main extends App {
  def fooLocal: Int = 10

  // types derived by IDE auto completion
  val x1: Any = fooInPackage // should be Int, also command + mouse hover not showing any type info 
  val x2: Int = fooLocal
  val x3: Int = FooModule.fooInModule

  println("Hello, World!")
}

Type info for local function or function inside a module is correct.

public repo with code here https://github.com/googley42/vscode-issue and git@github.com:googley42/vscode-issue.git

Expected behavior

should show type info for command + mouse hove, also for auto type completion

Operating system

macOS

Editor/Extension

VSCode/Metals

Version of Metals

v1.0.0

Extra context or search terms

type info

kasiaMarek commented 1 year ago

Thanks for the report. This is a known issue due to the compiler: https://github.com/scala/bug/issues/12663, first raised: https://github.com/scalameta/metals/issues/4495.

tgodzik commented 1 year ago

Let's close it as a duplicate then. Thanks!