-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
area:pattern-matchingarea:reportingError reporting including formatting, implicit suggestions, etcError reporting including formatting, implicit suggestions, etcbetter-errorsIssues concerned with improving confusing/unhelpful diagnostic messagesIssues concerned with improving confusing/unhelpful diagnostic messagesitype:bug
Description
Compiler version
3.3.5
Minimized code
package com.example
object Repro {
sealed abstract class Listener[A]
final case class Empty[A]()
extends Listener[A]
final case class Waiting[A](next: Promise[A])
extends Listener[A]
def foo[A](l: Listener[A]): Unit = {
l match {
case Empty() => println("empty")
case w @ Waiting(_) => println(s"waiting: ${w.next}") // <-- HERE
}
}
def main(args: Array[String]): Unit = {
foo(Waiting(Promise()))
}
}
sealed trait Promise[A]
object Promise {
def apply[A](): Promise[A] = new PromiseImpl[A](null)
private[this] abstract class PromiseBase[A] extends Promise[A]
private[this] final class PromiseImpl[A](val st: Waiting[A]) extends PromiseBase[A]
private[this] final class Waiting[A]
}
Output
[warn] -- [E030] Match case Unreachable Warning: /home/.../Repro.scala:...
[warn] 33 | case w @ Waiting(_) => println(s"waiting: ${w.next}")
[warn] | ^^^^^^^^^^^^^^
[warn] | Unreachable case
[warn] Matching filters for @nowarn or -Wconf:
[warn] - id=E30
[warn] - name=MatchCaseUnreachable
[warn] one warning found
[info] running com.example.Repro
waiting: com.example.Promise$PromiseImpl@d3995d
Expectation
I'd expect no "Unreachable case" warning for a case which is reachable.
Metadata
Metadata
Assignees
Labels
area:pattern-matchingarea:reportingError reporting including formatting, implicit suggestions, etcError reporting including formatting, implicit suggestions, etcbetter-errorsIssues concerned with improving confusing/unhelpful diagnostic messagesIssues concerned with improving confusing/unhelpful diagnostic messagesitype:bug
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
som-snytt commentedon May 7, 2025
It's quiet for
case w: Waiting[?] =>
.Maybe there's something special about Scala 3 pattern matching, but this looks like it should be easy. Speaking as a peanut gallery member.
Fix scala#23113: Treat private classes as sealed
marq commentedon Jul 16, 2025
I've encountered something similar. Looking at the linked PR it may be the same, if it's not I can create a new issue.
Compiler version: 3.3.4+