Skip to content

Commit a5b6907

Browse files
authored
PC: Replace CC with underlying type in completions (#19638)
1 parent 9c9f01c commit a5b6907

File tree

4 files changed

+29
-7
lines changed

4 files changed

+29
-7
lines changed

presentation-compiler/src/main/dotty/tools/pc/completions/Completions.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ class Completions(
244244
*/
245245
if sym.isClass && sym.companionModule.exists then sym.companionModule.info
246246
else denot.info
247-
val applyDenots = info.member(nme.apply).allSymbols.map(_.asSingleDenotation)
247+
val applyDenots = info.member(nme.apply).allSymbols.map(_.asSeenFrom(info).asSingleDenotation)
248248
denot :: applyDenots
249249
else denot :: Nil
250250

presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionDocSuite.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ class CompletionDocSuite extends BaseCompletionSuite:
215215
"""
216216
|> Found documentation for scala/package.Vector.
217217
|Vector scala.collection.immutable
218-
|Vector[A](elems: A*): CC[A]
218+
|Vector[A](elems: A*): Vector[A]
219219
|""".stripMargin,
220220
includeDocs = true
221221
)
@@ -317,6 +317,6 @@ class CompletionDocSuite extends BaseCompletionSuite:
317317
|}
318318
""".stripMargin,
319319
"""|myNumbers: Vector[Int]
320-
|myNumbers(i: Int): A
320+
|myNumbers(i: Int): Int
321321
|""".stripMargin
322322
)

presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSuite.scala

+25-3
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ class CompletionSuite extends BaseCompletionSuite:
2727
|}""".stripMargin,
2828
"""
2929
|List scala.collection.immutable
30-
|List[A](elems: A*): CC[A]
30+
|List[A](elems: A*): List[A]
3131
|List - java.awt
3232
|List - java.util
33-
|ListMap[K, V](elems: (K, V)*): CC[K, V]
33+
|ListMap[K, V](elems: (K, V)*): ListMap[K, V]
3434
|""".stripMargin,
3535
topLines = Some(5)
3636
)
@@ -180,7 +180,7 @@ class CompletionSuite extends BaseCompletionSuite:
180180
| TrieMap@@
181181
|}""".stripMargin,
182182
"""|TrieMap scala.collection.concurrent
183-
|TrieMap[K, V](elems: (K, V)*): CC[K, V]
183+
|TrieMap[K, V](elems: (K, V)*): TrieMap[K, V]
184184
|""".stripMargin
185185
)
186186

@@ -1712,3 +1712,25 @@ class CompletionSuite extends BaseCompletionSuite:
17121712
|""".stripMargin
17131713
)
17141714

1715+
@Test def `instantiate-type-vars-in-extra-apply-completions` =
1716+
check(
1717+
"""|object M:
1718+
| val fooBar = List(123)
1719+
| foo@@
1720+
|""".stripMargin,
1721+
"""|fooBar: List[Int]
1722+
|fooBar(n: Int): Int
1723+
|""".stripMargin
1724+
)
1725+
1726+
@Test def `show-underlying-type-instead-of-CC` =
1727+
check(
1728+
"""|object M:
1729+
| List@@
1730+
|""".stripMargin,
1731+
"""|List[A](elems: A*): List[A]
1732+
|ListMap[K, V](elems: (K, V)*): ListMap[K, V]
1733+
|""".stripMargin,
1734+
filter = _.contains("[")
1735+
)
1736+

presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionWorkspaceSuite.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ class CompletionWorkspaceSuite extends BaseCompletionSuite:
811811
|""".stripMargin,
812812
"""|fooBar: String
813813
|fooBar: List[Int]
814-
|fooBar(n: Int): A
814+
|fooBar(n: Int): Int
815815
|""".stripMargin,
816816
)
817817

0 commit comments

Comments
 (0)