Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: exhaustive match on stale symbols #5733

Merged
merged 1 commit into from
Oct 10, 2023
Merged
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 @@ -772,10 +772,9 @@ class MetalsGlobal(
def loop(sym: Symbol): Unit = {
sym.knownDirectSubclasses.foreach { child =>
val unique = semanticdbSymbol(child)
if (!isVisited(unique)) {
if (!isVisited(unique) && !child.isStale) {
isVisited += unique
if (child.name.containsName(CURSOR)) ()
else if (child.isStale) ()
else if (child.name == tpnme.LOCAL_CHILD) ()
else if (child.isSealed && (child.isAbstract || child.isTrait)) {
loop(child)
Expand Down
23 changes: 23 additions & 0 deletions tests/cross/src/test/scala/tests/pc/CompletionMatchSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -734,4 +734,27 @@ class CompletionMatchSuite extends BaseCompletionSuite {
filter = _.contains("exhaustive"),
)

check(
"stale-symbols",
"""
|package example
|
|object Main {
| val x: ScalaTargetType = ???
| val y = x match@@
|}
|sealed trait ScalaTargetType
|object ScalaTargetType {
| case object Scala2 extends ScalaTargetType
| case object Scala3 extends ScalaTargetType
| case object JS extends ScalaTargetType
| case object Native extends ScalaTargetType
| case object Typelevel extends ScalaTargetType
| case object ScalaCli extends ScalaTargetType
|}""".stripMargin,
"""|match
|match (exhaustive) ScalaTargetType (6 cases)
|""".stripMargin,
)

}
Loading