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

Compiler crashes on get the field names of case class. #16207

Open
esse-byte opened this issue Oct 19, 2022 · 9 comments
Open

Compiler crashes on get the field names of case class. #16207

esse-byte opened this issue Oct 19, 2022 · 9 comments

Comments

@esse-byte
Copy link

esse-byte commented Oct 19, 2022

Compiler version

3.2.0, 3.2.1-RC4

Minimized code

import scala.compiletime.constValueTuple
import scala.deriving.Mirror.ProductOf

case class C(date: Int, time: Int)

inline def labelsOf[A](using p: ProductOf[A]): Tuple = constValueTuple[p.MirroredElemLabels]

val headers: List[String] = labelsOf[C].toList.map(_.toString)

Output (click arrow to expand)

exception while typing {
  val p$proxy1:

      scala.deriving.Mirror.Product{
        MirroredMonoType = C; MirroredType = C; MirroredLabel = ("C" : String);
          MirroredElemTypes = (Int, Int)
        ; MirroredElemLabels = (("date" : String), ("time" : String))
      }

   =
    C.$asInstanceOf[

        scala.deriving.Mirror.Product{
          MirroredMonoType = C; MirroredType = C; MirroredLabel = ("C" : String)
            ;
          MirroredElemTypes = (Int, Int);
            MirroredElemLabels = (("date" : String), ("time" : String))
        }

    ]
  {
    val Tuple_this: Tuple =
      (
        {
          val res: Tuple =
            {
              val x$1: ("date" : String) = "date"
              {
                val Tuple_this: ("time" : String) *: EmptyTuple.type =
                  {
                    val res: Tuple =
                      {
                        val x$1: ("time" : String) = "time"
                        {
                          val Tuple_this: EmptyTuple.type = EmptyTuple
                          runtime.Tuples.cons("time", Tuple_this).asInstanceOf[
                            ("time" : String) *: EmptyTuple.type
                          ]:("time" : String) *: EmptyTuple.type
                        }:Any *: Tuple
                      }
                    res.asInstanceOf[("time" : String) *: EmptyTuple.type]
                  }:("time" : String) *: EmptyTuple.type
                runtime.Tuples.cons("date", Tuple_this).asInstanceOf[
                  (("date" : String), ("time" : String))
                ]:(("date" : String), ("time" : String))
              }:Any *: Tuple
            }
          res.asInstanceOf[p$proxy1.MirroredElemLabels]
        }:p$proxy1.MirroredElemLabels
      :Tuple)
    (
      Tuple_this.productIterator.toList.asInstanceOf[
        scala.collection.immutable.List[Tuple.Union[(Tuple_this : Product)]]
@esse-byte esse-byte added itype:bug itype:crash stat:needs triage Every issue needs to have an "area" and "itype" label labels Oct 19, 2022
@esse-byte
Copy link
Author

esse-byte commented Oct 19, 2022

It works if change the code to:

import scala.compiletime.constValueTuple
import scala.deriving.Mirror.ProductOf

case class C(date: Int, time: Int)

inline def labelsOf[A](using p: ProductOf[A]): Tuple = constValueTuple[p.MirroredElemLabels]

val labels = labelsOf[C].toList
val header = labels.map(_.toString)

@szymon-rd szymon-rd assigned szymon-rd and unassigned szymon-rd Oct 19, 2022
@szymon-rd szymon-rd added area:typer area:metaprogramming:reflection Issues related to the quotes reflection API and removed stat:needs triage Every issue needs to have an "area" and "itype" label area:typer labels Oct 19, 2022
@esse-byte esse-byte changed the title Compiler crashs on get the field names of inner case class. Compiler crashs on get the field names case class. Oct 19, 2022
@esse-byte esse-byte changed the title Compiler crashs on get the field names case class. Compiler crashs on get the field names of case class. Oct 19, 2022
@Kordyjan Kordyjan added this to the Future versions milestone Dec 12, 2022
@KacperFKorban KacperFKorban self-assigned this Dec 20, 2022
@KacperFKorban KacperFKorban added area:typer and removed area:metaprogramming:reflection Issues related to the quotes reflection API labels Dec 20, 2022
@SethTisue SethTisue changed the title Compiler crashs on get the field names of case class. Compiler crashes on get the field names of case class. Jan 12, 2023
@Kordyjan Kordyjan modified the milestones: Future versions, 3.3.1-RC1 Jan 16, 2023
@anatoliykmetyuk anatoliykmetyuk added the Spree Suitable for a future Spree label May 22, 2023
@KacperFKorban
Copy link
Member

Here's a minimization of the issue:

def tple: Tuple = ("abc", "def")

val _ = tple.toList.map(_ => 1)

Output

exception while typing {
  val Tuple_this: Tuple = tple
  (
    Tuple_this.productIterator.toList.asInstanceOf[
      scala.collection.immutable.List[Tuple.Union[(Tuple_this : Product)]]]
  :scala.collection.immutable.List[Tuple.Union[(Tuple_this : Product)]])
}.map of class class dotty.tools.dotc.ast.Trees$Select # -1
exception while typing {
  val Tuple_this: Tuple = tple
  (
    Tuple_this.productIterator.toList.asInstanceOf[
      scala.collection.immutable.List[Tuple.Union[(Tuple_this : Product)]]]
  :scala.collection.immutable.List[Tuple.Union[(Tuple_this : Product)]])
}.map[Int] of class class dotty.tools.dotc.ast.Trees$TypeApply # -1
exception while typing {
  val Tuple_this: Tuple = tple
  (
    Tuple_this.productIterator.toList.asInstanceOf[
      scala.collection.immutable.List[Tuple.Union[(Tuple_this : Product)]]]
  :scala.collection.immutable.List[Tuple.Union[(Tuple_this : Product)]])
}.map[Int](
  {
    def $anonfun(_$1: Tuple.Union[(?1 : Tuple)]): Int = 1
    closure($anonfun)
  }
) of class class dotty.tools.dotc.ast.Trees$Apply # -1
exception while typing {
  val Tuple_this: Tuple = tple
  (
    Tuple_this.productIterator.toList.asInstanceOf[
      scala.collection.immutable.List[Tuple.Union[(Tuple_this : Product)]]]
  :scala.collection.immutable.List[Tuple.Union[(Tuple_this : Product)]])
}.map[Int](
  {
    def $anonfun(_$1: Tuple.Union[(?1 : Tuple)]): Int = 1
    closure($anonfun)
  }
):scala.collection.immutable.List[Int] @unchecked of class class dotty.tools.dotc.ast.Trees$Typed # -1
exception while typing case val x1: scala.collection.immutable.List[Int] @unchecked =
  {
    val Tuple_this: Tuple = tple
    (
      Tuple_this.productIterator.toList.asInstanceOf[
        scala.collection.immutable.List[Tuple.Union[(Tuple_this : Product)]]]
    :scala.collection.immutable.List[Tuple.Union[(Tuple_this : Product)]])
  }.map[Int](
    {
      def $anonfun(_$1: Tuple.Union[(?1 : Tuple)]): Int = 1
      closure($anonfun)
    }
  ):scala.collection.immutable.List[Int] @unchecked of class class dotty.tools.dotc.ast.Trees$ValDef # -1
exception while typing {
  case val x1: scala.collection.immutable.List[Int] @unchecked =
    {
      val Tuple_this: Tuple = tple
      (
        Tuple_this.productIterator.toList.asInstanceOf[
          scala.collection.immutable.List[Tuple.Union[(Tuple_this : Product)]]]
      :scala.collection.immutable.List[Tuple.Union[(Tuple_this : Product)]])
    }.map[Int](
      {
        def $anonfun(_$1: Tuple.Union[(?1 : Tuple)]): Int = 1
        closure($anonfun)
      }
    ):scala.collection.immutable.List[Int] @unchecked
  return[matchResult1] ()
} of class class dotty.tools.dotc.ast.Trees$Block # -1
exception while typing matchResult1[Unit]: 
  {
    case val x1: scala.collection.immutable.List[Int] @unchecked =
      {
        val Tuple_this: Tuple = tple
        (
          Tuple_this.productIterator.toList.asInstanceOf[
            scala.collection.immutable.List[Tuple.Union[(Tuple_this : Product)]]
            ]
        :scala.collection.immutable.List[Tuple.Union[(Tuple_this : Product)]])
      }.map[Int](
        {
          def $anonfun(_$1: Tuple.Union[(?1 : Tuple)]): Int = 1
          closure($anonfun)
        }
      ):scala.collection.immutable.List[Int] @unchecked
    return[matchResult1] ()
  } of class class dotty.tools.dotc.ast.Trees$Labeled # -1
exception while typing @SourceFile("i16207.scala") final module class i16207$package() extends Object()
   {
  private def writeReplace(): AnyRef =
    new scala.runtime.ModuleSerializationProxy(classOf[i16207$package.type])
  def tple: Tuple = Tuple2.apply[String, String]("abc", "def")
  matchResult1[Unit]: 
    {
      case val x1: scala.collection.immutable.List[Int] @unchecked =
        {
          val Tuple_this: Tuple = tple
          (
            Tuple_this.productIterator.toList.asInstanceOf[
              
                scala.collection.immutable.List[
                  Tuple.Union[(Tuple_this : Product)]]
              
            ]
          :scala.collection.immutable.List[Tuple.Union[(Tuple_this : Product)]])
          }.map[Int](
          {
            def $anonfun(_$1: Tuple.Union[(?1 : Tuple)]): Int = 1
            closure($anonfun)
          }
        ):scala.collection.immutable.List[Int] @unchecked
      return[matchResult1] ()
    }
} of class class dotty.tools.dotc.ast.Trees$TypeDef # -1
exception while typing package <empty> {
  final lazy module val i16207$package: i16207$package = new i16207$package()
  @SourceFile("i16207.scala") final module class i16207$package() extends Object
    () {
    private def writeReplace(): AnyRef =
      new scala.runtime.ModuleSerializationProxy(classOf[i16207$package.type])
    def tple: Tuple = Tuple2.apply[String, String]("abc", "def")
    matchResult1[Unit]: 
      {
        case val x1: scala.collection.immutable.List[Int] @unchecked =
          {
            val Tuple_this: Tuple = tple
            (
              Tuple_this.productIterator.toList.asInstanceOf[
                
                  scala.collection.immutable.List[
                    Tuple.Union[(Tuple_this : Product)]]
                
              ]
            :
              
                scala.collection.immutable.List[
                  Tuple.Union[(Tuple_this : Product)]]
              
            )
          }.map[Int](
            {
              def $anonfun(_$1: Tuple.Union[(?1 : Tuple)]): Int = 1
              closure($anonfun)
            }
          ):scala.collection.immutable.List[Int] @unchecked
        return[matchResult1] ()
      }
  }
} of class class dotty.tools.dotc.ast.Trees$PackageDef # -1
java.lang.AssertionError: assertion failed: no owner from  <none>/ <none> in {
  val Tuple_this: Tuple = tple
  (
    Tuple_this.productIterator.toList.asInstanceOf[
      scala.collection.immutable.List[Tuple.Union[(Tuple_this : Product)]]]
  :scala.collection.immutable.List[Tuple.Union[(Tuple_this : Product)]])
}.<none> while running erasure on i16207.scala
exception occurred while compiling i16207.scala
java.lang.AssertionError: assertion failed: no owner from  <none>/ <none> in {
  val Tuple_this: Tuple = tple
  (
    Tuple_this.productIterator.toList.asInstanceOf[
      scala.collection.immutable.List[Tuple.Union[(Tuple_this : Product)]]]
  :scala.collection.immutable.List[Tuple.Union[(Tuple_this : Product)]])
}.<none> while compiling i16207.scala
Exception in thread "main" java.lang.AssertionError: assertion failed: no owner from  <none>/ <none> in {
  val Tuple_this: Tuple = tple
  (
    Tuple_this.productIterator.toList.asInstanceOf[
      scala.collection.immutable.List[Tuple.Union[(Tuple_this : Product)]]]
  :scala.collection.immutable.List[Tuple.Union[(Tuple_this : Product)]])
}.<none>
	at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
	at dotty.tools.dotc.transform.Erasure$Typer.typedSelect(Erasure.scala:716)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2897)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2990)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:126)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3058)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3062)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3174)
	at dotty.tools.dotc.transform.Erasure$Typer.typedTypeApply(Erasure.scala:812)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2947)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2991)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:126)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3058)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3062)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3174)
	at dotty.tools.dotc.transform.Erasure$Typer.typedApply(Erasure.scala:831)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2928)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2991)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:126)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3058)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3062)
	at dotty.tools.dotc.transform.Erasure$Typer.typedTyped(Erasure.scala:631)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2933)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2991)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:126)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3058)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3062)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3174)
	at dotty.tools.dotc.typer.Typer.typedValDef(Typer.scala:2326)
	at dotty.tools.dotc.transform.Erasure$Typer.typedValDef(Erasure.scala:901)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2901)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2990)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:126)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3058)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3062)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3084)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3130)
	at dotty.tools.dotc.transform.Erasure$Typer.typedStats(Erasure.scala:1047)
	at dotty.tools.dotc.typer.Typer.typedBlockStats(Typer.scala:1096)
	at dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:1100)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2936)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2991)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:126)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3058)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3062)
	at dotty.tools.dotc.typer.Typer.typedLabeled(Typer.scala:1799)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2921)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2990)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:126)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3058)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3062)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3111)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3130)
	at dotty.tools.dotc.transform.Erasure$Typer.typedStats(Erasure.scala:1047)
	at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2562)
	at dotty.tools.dotc.transform.Erasure$Typer.typedClassDef(Erasure.scala:1036)
	at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:2916)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2920)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2990)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:126)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3058)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3062)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3084)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3130)
	at dotty.tools.dotc.transform.Erasure$Typer.typedStats(Erasure.scala:1047)
	at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2692)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2961)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2991)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:126)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3058)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3062)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3174)
	at dotty.tools.dotc.transform.Erasure.run(Erasure.scala:144)
	at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:324)
	at scala.collection.immutable.List.map(List.scala:246)
	at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:328)
	at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:247)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1321)
	at dotty.tools.dotc.Run.runPhases$1(Run.scala:263)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:271)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:280)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:67)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:280)
	at dotty.tools.dotc.Run.compileSources(Run.scala:195)
	at dotty.tools.dotc.Run.compile(Run.scala:179)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:35)
	at dotty.tools.dotc.Driver.process(Driver.scala:195)
	at dotty.tools.dotc.Driver.process(Driver.scala:163)
	at dotty.tools.dotc.Driver.process(Driver.scala:175)
	at dotty.tools.dotc.Driver.main(Driver.scala:205)
	at dotty.tools.dotc.Main.main(Main.scala)

