Skip to content

-Ycheck failure for inline accessors generated in packages #19572

Open
@nicolasstucki

Description

@nicolasstucki

Compiler version

3.4.0-RC3 (probably also on 3.3.X)

Minimized code

package foo
package object G:
  private[foo] val valBinaryAPI2: Int = 1
package object H:
  inline def inlined = G.valBinaryAPI2 // -Ycheck failure

or

package foo
package I:
  private[foo] val valBinaryAPI2: Int = 1
package J:
  inline def inlined = I.valBinaryAPI2 // -Ycheck failure

Output

[[syntax trees at end of                     typer]] // tests/neg/inline-unstable-accessors.scala
package foo {
  package foo.G {
    final lazy module val package: foo.G.package = new foo.G.package()
    final module class package() extends Object() { this: foo.G.package.type =>
      private[foo] val valBinaryAPI2: Int = 1
    }
  }
  package foo.H {
    final lazy module val package: foo.H.package = new foo.H.package()
    final module class package() extends Object() { this: foo.H.package.type =>
      inline def inlined: Int = foo.H.inline$valBinaryAPI2$i1(foo.G):Int
      def inline$valBinaryAPI2$i1(x$0: foo.G): Int = x$0.valBinaryAPI2
    }
  }
}
checking tests/neg/inline-unstable-accessors.scala after phase MegaPhase{crossVersionChecks, firstTransform, checkReentrant, elimPackagePrefixes, cookComments, checkLoopingImplicits, betaReduce, inlineVals, expandSAMs, elimRepeated, refchecks}

  exception while retyping def inline$valBinaryAPI2$i1(x$0: foo.G): Int = x$0.valBinaryAPI2 of class DefDef # -1

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

     while compiling: tests/neg/inline-unstable-accessors.scala
        during phase: Ycheck
                mode: Mode(ImplicitsEnabled)
     library version: version 2.13.12
    compiler version: version 3.4.1-RC1-bin-SNAPSHOT-nonbootstrapped-git-c48406c
            settings: -Ycheck List(all) -classpath /Users/nicolasstucki/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.12/scala-library-2.13.12.jar:/Users/nicolasstucki/Github/dotty/library/../out/bootstrap/scala3-library-bootstrapped/scala-3.4.1-RC1-bin-SNAPSHOT-nonbootstrapped/scala3-library_3-3.4.1-RC1-bin-SNAPSHOT.jar -d /
Exception in thread "main" *** error while checking tests/neg/inline-unstable-accessors.scala after phase MegaPhase{crossVersionChecks, firstTransform, checkReentrant, elimPackagePrefixes, cookComments, checkLoopingImplicits, betaReduce, inlineVals, expandSAMs, elimRepeated, refchecks} ***
java.lang.AssertionError: assertion failed: non member selection of value valBinaryAPI2 in package foo.G from (x$0 : foo.G) in x$0.valBinaryAPI2
        at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
        at dotty.tools.dotc.transform.FirstTransform.checkPostCondition(FirstTransform.scala:62)
        at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted$$anonfun$1(TreeChecker.scala:415)
        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:333)
        at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:415)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3274)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3278)
        at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:381)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3389)
        at dotty.tools.dotc.typer.Typer.$anonfun$62(Typer.scala:2601)
        at dotty.tools.dotc.inlines.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:256)
        at dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:2601)
        at dotty.tools.dotc.transform.TreeChecker$Checker.typedDefDef$$anonfun$1(TreeChecker.scala:611)
        at dotty.tools.dotc.transform.TreeChecker$Checker.withDefinedSyms(TreeChecker.scala:248)
        at dotty.tools.dotc.transform.TreeChecker$Checker.typedDefDef(TreeChecker.scala:614)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3095)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3196)
        at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:174)
        at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:398)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3274)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3278)
        at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:381)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3300)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3346)
        at dotty.tools.dotc.transform.TreeChecker$Checker.typedStats(TreeChecker.scala:654)
        at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2788)
        at dotty.tools.dotc.transform.TreeChecker$Checker.typedClassDef(TreeChecker.scala:581)
        at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:3101)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3105)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3196)
        at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:174)
        at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:398)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3274)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3278)
        at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:381)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3300)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3346)
        at dotty.tools.dotc.transform.TreeChecker$Checker.typedStats(TreeChecker.scala:654)
        at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2921)
        at dotty.tools.dotc.transform.TreeChecker$Checker.typedPackageDef(TreeChecker.scala:680)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3147)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3197)
        at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:174)
        at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:398)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3274)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3278)
        at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:381)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3327)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3346)
        at dotty.tools.dotc.transform.TreeChecker$Checker.typedStats(TreeChecker.scala:654)
        at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2921)
        at dotty.tools.dotc.transform.TreeChecker$Checker.typedPackageDef(TreeChecker.scala:680)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3147)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3197)
        at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:174)
        at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:398)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3274)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3278)
        at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:381)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3389)
        at dotty.tools.dotc.transform.TreeChecker.check(TreeChecker.scala:129)
        at dotty.tools.dotc.transform.TreeChecker.run(TreeChecker.scala:109)
        at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:354)
        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:333)
        at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:360)
        at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:315)
        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:1323)
        at dotty.tools.dotc.Run.runPhases$1(Run.scala:337)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:350)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:359)
        at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:69)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:359)
        at dotty.tools.dotc.Run.compileSources(Run.scala:261)
        at dotty.tools.dotc.Run.compile(Run.scala:246)
        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)

Expectation

It should pass -Ycheck or emit an error if it is impossible to generate such accessor.

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