Skip to content

Compiler crashes during HoistSuperArgs #3189

Closed
@allanrenucci

Description

@allanrenucci

The following code snippet crashes the compiler

class Test[A](action: A => A) {
  def this() = this(a => a)
}
Stacktrace
exception while transforming @scala.annotation.internal.SourceFile("tests/allan/Test.scala") class Test[A](
  action: A => A
) extends Object() { 
  A
  private[this] val action: Test.this.A => Test.this.A
  def [A](): Unit = 
    {
      this[Test.this.A](
        {
          def $anonfun(a: Test.this.A): Test.this.A = a
          closure($anonfun)
        }
      )
      ()
    }
} of class class dotty.tools.dotc.ast.Trees$TypeDef # 131
exception while transforming package  {
  @scala.annotation.internal.SourceFile("tests/allan/Test.scala") class Test[A](
    action: A => A
  ) extends Object() { 
    A
    private[this] val action: Test.this.A => Test.this.A
    def [A](): Unit = 
      {
        this[Test.this.A](
          {
            def $anonfun(a: Test.this.A): Test.this.A = a
            closure($anonfun)
          }
        )
        ()
      }
  }
} of class class dotty.tools.dotc.ast.Trees$PackageDef # 132

exception occurred while compiling tests/allan/Test.scala
Exception in thread "main" java.util.NoSuchElementException: key not found: type A
at scala.collection.immutable.Map$Map1.apply(Map.scala:108)
at dotty.tools.dotc.transform.HoistSuperArgs$Hoister$$anon$1.apply(HoistSuperArgs.scala:131)
at dotty.tools.dotc.core.Types$TypeMap.$anonfun$mapOver$2(Types.scala:3755)
at dotty.tools.dotc.core.Types$VariantTraversal.atVariance(Types.scala:3679)
at dotty.tools.dotc.core.Types$TypeMap.mapArgs$1(Types.scala:3755)
at dotty.tools.dotc.core.Types$TypeMap.mapOver(Types.scala:3763)
at dotty.tools.dotc.transform.HoistSuperArgs$Hoister$$anon$1.apply(HoistSuperArgs.scala:134)
at dotty.tools.dotc.transform.HoistSuperArgs$Hoister$$anon$1.apply(HoistSuperArgs.scala:125)
at dotty.tools.dotc.ast.TreeTypeMap.mapType(TreeTypeMap.scala:62)
at dotty.tools.dotc.ast.TreeTypeMap.transform(TreeTypeMap.scala:89)
at dotty.tools.dotc.ast.TreeTypeMap.apply(TreeTypeMap.scala:140)
at dotty.tools.dotc.transform.HoistSuperArgs$Hoister.$anonfun$hoistSuperArg$5(HoistSuperArgs.scala:143)
at dotty.tools.dotc.ast.tpd$.polyDefDef(tpd.scala:209)
at dotty.tools.dotc.transform.HoistSuperArgs$Hoister.hoistSuperArg(HoistSuperArgs.scala:122)
at dotty.tools.dotc.transform.HoistSuperArgs$Hoister.$anonfun$hoistSuperArgsFromCall$1(HoistSuperArgs.scala:168)
at dotty.tools.dotc.core.Decorators$ListDecorator$.loop$1(Decorators.scala:62)
at dotty.tools.dotc.core.Decorators$ListDecorator$.mapconserve$extension(Decorators.scala:78)
at dotty.tools.dotc.transform.HoistSuperArgs$Hoister.hoistSuperArgsFromCall(HoistSuperArgs.scala:168)
at dotty.tools.dotc.transform.HoistSuperArgs$Hoister.hoistSuperArgsFromConstr(HoistSuperArgs.scala:179)
at dotty.tools.dotc.transform.HoistSuperArgs.$anonfun$transformTypeDef$1(HoistSuperArgs.scala:195)
at dotty.tools.dotc.core.Decorators$ListDecorator$.loop$1(Decorators.scala:62)
at dotty.tools.dotc.core.Decorators$ListDecorator$.mapconserve$extension(Decorators.scala:78)
at dotty.tools.dotc.transform.HoistSuperArgs.transformTypeDef(HoistSuperArgs.scala:195)
at dotty.tools.dotc.transform.TreeTransforms$TreeTransformer.goTypeDef(TreeTransform.scala:839)
at dotty.tools.dotc.transform.TreeTransforms$TreeTransformer.transformNamed(TreeTransform.scala:986)
at dotty.tools.dotc.transform.TreeTransforms$TreeTransformer.$anonfun$transform$5(TreeTransform.scala:1184)
at dotty.tools.dotc.reporting.Reporting.traceIndented(Reporter.scala:140)
at dotty.tools.dotc.reporting.Reporting.traceIndented$(Reporter.scala:139)
at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:57)
at dotty.tools.dotc.transform.TreeTransforms$TreeTransformer.transform(TreeTransform.scala:1177)
at dotty.tools.dotc.transform.TreeTransforms$TreeTransformer.transformStat$1(TreeTransform.scala:1210)
at dotty.tools.dotc.transform.TreeTransforms$TreeTransformer.$anonfun$transformStats$2(TreeTransform.scala:1214)
at dotty.tools.dotc.core.Decorators$ListDecorator$.loop$1(Decorators.scala:62)
at dotty.tools.dotc.core.Decorators$ListDecorator$.mapconserve$extension(Decorators.scala:78)
at dotty.tools.dotc.transform.TreeTransforms$TreeTransformer.transformStats(TreeTransform.scala:1214)
at dotty.tools.dotc.transform.TreeTransforms$TreeTransformer.transformUnnamed(TreeTransform.scala:1164)
at dotty.tools.dotc.transform.TreeTransforms$TreeTransformer.$anonfun$transform$5(TreeTransform.scala:1185)
at dotty.tools.dotc.reporting.Reporting.traceIndented(Reporter.scala:140)
at dotty.tools.dotc.reporting.Reporting.traceIndented$(Reporter.scala:139)
at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:57)
at dotty.tools.dotc.transform.TreeTransforms$TreeTransformer.transform(TreeTransform.scala:1177)
at dotty.tools.dotc.transform.TreeTransforms$TreeTransformer.macroTransform(TreeTransform.scala:557)
at dotty.tools.dotc.transform.TreeTransforms$TreeTransformer.run(TreeTransform.scala:475)
at dotty.tools.dotc.core.Phases$Phase.$anonfun$runOn$1(Phases.scala:288)
at scala.collection.immutable.List.map(List.scala:283)
at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:286)
at dotty.tools.dotc.core.Phases$Phase.runOn$(Phases.scala:285)
at dotty.tools.dotc.transform.TreeTransforms$TreeTransformer.runOn(TreeTransform.scala:469)
at dotty.tools.dotc.Run.$anonfun$compileUnits$3(Run.scala:124)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
at dotty.tools.dotc.util.Stats$.trackTime(Stats.scala:47)
at dotty.tools.dotc.Run.$anonfun$compileUnits$2(Run.scala:122)
at dotty.tools.dotc.Run.$anonfun$compileUnits$2$adapted(Run.scala:120)
at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:32)
at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:29)
at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:191)
at dotty.tools.dotc.Run.$anonfun$compileUnits$1(Run.scala:120)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:86)
at dotty.tools.dotc.Run.compileUnits(Run.scala:108)
at dotty.tools.dotc.Run.compileSources(Run.scala:95)
at dotty.tools.dotc.Run.compile(Run.scala:79)
at dotty.tools.dotc.Driver.doCompile(Driver.scala:26)
at dotty.tools.dotc.Driver.process(Driver.scala:124)
at dotty.tools.dotc.Driver.process(Driver.scala:93)
at dotty.tools.dotc.Driver.process(Driver.scala:105)
at dotty.tools.dotc.Driver.main(Driver.scala:132)
at dotty.tools.dotc.Main.main(Main.scala)
java.lang.RuntimeException: Nonzero exit code returned from runner: 1


Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions