Skip to content

Unexpected sensitivity to order of definitions #17224

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

Open
som-snytt opened this issue Apr 10, 2023 · 0 comments
Open

Unexpected sensitivity to order of definitions #17224

som-snytt opened this issue Apr 10, 2023 · 0 comments

Comments

@som-snytt
Copy link
Contributor

Compiler version

3.3.1-RC1-bin-SNAPSHOT-git-d4a8600

Minimized code

object Test {
  type E[+X <: A with T[X]] = A with T[X]
  sealed trait T[+X <: E[X]]
  trait A extends T[A]
  trait B extends A with T[B]
  def test[E1 <: E[E1], E2 <: E[E2]](a: E[E1], b: E[E2]) =
    (a, b) match {
      case (_, _: B) =>
      case (_: B, _) =>
      case _ =>
    }
}

Output

-- [E046] Cyclic Error: S.scala:4:23 -----------------------------------------------------------------------------------
4 |  sealed trait T[+X <: E[X]]
  |                       ^
  |                       Cyclic reference involving type E
  |
  | longer explanation available when compiling with `-explain`
1 error found

Expectation

Same result as when switching order of E and T:

object Test {
  sealed trait T[+X <: E[X]]
  type E[+X <: A with T[X]] = A with T[X]
  trait A extends T[A]
  trait B extends A with T[B]
  def test[E1 <: E[E1], E2 <: E[E2]](a :E[E1], b :E[E2]) =
    (a, b) match {
      case (_, _ :B) =>
      case (_ :B, _) =>
      case _ =>
    }
}

which compiles successfully.

Observed at scala/bug#12771

@som-snytt som-snytt added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Apr 10, 2023
@nicolasstucki nicolasstucki added area:typer and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants