Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ object MetalsInteractive:
// For a named arg, find the target `DefDef` and jump to the param
case NamedArg(name, _) :: Apply(fn, _) :: _ =>
val funSym = fn.symbol
if funSym.is(Synthetic) && funSym.owner.is(CaseClass) then
val sym = funSym.owner.info.member(name).symbol
lazy val owner = funSym.owner.companionClass
if funSym.is(Synthetic) && owner.is(CaseClass) then
val sym = owner.info.member(name).symbol
List((sym, sym.info, None))
else
val paramSymbol =
Expand All @@ -130,6 +131,13 @@ object MetalsInteractive:
val sym = paramSymbol.getOrElse(fn.symbol)
List((sym, sym.info, None))

case NamedArg(name, _) :: UnApply(s, _, _) :: _ =>
lazy val owner = s.symbol.owner.companionClass
if s.symbol.is(Synthetic) && owner.is(CaseClass) then
val sym = owner.info.member(name).symbol
List((sym, sym.info, None))
else Nil

case (_: untpd.ImportSelector) :: (imp: Import) :: _ =>
importedSymbols(imp, _.span.contains(pos.span)).map(sym =>
(sym, sym.info, None)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -639,3 +639,34 @@ class PcDefinitionSuite extends BasePcDefinitionSuite:
| export scala.collection.immutable.V/*scala/collection/immutable/Vector. Vector.scala*/@@ector
|""".stripMargin
)

@Test def i7763 =
check(
"""|case class MyItem(<<name>>: String)
|
|def handle(item: MyItem) =
| item match {
| case MyItem(na@@me = n2) => println(n2)
| }
|""".stripMargin
)

@Test def `i7763-neg` =
check(
"""|object MyItem:
| def unapply(name: String): Option[Int] = ???
|
|def handle(item: String) =
| item match {
| case MyItem(na@@me = n2) => println(n2)
| }
|""".stripMargin
)

@Test def `i7763-apply` =
check(
"""|case class MyItem(<<name>>: String)
|
|def handle(item: String) = MyItem(na@@me = item)
|""".stripMargin
)
Original file line number Diff line number Diff line change
Expand Up @@ -870,3 +870,15 @@ class HoverTermSuite extends BaseHoverSuite:
|""".stripMargin,
"val aa: Int".hover
)

@Test def i7763 =
check(
"""|case class MyItem(name: String)
|
|def handle(item: MyItem) =
| item match {
| case MyItem(na@@me = n2) => println(n2)
| }
|""".stripMargin,
"val name: String".hover
)
Loading