Skip to content

Compile crush: Dependent Method Types and Varargs #23299

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
eanea opened this issue May 31, 2025 · 1 comment
Open

Compile crush: Dependent Method Types and Varargs #23299

eanea opened this issue May 31, 2025 · 1 comment

Comments

@eanea
Copy link

eanea commented May 31, 2025

Compiler version

3.3.5
3.6.4
3.7.0-RC1

Minimized code

def kek(t: Table, ids: t.Id*) = ???

trait Table {
  type Id = String
}

object Table1 extends Table {
  val id: Id = "table1_id"
}

kek(Table1, Table1.id)

https://scastie.scala-lang.org/hqos1NfBRCWm4jbmhqhmHQ

Output (click arrow to expand)

error when pickling type t.type
error when pickling type t.Id
error when pickling tree t.Id
error when pickling tree [Playground.Table1.id : t.Id]
error when pickling tree [Playground.Table1.id : t.Id]*
error when pickling tree Playground.kek(Playground.Table1, [Playground.Table1.id : t.Id]*)
error when pickling tree val $t: Nothing =
  Playground.kek(Playground.Table1, [Playground.Table1.id : t.Id]*)
error when pickling tree {
  val $t: Nothing =
    Playground.kek(Playground.Table1, [Playground.Table1.id : t.Id]*)
  Playground.instrumentationMap.update(
    _root_.com.olegych.scastie.api.Position.apply(133, 155),
    _root_.com.olegych.scastie.api.runtime.Runtime.render[Any]($t))
  $t:Nothing
}
error when pickling tree scala.Predef.locally[Nothing](
  {
    val $t: Nothing =
      Playground.kek(Playground.Table1, [Playground.Table1.id : t.Id]*)
    Playground.instrumentationMap.update(
      _root_.com.olegych.scastie.api.Position.apply(133, 155),
      _root_.com.olegych.scastie.api.runtime.Runtime.render[Any]($t))
    $t:Nothing
  }
)
error when pickling tree () extends Object(), com.olegych.scastie.api.runtime.ScastieApp {
  this: Playground.type =>
  private def writeReplace(): AnyRef =
    new scala.runtime.ModuleSerializationProxy(classOf[Playground.type])
  private[this] val instrumentationMap:
    
      scala.collection.mutable.Map[com.olegych.scastie.api.Position,
        com.olegych.scastie.api.Render]
    
   =
    _root_.scala.collection.mutable.Map.empty[
      _root_.com.olegych.scastie.api.Position,
      _root_.com.olegych.scastie.api.Render]
  def instrumentations: List[com.olegych.scastie.api.Instrumentation] =
    Playground.instrumentationMap.toList.map[
      com.olegych.scastie.api.Instrumentation](
      {
        def $anonfun(
          x$1:
            (com.olegych.scastie.api.Position, com.olegych.scastie.api.Render)
        ): com.olegych.scastie.api.Instrumentation =
          x$1 match 
            {
              case 
                Tuple2.unapply[com.olegych.scastie.api.Position,
                  com.olegych.scastie.api.Render](pos @ _, r @ _)
               =>
                _root_.com.olegych.scastie.api.Instrumentation.apply(pos, r)
            }
        closure($anonfun)
      }
    )
  def kek(t: Playground.Table, ids: Seq[t.Id] @Repeated): Nothing = ???
  trait Table() extends Object {
    type Id = String
  }
  final lazy module val Table1: Playground.Table1 = new Playground.Table1()
  final module class Table1() extends Object(), Playground.Table {
    this: Playground.Table1.type =>
    private def writeReplace(): AnyRef =
      new scala.runtime.ModuleSerializationProxy(classOf[Playground.Table1.type]
        )
    val id: Playground.Table1.Id = "table1_id"
  }
  scala.Predef.locally[Nothing](
    {
      val $t: Nothing =
        Playground.kek(Playground.Table1, [Playground.Table1.id : t.Id]*)
      Playground.instrumentationMap.update(
        _root_.com.olegych.scastie.api.Position.apply(133, 155),
        _root_.com.olegych.scastie.api.runtime.Runtime.render[Any]($t))
      $t:Nothing
    }
  )
}
error when pickling tree @SourceFile("src/main/scala/main.scala") final module class Playground() extends
   Object(), com.olegych.scastie.api.runtime.ScastieApp {
  this: Playground.type =>
  private def writeReplace(): AnyRef =
    new scala.runtime.ModuleSerializationProxy(classOf[Playground.type])
  private[this] val instrumentationMap:
    
      scala.collection.mutable.Map[com.olegych.scastie.api.Position,
        com.olegych.scastie.api.Render]
    
   =
    _root_.scala.collection.mutable.Map.empty[
      _root_.com.olegych.scastie.api.Position,
      _root_.com.olegych.scastie.api.Render]
  def instrumentations: List[com.olegych.scastie.api.Instrumentation] =
    Playground.instrumentationMap.toList.map[
      com.olegych.scastie.api.Instrumentation](
      {
        def $anonfun(
          x$1:
            (com.olegych.scastie.api.Position, com.olegych.scastie.api.Render)
        ): com.olegych.scastie.api.Instrumentation =
          x$1 match 
            {
              case 
                Tuple2.unapply[com.olegych.scastie.api.Position,
                  com.olegych.scastie.api.Render](pos @ _, r @ _)
               =>
                _root_.com.olegych.scastie.api.Instrumentation.apply(pos, r)
            }
        closure($anonfun)
      }
    )
  def kek(t: Playground.Table, ids: Seq[t.Id] @Repeated): Nothing = ???
  trait Table() extends Object {
    type Id = String
  }
  final lazy module val Table1: Playground.Table1 = new Playground.Table1()
  final module class Table1() extends Object(), Playground.Table {
    this: Playground.Table1.type =>
    private def writeReplace(): AnyRef =
      new scala.runtime.ModuleSerializationProxy(classOf[Playground.Table1.type]
        )
    val id: Playground.Table1.Id = "table1_id"
  }
  scala.Predef.locally[Nothing](
    {
      val $t: Nothing =
        Playground.kek(Playground.Table1, [Playground.Table1.id : t.Id]*)
      Playground.instrumentationMap.update(
        _root_.com.olegych.scastie.api.Position.apply(133, 155),
        _root_.com.olegych.scastie.api.runtime.Runtime.render[Any]($t))
      $t:Nothing
    }
  )
}
error when pickling tree package <empty> {
  import _root_.com.olegych.scastie.api.runtime.*
  final lazy module val Playground: Playground = new Playground()
  @SourceFile("src/main/scala/main.scala") final module class Playground()
     extends Object(), com.olegych.scastie.api.runtime.ScastieApp {
    this: Playground.type =>
    private def writeReplace(): AnyRef =
      new scala.runtime.ModuleSerializationProxy(classOf[Playground.type])
    private[this] val instrumentationMap:
      
        scala.collection.mutable.Map[com.olegych.scastie.api.Position,
          com.olegych.scastie.api.Render]
      
     =
      _root_.scala.collection.mutable.Map.empty[
        _root_.com.olegych.scastie.api.Position,
        _root_.com.olegych.scastie.api.Render]
    def instrumentations: List[com.olegych.scastie.api.Instrumentation] =
      Playground.instrumentationMap.toList.map[
        com.olegych.scastie.api.Instrumentation](
        {
          def $anonfun(
            x$1:
              (com.olegych.scastie.api.Position, com.olegych.scastie.api.Render)
            ): com.olegych.scastie.api.Instrumentation =
            x$1 match 
              {
                case 
                  Tuple2.unapply[com.olegych.scastie.api.Position,
                    com.olegych.scastie.api.Render](pos @ _, r @ _)
                 =>
                  _root_.com.olegych.scastie.api.Instrumentation.apply(pos, r)
              }
          closure($anonfun)
        }
      )
    def kek(t: Playground.Table, ids: Seq[t.Id] @Repeated): Nothing = ???
    trait Table() extends Object {
      type Id = String
    }
    final lazy module val Table1: Playground.Table1 = new Playground.Table1()
    final module class Table1() extends Object(), Playground.Table {
      this: Playground.Table1.type =>
      private def writeReplace(): AnyRef =
        new scala.runtime.ModuleSerializationProxy(
          classOf[Playground.Table1.type])
      val id: Playground.Table1.Id = "table1_id"
    }
    scala.Predef.locally[Nothing](
      {
        val $t: Nothing =
          Playground.kek(Playground.Table1, [Playground.Table1.id : t.Id]*)
        Playground.instrumentationMap.update(
          _root_.com.olegych.scastie.api.Position.apply(133, 155),
          _root_.com.olegych.scastie.api.runtime.Runtime.render[Any]($t))
        $t:Nothing
      }
    )
  }
}

  unhandled exception while running pickler on
