Skip to content

Commit 6b01b5d

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 6b01b5d

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,26 @@ 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.isImplicitMethod && res.paramInfos.forall(_.tpe.
90+
if (res.resultType.isParameterless &&
91+
res.isImplicitMethod &&
92+
res.paramInfos.forall(_.classSymbol.fullName.toString == "scala.collection.generic.CanBuildFrom"))
93+
Nil
94+
else
95+
toParamss(res)
8896
case _ =>
8997
Nil
9098
}
91-
tp.paramNames.zip(tp.paramInfos).map { case (name, info) =>
99+
val params = tp.paramNames.zip(tp.paramInfos).map { case (name, info) =>
92100
Signatures.Param(name.show,
93101
info.widenTermRefExpr.show,
94102
docComment.flatMap(_.paramDoc(name)),
95103
isImplicit = tp.isImplicitMethod)
96-
} :: rest
104+
}
105+
106+
params :: rest
97107
}
98108

99109
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)