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

Inlined match crashes when rhs uses private inlined methods #18589

Closed
WojciechMazur opened this issue Sep 25, 2023 · 0 comments · Fixed by #18595
Closed

Inlined match crashes when rhs uses private inlined methods #18589

WojciechMazur opened this issue Sep 25, 2023 · 0 comments · Fixed by #18595
Assignees
Labels
area:inline itype:bug itype:crash regression This worked in a previous version but doesn't anymore

Comments

@WojciechMazur
Copy link
Contributor

Regression found in Open Community Build in following projects:

Project Version Build URL Notes
hnaderi/named-codec 0.2.0 Open CB logs Minimization based on this project
lunatech-labs/course-management-tools 2.0.19 Open CB logs
zio/zio-prelude 1.0.0-RC20 -> 1.0.0-RC21 Open CB logs

Compiler version

3.4.0-RC1-bin-20230921-3d539e6-NIGHTLY
Bisect points to: fe4a685

Minimized code

The usage of inlined method needs to be defined in different compilation unit

// core_0.scala
import scala.deriving.Mirror

trait NamedCodec[A, R]

object NamedCodecPlatform {

  final class Builder[R]() {
    inline def of[T](using m: Mirror.Of[T]): NamedCodec[T, R] =
      inline m match {
        case s: Mirror.SumOf[T]     => sumInst(s)
        case _: Mirror.ProductOf[T] => productInst
      }

    private inline def productInst[T]: NamedCodec[T, R] = ???
    private inline def sumInst[T](m: Mirror.SumOf[T]): NamedCodec[T, R] = ???
  }
}
// test_1.scala
enum Data {
  case A, B, C
}

@main def Test = {
  val builder: NamedCodecPlatform.Builder[Any] = ???
  builder.of[Data]
}

Output (click arrow to expand)

  unhandled exception while running inlining on /Users/wmazur/projects/dotty/bisect/main.test.scala

  An unhandled exception was thrown in the compiler.
  Please file a crash report here:
  https://github.com/lampepfl/dotty/issues/new/choose

     while compiling: /Users/wmazur/projects/dotty/bisect/main.test.scala
        during phase: inlining
                mode: Mode(ImplicitsEnabled)
     library version: version 2.13.10
    compiler version: version 3.4.0-RC1-bin-20230920-b1fc943-NIGHTLY-git-b1fc943
            settings: -classpath /Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.4.0-RC1-bin-20230920-b1fc943-NIGHTLY/scala3-library_3-3.4.0-RC1-bin-20230920-b1fc943-NIGHTLY.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.10/scala-library-2.13.10.jar:/Users/wmazur/projects/dotty/bisect/.scala-build/project_7b7a0d617e-28223c4e44/classes/main:/Users/wmazur/projects/dotty/bisect/.scala-build/project_7b7a0d617e-28223c4e44/classes/main -d /Users/wmazur/projects/dotty/bisect/.scala-build/project_7b7a0d617e-28223c4e44/classes/test -java-output-version 17 -sourceroot /Users/wmazur/projects/dotty/bisect

                tree: EmptyTree
       tree position: :<unknown>
           tree type: <notype>
              symbol: val <none>
           call site: package <root> in module class <root>

  == Source file context for tree position ==


