Skip to content

Commit

Permalink
PC: Replace CC with underlying type in completions (#19638)
Browse files Browse the repository at this point in the history
[Cherry-picked a5b6907]
  • Loading branch information
rochala authored and WojciechMazur committed Jun 30, 2024
1 parent 1934853 commit 0f2582d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ class Completions(
*/
if sym.isClass && sym.companionModule.exists then sym.companionModule.info
else denot.info
val applyDenots = info.member(nme.apply).allSymbols.map(_.asSingleDenotation)
val applyDenots = info.member(nme.apply).allSymbols.map(_.asSeenFrom(info).asSingleDenotation)
denot :: applyDenots
else denot :: Nil

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ class CompletionDocSuite extends BaseCompletionSuite:
"""
|> Found documentation for scala/package.Vector.
|Vector scala.collection.immutable
|Vector[A](elems: A*): CC[A]
|Vector[A](elems: A*): Vector[A]
|""".stripMargin,
includeDocs = true
)
Expand Down Expand Up @@ -317,6 +317,6 @@ class CompletionDocSuite extends BaseCompletionSuite:
|}
""".stripMargin,
"""|myNumbers: Vector[Int]
|myNumbers(i: Int): A
|myNumbers(i: Int): Int
|""".stripMargin
)
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ class CompletionSuite extends BaseCompletionSuite:
|}""".stripMargin,
"""
|List scala.collection.immutable
|List[A](elems: A*): CC[A]
|List[A](elems: A*): List[A]
|List - java.awt
|List - java.util
|ListMap[K, V](elems: (K, V)*): CC[K, V]
|ListMap[K, V](elems: (K, V)*): ListMap[K, V]
|""".stripMargin,
topLines = Some(5)
)
Expand Down Expand Up @@ -180,7 +180,7 @@ class CompletionSuite extends BaseCompletionSuite:
| TrieMap@@
|}""".stripMargin,
"""|TrieMap scala.collection.concurrent
|TrieMap[K, V](elems: (K, V)*): CC[K, V]
|TrieMap[K, V](elems: (K, V)*): TrieMap[K, V]
|""".stripMargin
)

Expand Down Expand Up @@ -1712,3 +1712,25 @@ class CompletionSuite extends BaseCompletionSuite:
|""".stripMargin
)

@Test def `instantiate-type-vars-in-extra-apply-completions` =
check(
"""|object M:
| val fooBar = List(123)
| foo@@
|""".stripMargin,
"""|fooBar: List[Int]
|fooBar(n: Int): Int
|""".stripMargin
)

@Test def `show-underlying-type-instead-of-CC` =
check(
"""|object M:
| List@@
|""".stripMargin,
"""|List[A](elems: A*): List[A]
|ListMap[K, V](elems: (K, V)*): ListMap[K, V]
|""".stripMargin,
filter = _.contains("[")
)

Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ class CompletionWorkspaceSuite extends BaseCompletionSuite:
|""".stripMargin,
"""|fooBar: String
|fooBar: List[Int]
|fooBar(n: Int): A
|fooBar(n: Int): Int
|""".stripMargin,
)

Expand Down

0 comments on commit 0f2582d

Please sign in to comment.