@scala-center-bot
Copy link

This issue was picked for the Issue Spree No. 31 of 30 May 2023 which takes place in 2 days. @dwijnand, @iusildra will be working on it. If you have any insight into the issue or guidance on how to fix it, please leave it here.

@dwijnand
Copy link
Member

Adding AllowLambdaWildcardApply like in #17592 fixes this. Except it still fails -Ycheck:inlining because List[Union[Tuple_this]] is widened to List[Any] while the closure is still Union[?1 : Tuple] => Int...

@SethTisue
Copy link
Member

SethTisue commented Jul 5, 2023

Still broken in current nightly.

Note that in Kacper's minimization:

  • the crash goes away if you change tple to a val
  • the crash goes away if you .toList to an intermediate val, then separately .map (as @esse-byte already indicated)
  • inlining is involved because toList is inline (and it's relevant to inlining that tple isn't a stable identifier)

Dale and I are digging. Some thoughts/findings:

  • what's coming out of the inliner seems correct afawct
  • the crash happens during erasure
  • the crash occurs because map has NoDenotation. The type of tple is List[...] where ... is an unreduced match type. (It's expected that the match type doesn't reduce, because we've upcast to Tuple.)

But we don't even really have a hypothesis yet as to the actual cause. Some logic error in the mechanics of how denotations change from phase to phase?

@smarter
Copy link
Member

smarter commented Jul 5, 2023

This fails in inlining rather than erasure with -Ycheck:all:

Exception in thread "main" java.lang.AssertionError: assertion failed: 
Found:    Tuple.Union[(?1 : Tuple)] => Int
Required: (Tuple match {
  case EmptyTuple => Nothing
  case h *: t => h | Tuple.Fold[t, Nothing, [x, y] =>> x | y]
}) => Int

I believe the inlined code is equivalent to something like :

    def tple = Tuple("abc", "def")
    {
      val Tuple_this: Tuple = tple
      Tuple_this.productIterator.toList.asInstanceOf[List[Tuple.Union[Tuple_this.type]]]: List[Tuple.Union[? <: Tuple]]
    }.map(_ => 1)

(The type ascription with the wildcard is produced by ensureNoLocalRefs).
This also fails to typecheck:

-- [E007] Type Mismatch Error: try/i16207.scala:37:52 --------------------------
37 |      Tuple_this.productIterator.toList.asInstanceOf[List[Tuple.Union[Tuple_this.type]]]: List[Tuple.Union[? <: Tuple]]
   |      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |Found:    List[Tuple.Union[(Tuple_this : Tuple)]]
   |Required: List[
   |  Tuple match {
   |    case EmptyTuple => Nothing
   |    case h *: t => h | Tuple.Fold[t, Nothing, [x, y] =>> x | y]
   |  }
   |]
   |
   |Note: a match type could not be fully reduced:
   |
   |  trying to reduce  Tuple.Union[(Tuple_this : Tuple)]
   |  trying to reduce  Tuple.Fold[(Tuple_this : Tuple), Nothing, [x, y] =>> x | y]
   |  failed since selector (Tuple_this : Tuple)
   |  does not match  case EmptyTuple => Nothing
   |  and cannot be shown to be disjoint from it either.
   |  Therefore, reduction cannot advance to the remaining case
   |
   |    case h *: t => h | Tuple.Fold[t, Nothing, [x, y] =>> x | y]
   |
   | longer explanation available when compiling with `-explain`

It seems that the match type applied to a wildcard gets eagerly reduced, if we can avoid that then the subtyping check should succeed. Additionally, we might also want to change ApproximatingTypeMap to approximate a match type by its upper bound instead of leaving a wildcard, since it doesn't seem like that buys us anything.

@dwijnand
Copy link
Member

dwijnand commented Jul 5, 2023

diff --git compiler/src/dotty/tools/dotc/core/TypeComparer.scala compiler/src/dotty/tools/dotc/core/TypeComparer.scala
index abe17e21c2..697fa09b3c 100644
--- compiler/src/dotty/tools/dotc/core/TypeComparer.scala
+++ compiler/src/dotty/tools/dotc/core/TypeComparer.scala
@@ -1013,12 +1013,10 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
             def widenScrutinee(scrutinee1: Type) = scrutinee1 match
                 case tp: TermRef if tp.symbol.is(InlineProxy) => tp.info
                 case tp                                       => tp.widenSkolem
-            def checkScrutinee(scrutinee1: Type): Boolean =
-              isSameType(scrutinee1, tp2.scrutinee) || {
-                val widenScrutinee1 = widenScrutinee(scrutinee1)
-                (widenScrutinee1 ne scrutinee1) && checkScrutinee(widenScrutinee1)
-              }
-            checkScrutinee(tp1.scrutinee) &&
+            def checkScrutinee(scrutinee1: Type, scrutinee2: Type): Boolean =
+              isSameType(scrutinee1, scrutinee2) ||
+              isSameType(widenScrutinee(scrutinee1), widenScrutinee(scrutinee2))
+            checkScrutinee(tp1.scrutinee, tp2.scrutinee) &&
             tp1.cases.corresponds(tp2.cases)(isSubType)
           case _ => false
         }

🤔 #18043 @mbovel 😴/☕

nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Dec 4, 2023
This provides a way forward to fixing the signatures of some tuple
methods, and removes the inlining from the tuple methods. Optimization
will be implemented later directly on these method calls, which avoids
unnecessary complications due to inlining artifacts.

Old definitions are made tasty compatible and just delegate to the new
representation.

Fixes scala#12721
Fixes scala#15992
Fixes scala#16207
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Dec 7, 2023
This provides a way forward to fixing the signatures of some tuple
methods, and removes the inlining from the tuple methods. Optimization
will be implemented later directly on these method calls, which avoids
unnecessary complications due to inlining artifacts.

Old definitions are made tasty compatible and just delegate to the new
representation.

Fixes scala#12721
Fixes scala#15992
Fixes scala#16207
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Dec 7, 2023
This provides a way forward to fixing the signatures of some tuple
methods, and removes the inlining from the tuple methods. Optimization
will be implemented later directly on these method calls, which avoids
unnecessary complications due to inlining artifacts.

Old definitions are made tasty compatible and just delegate to the new
representation.

Fixes scala#12721
Fixes scala#15992
Fixes scala#16207
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Dec 8, 2023
This provides a way forward to fixing the signatures of some tuple
methods, and removes the inlining from the tuple methods. Optimization
will be implemented later directly on these method calls, which avoids
unnecessary complications due to inlining artifacts.

