Skip to content

GADT constraints with pattern alternatives compile error since Scala 3.7.1 #23328

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

Closed
xuwei-k opened this issue Jun 7, 2025 · 1 comment
Closed
Labels
itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label

Comments

@xuwei-k
Copy link
Contributor

xuwei-k commented Jun 7, 2025

Compiler version

3.7.1
(not 3.7.0, 3.3.6)

Minimized code

//> using scala 3.7.1

package example

sealed trait A[X, Y]
case class B[X](x: X) extends A[X, Int]
case class C[X](x: X) extends A[X, Int]
case class D[X, Y](x: X, y: Y) extends A[X, Y]

def f[X, Y](a: A[X, Y]): Y = a match {
  case B(_) | C(_) => 2
  case D(_, y) => y
}

Output

[error] ./A.scala:11:23
[error] Found:    (2 : Int)
[error] Required: Y
[error]   case B(_) | C(_) => 2
[error]                       ^

Expectation

success

Note

@xuwei-k xuwei-k added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Jun 7, 2025
@xuwei-k
Copy link
Contributor Author

xuwei-k commented Jun 7, 2025

success 3.7.2-RC1-bin-20250603-0be2091-NIGHTLY

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label
Projects
None yet
Development

No branches or pull requests

1 participant