scalameta / metals

Scala language server with rich IDE features 🚀

Home Page:https://scalameta.org/metals/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[java] goto definition doesn't work when generic method is present

ghostbuster91 opened this issue · comments

Describe the bug

Given the following java code:

package com.example;

import hello.Foo;

public class Builder {

	static <T> void instance() {
	}

	void build() {
		String baz = Foo.baz();
	}
}

and some scala code in the same module:

package hello

object Foo {
  def baz: String = "SSSS"
}

Calling goto def. on Foo or baz from java returns empty results.

It seems to be connected with the presence of the generic parameter in the instance method.
If we comment out the whole instance method, goto def. starts to work correctly.

There is one more thing that I discovered which seems to be connected with another issue #6357

If we add class definition to the Foo file like so:

class Foo {}

object Foo {
  def baz: String = "SSSS"
}

Then both Foo and baz starts to navigating to Foo class definition.

Full project to reproduce the issue: https://github.com/ghostbuster91/demos/tree/goto-def-generic

Expected behavior

I would expect goto definition to navigate to the baz method inside the Foo object regardless of the presence of any type parameters in other methods.

Operating system

Linux

Editor/Extension

Nvim (nvim-metals)

Version of Metals

1.3.0

Extra context or search terms

goto definition, java