Exception in thread "main" java.lang.AssertionError: assertion failed
        at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:11)
        at dotty.tools.dotc.util.Spans$Span$.start$extension(Spans.scala:45)
        at dotty.tools.dotc.ast.Trees$Select.nameSpan(Trees.scala:458)
        at dotty.tools.dotc.inlines.Inliner$InlineTyper.typedSelect(Inliner.scala:774)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3080)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3178)
        at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:174)
        at dotty.tools.dotc.inlines.Inliner$InlineTyper.typedUnadapted(Inliner.scala:919)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3258)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3262)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3374)
        at dotty.tools.dotc.typer.Applications.typedTypeApply(Applications.scala:1170)
        at dotty.tools.dotc.typer.Applications.typedTypeApply$(Applications.scala:352)
        at dotty.tools.dotc.inlines.Inliner$InlineTyper.typedTypeApply(Inliner.scala:824)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3131)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3179)
        at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:174)
        at dotty.tools.dotc.inlines.Inliner$InlineTyper.typedUnadapted(Inliner.scala:919)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3258)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3262)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3374)
        at dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:958)
        at dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:1118)
        at dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:352)
        at dotty.tools.dotc.inlines.Inliner$InlineTyper.typedApply(Inliner.scala:820)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3111)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3179)
        at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:174)
        at dotty.tools.dotc.inlines.Inliner$InlineTyper.typedUnadapted(Inliner.scala:919)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3258)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3262)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3374)
        at dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:1176)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3119)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3179)
        at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:174)
        at dotty.tools.dotc.inlines.Inliner$InlineTyper.typedUnadapted(Inliner.scala:919)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3258)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3262)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3374)
        at dotty.tools.dotc.inlines.Inliner$InlineTyper.typedMatchFinish(Inliner.scala:890)
        at dotty.tools.dotc.typer.Typer.typedMatch(Typer.scala:1797)
        at dotty.tools.dotc.inlines.Inliner$InlineTyper.typedMatch(Inliner.scala:851)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3126)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3179)
        at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:174)
        at dotty.tools.dotc.inlines.Inliner$InlineTyper.typedUnadapted(Inliner.scala:919)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3258)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3262)
        at dotty.tools.dotc.typer.ReTyper.typedTyped(ReTyper.scala:65)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3116)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3179)
        at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:174)
        at dotty.tools.dotc.inlines.Inliner$InlineTyper.typedUnadapted(Inliner.scala:919)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3258)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3255)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3262)
        at dotty.tools.dotc.inlines.Inliner.inlined(Inliner.scala:681)
        at dotty.tools.dotc.inlines.Inlines$InlineCall.expand(Inlines.scala:449)
        at dotty.tools.dotc.inlines.Inlines$.inlineCall(Inlines.scala:152)
        at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:95)
        at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformBlock$$anonfun$1$$anonfun$1(tpd.scala:1255)
        at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.loop$2(tpd.scala:1237)
        at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformStats(tpd.scala:1250)
        at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformBlock(tpd.scala:1255)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1543)
        at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:43)
        at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:91)
        at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:50)
        at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:89)
        at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.loop$2(tpd.scala:1250)
        at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformStats(tpd.scala:1250)
        at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformStats(tpd.scala:1252)
        at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:58)
        at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:108)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1597)
        at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:67)
        at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:89)
        at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.loop$2(tpd.scala:1250)
        at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformStats(tpd.scala:1250)
        at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformStats(tpd.scala:1252)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1608)
        at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:67)
        at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:97)
        at dotty.tools.dotc.transform.Inlining$$anon$2.transform(Inlining.scala:58)
        at dotty.tools.dotc.transform.MacroTransform.run(MacroTransform.scala:18)
        at dotty.tools.dotc.transform.Inlining.run(Inlining.scala:34)
        at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:327)
        at scala.collection.immutable.List.map(List.scala:246)
        at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:331)
        at dotty.tools.dotc.transform.Inlining.runOn(Inlining.scala:38)
        at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:246)
        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:71)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:280)
        at dotty.tools.dotc.Run.compileSources(Run.scala:194)
        at dotty.tools.dotc.Run.compile(Run.scala:179)
        at dotty.tools.dotc.Driver.doCompile(Driver.scala:37)
        at dotty.tools.dotc.Driver.process(Driver.scala:197)
        at dotty.tools.dotc.Driver.process(Driver.scala:165)
        at dotty.tools.dotc.Driver.process(Driver.scala:177)
        at dotty.tools.dotc.Driver.main(Driver.scala:207)
        at dotty.tools.dotc.Main.main(Main.scala)
        ```
</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:inline itype:bug itype:crash regression This worked in a previous version but doesn't anymore
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants