File tree 4 files changed +62
-0
lines changed
src/main/dotty/tools/pc/completions
test/dotty/tools/pc/tests/completion
4 files changed +62
-0
lines changed Original file line number Diff line number Diff line change @@ -248,6 +248,10 @@ class CompletionProvider(
248
248
mkItem(
249
249
" {" + sym.fullNameBackticked + completionTextSuffix + " }"
250
250
)
251
+ case _ if v.isExtensionMethod =>
252
+ mkItem(
253
+ ident.backticked(backtickSoftKeyword) + completionTextSuffix
254
+ )
251
255
case _ =>
252
256
mkItem(
253
257
sym.fullNameBackticked(
Original file line number Diff line number Diff line change @@ -64,6 +64,7 @@ object CompletionValue:
64
64
def symbol : Symbol
65
65
def isFromWorkspace : Boolean = false
66
66
override def completionItemDataKind = CompletionItemData .None
67
+ def isExtensionMethod : Boolean = false
67
68
68
69
override def completionData (
69
70
buildTargetIdentifier : String
@@ -153,6 +154,7 @@ object CompletionValue:
153
154
override def completionItemKind (using Context ): CompletionItemKind =
154
155
CompletionItemKind .Method
155
156
override def completionItemDataKind : Integer = CompletionSource .ExtensionKind .ordinal
157
+ override def isExtensionMethod : Boolean = true
156
158
override def description (printer : ShortenedTypePrinter )(using Context ): String =
157
159
s " ${printer.completionSymbol(symbol)} (extension) "
158
160
Original file line number Diff line number Diff line change @@ -174,3 +174,35 @@ class CompletionExtensionSuite extends BaseCompletionSuite:
174
174
|increment2: Int (extension)
175
175
|""" .stripMargin
176
176
)
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:
825
825
|MyType - demo.other""" .stripMargin,
826
826
)
827
827
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