Skip to content

Conversation

jchyb
Copy link
Contributor

@jchyb jchyb commented Oct 13, 2025

Fixes #24038

In the minimisation, the typer phase expanded

case abcd: (h *: t, bh *: bt) =>
      val (hh *: tt, bh *: bt) = abcd

into

case abcd @ _:Tuple2[*:[h @ _, t @ _], *:[bh @ _, bt @ _]] =>
  val $1$: (Any, Tuple, Any, Tuple) =
    abcd:((T, M[T]) & (h *: t, bh *: bt)) @unchecked match 
      {
        case 
          Tuple2.unapply[T, M[T]](
            *:.unapply[Any, Tuple](hh @ _, tt @ _):(Any *: Tuple),
            *:.unapply[Any, Tuple](bh @ _, bt @ _):(Any *: Tuple))
            => Tuple4.apply[Any, Tuple, Any, Tuple](hh, tt, bh, bt)
      }
  val hh: Any = $1$._1
  val tt: Tuple = $1$._2
  val bh: Any = $1$._3
  val bt: Tuple = $1$._4

Before the change in #23923 it would simplify ((T, M[T]) & (h *: t, bh *: bt)) into (T & (h *: t), M[T] & (bh *: bt)) and thus generate:

case abcd @ _:Tuple2[*:[h @ _, t @ _], *:[bh @ _, bt @ _]] =>
  val $1$: (h, t, bh, bt) =
    abcd:(T & h *: t, M[T] & bh *: bt) @unchecked match 
      {
        case 
          Tuple2.unapply[T & h *: t, M[T] & bh *: bt](
            *:.unapply[h, t](hh @ _, tt @ _),
            *:.unapply[bh, bt](bh @ _, bt @ _))
          => Tuple4.apply[h, t, bh, bt](hh, tt, bh, bt)
      }
  val hh: h = $1$._1
  val tt: t = $1$._2
  val bh: bh = $1$._3
  val bt: bt = $1$._4

Since it looks like this simplification is now illegal, and the unapply generation for intersection types seems to prioritize the leftmost argument, to fix this we make sure that when typing Binds we prioritize the user-created tree.tpe and deprioritize the inferred proto type, which hopefully is enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regression in pityka/relational3 for transparent inline with match types

1 participant