Skip to content

Commit a17721d

Browse files
committed
Closes #7532: Parameter hints not working for functions
- Treat function `apply` calls as valid for signatureHelp; stop excluding FunctionN `apply`. - Add tests for implicit/explicit apply; keep skipping tuple applies.
1 parent 4493b49 commit a17721d

File tree

2 files changed

+38
-7
lines changed

2 files changed

+38
-7
lines changed

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ object Signatures {
379379
case other => other.stripAnnots
380380

381381
/**
382-
* Checks if tree is valid for signatureHelp. Skipped trees are either tuple or function applies
382+
* Checks if tree is valid for signatureHelp. Skips tuple apply trees
383383
*
384384
* @param tree tree to validate
385385
*/
@@ -389,12 +389,7 @@ object Signatures {
389389
&& tree.symbol.exists
390390
&& ctx.definitions.isTupleClass(tree.symbol.owner.companionClass)
391391

392-
val isFunctionNApply =
393-
tree.symbol.name == nme.apply
394-
&& tree.symbol.exists
395-
&& ctx.definitions.isFunctionSymbol(tree.symbol.owner)
396-
397-
!isTupleApply && !isFunctionNApply
392+
!isTupleApply
398393

399394
/**
400395
* Get unapply method result type omiting unknown types and another method calls.

presentation-compiler/test/dotty/tools/pc/tests/signaturehelp/SignatureHelpSuite.scala

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1610,3 +1610,39 @@ class SignatureHelpSuite extends BaseSignatureHelpSuite:
16101610
| ^^^^^^
16111611
""".stripMargin
16121612
)
1613+
1614+
@Test def `proper-function-signature` =
1615+
check(
1616+
"""
1617+
|object OOO {
1618+
|
1619+
|val function: (x: Int, y: String) => Unit =
1620+
|(_, _) =>
1621+
| ()
1622+
|
1623+
|function(@@, "one")
1624+
|}
1625+
""".stripMargin,
1626+
"""|apply(v1: Int, v2: String): Unit
1627+
| ^^^^^^^
1628+
|""".stripMargin
1629+
)
1630+
1631+
@Test def `proper-function-signature-with-explicit-apply` =
1632+
check(
1633+
"""
1634+
|object OOO {
1635+
|
1636+
|val function: (x: Int, y: String) => Unit =
1637+
|(_, _) =>
1638+
| ()
1639+
|
1640+
|function.apply(@@, "one")
1641+
|}
1642+
""".stripMargin,
1643+
"""|apply(v1: Int, v2: String): Unit
1644+
| ^^^^^^^
1645+
|""".stripMargin
1646+
)
1647+
1648+

0 commit comments

Comments
 (0)