From c96b5618b57a0a2d1a70daf02a48ad3fcf525be5 Mon Sep 17 00:00:00 2001 From: Jakub Ciesluk <323892@uwr.edu.pl> Date: Mon, 25 Sep 2023 16:25:17 +0200 Subject: [PATCH] bugfix: No signature help for local methods --- .../dotty/tools/dotc/util/Signatures.scala | 4 ++- .../signaturehelp/SignatureHelpSuite.scala | 36 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/util/Signatures.scala b/compiler/src/dotty/tools/dotc/util/Signatures.scala index 5fae39a20de4..ed95314f6fe0 100644 --- a/compiler/src/dotty/tools/dotc/util/Signatures.scala +++ b/compiler/src/dotty/tools/dotc/util/Signatures.scala @@ -13,6 +13,7 @@ import core.NameKinds import core.Types._ import core.Symbols.NoSymbol import interactive.Interactive +import transform.SymUtils.isLocal import util.Spans.Span import reporting._ @@ -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.isLocal then List(funSymbol.denot) else + funSymbol.owner.info.member(funSymbol.name).alternatives val alternativeIndex = alternatives.map(_.symbol).indexOf(funSymbol) max 0 (alternativeIndex, alternatives) diff --git a/presentation-compiler/test/dotty/tools/pc/tests/signaturehelp/SignatureHelpSuite.scala b/presentation-compiler/test/dotty/tools/pc/tests/signaturehelp/SignatureHelpSuite.scala index 0b3112228b83..c39bdd716b37 100644 --- a/presentation-compiler/test/dotty/tools/pc/tests/signaturehelp/SignatureHelpSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/tests/signaturehelp/SignatureHelpSuite.scala @@ -702,3 +702,39 @@ 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, + )