File tree Expand file tree Collapse file tree 4 files changed +62
-0
lines changed
src/main/dotty/tools/pc/completions
test/dotty/tools/pc/tests/completion Expand file tree Collapse file tree 4 files changed +62
-0
lines changed Original file line number Diff line number Diff line change @@ -244,6 +244,10 @@ class CompletionProvider(
244244 mkItem(
245245 " {" + sym.fullNameBackticked + completionTextSuffix + " }"
246246 )
247+ case _ if v.isExtensionMethod =>
248+ mkItem(
249+ ident.backticked(backtickSoftKeyword) + completionTextSuffix
250+ )
247251 case _ =>
248252 mkItem(
249253 sym.fullNameBackticked(
Original file line number Diff line number Diff line change @@ -64,6 +64,7 @@ object CompletionValue:
6464 def symbol : Symbol
6565 def isFromWorkspace : Boolean = false
6666 override def completionItemDataKind = CompletionItemData .None
67+ def isExtensionMethod : Boolean = false
6768
6869 override def completionData (
6970 buildTargetIdentifier : String
@@ -153,6 +154,7 @@ object CompletionValue:
153154 override def completionItemKind (using Context ): CompletionItemKind =
154155 CompletionItemKind .Method
155156 override def completionItemDataKind : Integer = CompletionSource .ExtensionKind .ordinal
157+ override def isExtensionMethod : Boolean = true
156158 override def description (printer : ShortenedTypePrinter )(using Context ): String =
157159 s " ${printer.completionSymbol(symbol)} (extension) "
158160
Original file line number Diff line number Diff line change @@ -174,3 +174,35 @@ class CompletionExtensionSuite extends BaseCompletionSuite:
174174 |increment2: Int (extension)
175175 |""" .stripMargin
176176 )
177+
178+ @ Test def `name-conflict` =
179+ checkEdit(
180+ """
181+ |package example
182+ |
183+ |import example.enrichments.*
184+ |
185+ |object enrichments:
186+ | extension (num: Int)
187+ | def plus(other: Int): Int = num + other
188+ |
189+ |def main = {
190+ | val plus = 100.plus(19)
191+ | val y = 19.pl@@
192+ |}
193+ |""" .stripMargin,
194+ """
195+ |package example
196+ |
197+ |import example.enrichments.*
198+ |
199+ |object enrichments:
200+ | extension (num: Int)
201+ | def plus(other: Int): Int = num + other
202+ |
203+ |def main = {
204+ | val plus = 100.plus(19)
205+ | val y = 19.plus($0)
206+ |}
207+ |""" .stripMargin
208+ )
Original file line number Diff line number Diff line change @@ -825,3 +825,27 @@ class CompletionWorkspaceSuite extends BaseCompletionSuite:
825825 |MyType - demo.other""" .stripMargin,
826826 )
827827
828+ @ Test def `method-name-conflict` =
829+ checkEdit(
830+ """ |package demo
831+ |
832+ |object O {
833+ | def mmmm(x: Int) = x + 3
834+ | class Test {
835+ | val mmmm = "abc"
836+ | val foo = mmmm@@
837+ | }
838+ |}
839+ |""" .stripMargin,
840+ """ |package demo
841+ |
842+ |object O {
843+ | def mmmm(x: Int) = x + 3
844+ | class Test {
845+ | val mmmm = "abc"
846+ | val foo = demo.O.mmmm($0)
847+ | }
848+ |}
849+ |""" .stripMargin,
850+ filter = _.contains(" mmmm(x: Int)" )
851+ )
You can’t perform that action at this time.
0 commit comments