File tree Expand file tree Collapse file tree 2 files changed +58
-1
lines changed
compiler/src/dotty/tools/dotc/util
presentation-compiler/test/dotty/tools/pc/tests/signaturehelp Expand file tree Collapse file tree 2 files changed +58
-1
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import core.NameKinds
1313import core .Types ._
1414import core .Symbols .NoSymbol
1515import interactive .Interactive
16+ import transform .SymUtils .isLocalToBlock
1617import util .Spans .Span
1718import reporting ._
1819
@@ -178,7 +179,8 @@ object Signatures {
178179 (alternativeIndex, alternatives)
179180 case _ =>
180181 val funSymbol = fun.symbol
181- val alternatives = funSymbol.owner.info.member(funSymbol.name).alternatives
182+ val alternatives = if funSymbol.isLocalToBlock then List (funSymbol.denot) else
183+ funSymbol.owner.info.member(funSymbol.name).alternatives
182184 val alternativeIndex = alternatives.map(_.symbol).indexOf(funSymbol) max 0
183185 (alternativeIndex, alternatives)
184186
Original file line number Diff line number Diff line change @@ -702,3 +702,58 @@ class SignatureHelpSuite extends BaseSignatureHelpSuite:
702702 | ^^^^^^^^^^^
703703 |""" .stripMargin
704704 )
705+
706+ @ Test def `local-method` =
707+ check(
708+ """
709+ |object Main {
710+ | def foo() = {
711+ | def deployment(
712+ | fst: String,
713+ | snd: Int = 1,
714+ | ): Option[Int] = ???
715+ | val abc = deployment(@@)
716+ | }
717+ |}
718+ |""" .stripMargin,
719+ """ |deployment(fst: String, snd: Int): Option[Int]
720+ | ^^^^^^^^^^^
721+ |""" .stripMargin,
722+ )
723+
724+ @ Test def `local-method2` =
725+ check(
726+ """
727+ |object Main {
728+ | val foo = {
729+ | def deployment(
730+ | fst: String,
731+ | snd: Int = 1,
732+ | ): Option[Int] = ???
733+ | deployment(@@)
734+ | }
735+ |}
736+ |""" .stripMargin,
737+ """ |deployment(fst: String, snd: Int): Option[Int]
738+ | ^^^^^^^^^^^
739+ |""" .stripMargin,
740+ )
741+
742+ @ Test def `local-method3` =
743+ check(
744+ """
745+ |object Main {
746+ | def foo = {
747+ | object a {
748+ | def apply(a: Int): Int = a
749+ | def apply(b: String): String = b
750+ | a(""@@)
751+ | }
752+ | }
753+ |}
754+ |""" .stripMargin,
755+ """ |apply(b: String): String
756+ | ^^^^^^^^^
757+ |apply(a: Int): Int
758+ |""" .stripMargin
759+ )
You can’t perform that action at this time.
0 commit comments