@eanea eanea added itype:bug itype:crash stat:needs triage Every issue needs to have an "area" and "itype" label labels May 31, 2025
@Gedochao
Copy link
Contributor

Gedochao commented Jun 3, 2025

Full crash output:

error when pickling type t.type
error when pickling type t.Id
error when pickling tree t.Id of class class dotty.tools.dotc.ast.Trees$InferredTypeTree
error when pickling tree [Table1.id : t.Id] of class class dotty.tools.dotc.ast.Trees$SeqLiteral
error when pickling tree [Table1.id : t.Id]* of class class dotty.tools.dotc.ast.Trees$Typed
error when pickling tree kek(Table1, [Table1.id : t.Id]*) of class class dotty.tools.dotc.ast.Trees$Apply
error when pickling tree {
  kek(Table1, [Table1.id : t.Id]*)
} of class class dotty.tools.dotc.ast.Trees$Block
error when pickling tree @main def main: Nothing =
  {
    kek(Table1, [Table1.id : t.Id]*)
  } of class class dotty.tools.dotc.ast.Trees$DefDef
error when pickling tree () extends Object() { this: repro$package.type =>
  private def writeReplace(): AnyRef =
    new scala.runtime.ModuleSerializationProxy(classOf[repro$package.type])
  def kek(t: Table, ids: Seq[t.Id] @Repeated): Nothing = ???
  @main def main: Nothing =
    {
      kek(Table1, [Table1.id : t.Id]*)
    }
} of class class dotty.tools.dotc.ast.Trees$Template
error when pickling tree @SourceFile("repro.scala") final module class repro$package() extends Object() {
   this: repro$package.type =>
  private def writeReplace(): AnyRef =
    new scala.runtime.ModuleSerializationProxy(classOf[repro$package.type])
  def kek(t: Table, ids: Seq[t.Id] @Repeated): Nothing = ???
  @main def main: Nothing =
    {
      kek(Table1, [Table1.id : t.Id]*)
    }
} of class class dotty.tools.dotc.ast.Trees$TypeDef
error when pickling tree package <empty> {
  final lazy module val repro$package: repro$package = new repro$package()
  @SourceFile("repro.scala") final module class repro$package() extends Object()
     { this: repro$package.type =>
    private def writeReplace(): AnyRef =
      new scala.runtime.ModuleSerializationProxy(classOf[repro$package.type])
    def kek(t: Table, ids: Seq[t.Id] @Repeated): Nothing = ???
    @main def main: Nothing =
      {
        kek(Table1, [Table1.id : t.Id]*)
      }
  }
} of class class dotty.tools.dotc.ast.Trees$PackageDef

  unhandled exception while running pickler on /Users/pchabelski/IdeaProjects/scala-cli-tests-3/scala-cli-tests-3/compiler-repro/repro.scala

  An unhandled exception was thrown in the compiler.
  Please file a crash report here:
  https://github.com/scala/scala3/issues/new/choose
  For non-enriched exceptions, compile with -Xno-enrich-error-messages.


     while compiling: /Users/pchabelski/IdeaProjects/scala-cli-tests-3/scala-cli-tests-3/compiler-repro/repro.scala
        during phase: pickler
                mode: Mode(ImplicitsEnabled)
     library version: version 2.13.16
    compiler version: version 3.7.0-RC1
            settings: -classpath /Users/pchabelski/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.7.0-RC1/scala3-library_3-3.7.0-RC1.jar:/Users/pchabelski/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.16/scala-library-2.13.16.jar -d /Users/pchabelski/IdeaProjects/scala-cli-tests-3/scala-cli-tests-3/compiler-repro/.scala-build/compiler-repro_05dd00baf2-9acd81c9bc/classes/main -sourceroot /Users/pchabelski/IdeaProjects/scala-cli-tests-3/scala-cli-tests-3/compiler-repro

