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

Backport "bugfix: No signature help for local methods" to LTS #20680

Merged
merged 1 commit into from
Jun 20, 2024
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
4 changes: 3 additions & 1 deletion compiler/src/dotty/tools/dotc/util/Signatures.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import core.NameKinds
import core.Types._
import core.Symbols.NoSymbol
import interactive.Interactive
import transform.SymUtils.isLocalToBlock
import util.Spans.Span
import reporting._

Expand Down Expand Up @@ -178,7 +179,8 @@ object Signatures {
(alternativeIndex, alternatives)
case _ =>
val funSymbol = fun.symbol
val alternatives = funSymbol.owner.info.member(funSymbol.name).alternatives
val alternatives = if funSymbol.isLocalToBlock then List(funSymbol.denot) else
funSymbol.owner.info.member(funSymbol.name).alternatives
val alternativeIndex = alternatives.map(_.symbol).indexOf(funSymbol) max 0
(alternativeIndex, alternatives)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -702,3 +702,58 @@ class SignatureHelpSuite extends BaseSignatureHelpSuite:
| ^^^^^^^^^^^
|""".stripMargin
)

@Test def `local-method` =
check(
"""
|object Main {
| def foo() = {
| def deployment(
| fst: String,
| snd: Int = 1,
| ): Option[Int] = ???
| val abc = deployment(@@)
| }
|}
|""".stripMargin,
"""|deployment(fst: String, snd: Int): Option[Int]
| ^^^^^^^^^^^
|""".stripMargin,
)

@Test def `local-method2` =
check(
"""
|object Main {
| val foo = {
| def deployment(
| fst: String,
| snd: Int = 1,
| ): Option[Int] = ???
| deployment(@@)
| }
|}
|""".stripMargin,
"""|deployment(fst: String, snd: Int): Option[Int]
| ^^^^^^^^^^^
|""".stripMargin,
)

@Test def `local-method3` =
check(
"""
|object Main {
| def foo = {
| object a {
| def apply(a: Int): Int = a
| def apply(b: String): String = b
| a(""@@)
| }
| }
|}
|""".stripMargin,
"""|apply(b: String): String
| ^^^^^^^^^
|apply(a: Int): Int
|""".stripMargin
)
Loading