Skip to content

Scoping issue with inline inside a private method #3082

Closed
@OlivierBlanvillain

Description

@OlivierBlanvillain
object Test {
  private def foo(arg1: Int): Int = {
    inline def bar: Int = foo(0)
    arg1
  }
}

Results in an assertion failed: symbol (method bar$_inlineAccessor_$1) entered the scope of non-class owner method foo

Full Stack trace
Exception in thread "main" java.lang.AssertionError: assertion failed: symbol (method bar$_inlineAccessor_$1) entered the scope of non-class owner method foo
        at scala.Predef$.assert(Predef.scala:219)
        at dotty.tools.dotc.core.Symbols$Symbol.entered(Symbols.scala:452)
        at dotty.tools.dotc.typer.Inliner$addAccessors$2$.accessorSymbol(Inliner.scala:66)
        at dotty.tools.dotc.typer.Inliner$addAccessors$2$.addAccessor(Inliner.scala:92)
        at dotty.tools.dotc.typer.Inliner$addAccessors$2$.transform(Inliner.scala:151)
        at dotty.tools.dotc.typer.Inliner$.makeInlineable(Inliner.scala:177)
        at dotty.tools.dotc.typer.Inliner$.$anonfun$registerInlineInfo$1(Inliner.scala:200)
        at dotty.tools.dotc.core.Annotations$LazyBodyAnnotation.tree(Annotations.scala:71)
        at dotty.tools.dotc.typer.Inliner$.bodyAndAccessors(Inliner.scala:213)
        at dotty.tools.dotc.typer.Inliner$.bodyToInline(Inliner.scala:222)
        at dotty.tools.dotc.typer.Typer.inlineExpansion(Typer.scala:1745)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:1716)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:1737)
        at dotty.tools.dotc.typer.Typer.typedBlockStats(Typer.scala:620)
        at dotty.tools.dotc.typer.Typer.$anonfun$typedBlock$1(Typer.scala:623)
        at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
        at dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:622)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1637)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1677)
        at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1692)
        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:58)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1690)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:1749)
        at dotty.tools.dotc.typer.Typer.$anonfun$typedDefDef$1(Typer.scala:1303)
        at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
        at dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:1285)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1618)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1676)
        at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1692)
        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:58)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1690)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:1714)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:1737)
        at dotty.tools.dotc.typer.Typer.$anonfun$typedClassDef$1(Typer.scala:1403)
        at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
        at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:1333)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1621)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1676)
        at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1692)
        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:58)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1690)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:1714)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:1737)
        at dotty.tools.dotc.typer.Typer.$anonfun$typedPackageDef$1(Typer.scala:1520)
        at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
        at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:1507)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1660)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1677)
        at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1692)
        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:58)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1690)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:1749)
        at dotty.tools.dotc.typer.FrontEnd.$anonfun$typeCheck$1(FrontEnd.scala:64)
        at dotty.tools.dotc.typer.FrontEnd.monitor(FrontEnd.scala:32)
        at dotty.tools.dotc.typer.FrontEnd.typeCheck(FrontEnd.scala:62)
        at dotty.tools.dotc.typer.FrontEnd.$anonfun$runOn$5(FrontEnd.scala:93)
        at dotty.tools.dotc.typer.FrontEnd.$anonfun$runOn$5$adapted(FrontEnd.scala:93)
        at scala.collection.immutable.List.foreach(List.scala:389)
        at dotty.tools.dotc.typer.FrontEnd.runOn(FrontEnd.scala:93)
        at dotty.tools.dotc.Run.$anonfun$compileUnits$2(Run.scala:123)
        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$.monitorHeartBeat(Stats.scala:76)
        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
        at scala.sys.package$.error(package.scala:27)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions