Skip to content

Commit

Permalink
bugfix: Show document highlight with cursor on primary cosntructor
Browse files Browse the repository at this point in the history
Previously, when using document highlight on the type parameter in the primary constructor, we would only get that specific parameter highlighted. This is because those were treated as different symbols with one having constructor parent and the other trait param.

Now, we properly match them as the same symbol from the user perspective.

This seems to be handled the other way already.
  • Loading branch information
tgodzik committed Apr 6, 2023
1 parent 3893260 commit d38973c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ abstract class PcCollector[T](
info.member(sym.asTerm.name.setterName).symbol,
info.member(sym.asTerm.name.getterName).symbol,
) ++ sym.allOverriddenSymbols.toSet
// type used in primary constructor will not match the one used in the class
else if sym.isTypeParam && sym.owner.isPrimaryConstructor then
Set(sym, sym.owner.owner.info.member(sym.name).symbol)
else Set(sym)
all.filter(s => s != NoSymbol && !s.isError)
end symbolAlternatives
Expand Down Expand Up @@ -325,7 +328,6 @@ abstract class PcCollector[T](
symbol: Option[Symbol] = None,
) =
this.collect(parent)(tree, pos, symbol)

tree match
/**
* All indentifiers such as:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,20 @@ class TypeDocumentHighlightSuite extends BaseDocumentHighlightSuite {
|}""".stripMargin,
)

check(
"trait-param1",
"""|trait Zg[<<T@@T>>]{
| def doZ: List[<<TT>>]
|}
|""".stripMargin,
)

check(
"trait-param2",
"""|trait Zg[<<TT>>]{
| def doZ: List[<<T@@T>>]
|}
|""".stripMargin,
)

}

0 comments on commit d38973c

Please sign in to comment.