Fixes scala#12721
Fixes scala#16207
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Dec 19, 2023
This provides a way forward to fixing the signatures of some tuple
methods, and removes the inlining from the tuple methods. Optimization
will be implemented later directly on these method calls, which avoids
unnecessary complications due to inlining artifacts.

Fixes scala#12721
Fixes scala#16207
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Dec 19, 2023
This provides a way forward to fixing the signatures of some tuple
methods, and removes the inlining from the tuple methods. Optimization
will be implemented later directly on these method calls, which avoids
unnecessary complications due to inlining artifacts.

Fixes scala#12721
Fixes scala#16207
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Dec 20, 2023
This provides a way forward to fixing the signatures of some tuple
methods, and removes the inlining from the tuple methods. Optimization
will be implemented later directly on these method calls, which avoids
unnecessary complications due to inlining artifacts.

Fixes scala#12721
Fixes scala#16207
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Dec 20, 2023
This provides a way forward to fixing the signatures of some tuple
methods, and removes the inlining from the tuple methods. Optimization
will be implemented later directly on these method calls, which avoids
unnecessary complications due to inlining artifacts.

Fixes scala#12721
Fixes scala#16207
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Dec 20, 2023
This provides a way forward to fixing the signatures of some tuple
methods, and removes the inlining from the tuple methods. Optimization
will be implemented later directly on these method calls, which avoids
unnecessary complications due to inlining artifacts.

