Skip to content

Commit 804c31c

Browse files
committed
IDE: Don't display parameter lists made of CanBuildFrom in signatures
It's a hack, but this should be less confusing for students, and it's only temporary until 2.13 is out.
1 parent c2a538d commit 804c31c

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

compiler/src/dotty/tools/dotc/util/Signatures.scala

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,25 @@ object Signatures {
8484
def toParamss(tp: MethodType)(implicit ctx: Context): List[List[Param]] = {
8585
val rest = tp.resType match {
8686
case res: MethodType =>
87-
toParamss(res)
87+
// HACK: Hide parameter lists consisting only of CanBuildFrom,
88+
// remove this once we switch to the 2.13 standard library.
89+
if (res.resultType.isParameterless &&
90+
res.isImplicitMethod &&
91+
res.paramInfos.forall(_.classSymbol.fullName.toString == "scala.collection.generic.CanBuildFrom"))
92+
Nil
93+
else
94+
toParamss(res)
8895
case _ =>
8996
Nil
9097
}
91-
tp.paramNames.zip(tp.paramInfos).map { case (name, info) =>
98+
val params = tp.paramNames.zip(tp.paramInfos).map { case (name, info) =>
9299
Signatures.Param(name.show,
93100
info.widenTermRefExpr.show,
94101
docComment.flatMap(_.paramDoc(name)),
95102
isImplicit = tp.isImplicitMethod)
96-
} :: rest
103+
}
104+
105+
params :: rest
97106
}
98107

99108
denot.info.stripPoly match {

language-server/test/dotty/tools/languageserver/SignatureHelpTest.scala

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import dotty.tools.dotc.util.Signatures.{Param => P, Signature => S}
88

99
class SignatureHelpTest {
1010

11-
@Test def javaParam: Unit = {
11+
@Test def fromJava: Unit = {
1212
val signature =
1313
S("codePointAt", Nil, List(List(P("x$0", "Int"))), Some("Int"))
1414
code"""object O {
@@ -17,13 +17,17 @@ class SignatureHelpTest {
1717
.signatureHelp(m1, List(signature), Some(0), 0)
1818
}
1919

20-
@Test def scala2Param: Unit = {
21-
val signature =
20+
@Test def fromScala2: Unit = {
21+
val applySig =
2222
S("apply[A]", Nil, List(List(P("xs", "A*"))), Some("List[A]"))
23+
val mapSig =
24+
S("map[B, That]", Nil, List(List(P("f", "A => B"))), Some("That"))
2325
code"""object O {
2426
List($m1)
27+
List(1, 2, 3).map($m2)
2528
}""".withSource
26-
.signatureHelp(m1, List(signature), Some(0), 0)
29+
.signatureHelp(m1, List(applySig), Some(0), 0)
30+
.signatureHelp(m2, List(mapSig), Some(0), 0)
2731
}
2832

2933
@Test def singleParam: Unit = {

0 commit comments

Comments
 (0)