Exception in thread "main" java.lang.AssertionError: assertion failed: orphan parameter reference: TermParamRef(t)
        at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleNewType(TreePickler.scala:318)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleType(TreePickler.scala:183)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleNewType(TreePickler.scala:239)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleType(TreePickler.scala:183)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:716)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:610)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:560)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$3(TreePickler.scala:527)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:334)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:527)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:571)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTreeUnlessEmpty(TreePickler.scala:356)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:390)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:662)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleStats$$anonfun$2(TreePickler.scala:423)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:334)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleStats(TreePickler.scala:423)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:698)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:381)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:664)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleStats$$anonfun$2(TreePickler.scala:423)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:334)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleStats(TreePickler.scala:423)
        at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:714)
        at dotty.tools.dotc.core.tasty.TreePickler.pickle$$anonfun$1(TreePickler.scala:938)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:334)
        at dotty.tools.dotc.core.tasty.TreePickler.pickle(TreePickler.scala:936)
        at dotty.tools.dotc.transform.Pickler.run$$anonfun$1$$anonfun$1(Pickler.scala:306)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:334)
        at dotty.tools.dotc.transform.Pickler.run$$anonfun$1(Pickler.scala:279)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:334)
        at dotty.tools.dotc.transform.Pickler.run(Pickler.scala:278)
        at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:383)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:334)
        at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:376)
        at dotty.tools.dotc.transform.Pickler.runPhase$1(Pickler.scala:392)
        at dotty.tools.dotc.transform.Pickler.runOn(Pickler.scala:398)
        at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:367)
        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:1324)
        at dotty.tools.dotc.Run.runPhases$1(Run.scala:360)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1$$anonfun$2(Run.scala:407)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1$$anonfun$adapted$1(Run.scala:407)
        at scala.Function0.apply$mcV$sp(Function0.scala:42)
        at dotty.tools.dotc.Run.showProgress(Run.scala:469)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:407)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:419)
        at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:69)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:419)
        at dotty.tools.dotc.Run.compileSources(Run.scala:306)
        at dotty.tools.dotc.Run.compile(Run.scala:291)
        at dotty.tools.dotc.Driver.doCompile(Driver.scala:37)
        at dotty.tools.dotc.Driver.process(Driver.scala:201)
        at dotty.tools.dotc.Driver.process(Driver.scala:169)
        at dotty.tools.dotc.Driver.process(Driver.scala:181)
        at dotty.tools.dotc.Driver.main(Driver.scala:211)
        at dotty.tools.dotc.Main.main(Main.scala)

@Gedochao Gedochao added area:pickling and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Jun 3, 2025
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