Fixes scala#12721
Fixes scala#16207
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Dec 20, 2023
This provides a way forward to fixing the signatures of some tuple
methods, and removes the inlining from the tuple methods. Optimization
will be implemented later directly on these method calls, which avoids
unnecessary complications due to inlining artifacts.

Fixes scala#12721
Fixes scala#16207
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jan 4, 2024
This provides a way forward to fixing the signatures of some tuple
methods, and removes the inlining from the tuple methods. Optimization
will be implemented later directly on these method calls, which avoids
unnecessary complications due to inlining artifacts.

Fixes scala#12721
Fixes scala#16207
@mbovel
Copy link
Member

mbovel commented Jan 14, 2024

@dwijnand @SethTisue @smarter what is the current state of this issue? Would like to continue working on it during a future Spree?

@KacperFKorban's minimization still crashes as of 3.4.0-RC1-bin-20240112-c50f2ff-NIGHTLY.

@nicolasstucki nicolasstucki removed the Spree Suitable for a future Spree label Jan 15, 2024
@nicolasstucki
Copy link
Contributor

The scope is this is not for a Spree anymore. Our only backward-compatible solution is to redefine the toList as an extension method and hide the old one. This is what I am testing in #19185. This is not a trivial change and comes with its drawbacks.

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

Successfully merging a pull request may close this issue.