Skip to content

Non-applied inlined contextual closure fails when inlined #6863

Closed
@nicolasstucki

Description

@nicolasstucki

Minimized code

lib.scala

trait Ctx
inline def foo(): Unit = given (x: Ctx) => ()

app.scala

class Test {
  foo()
}
Stack trace
sbt:dotty> dotc lib.scala
[warn] Multiple main classes detected.  Run 'show discoveredMainClasses' to see the list
[info] Running (fork) dotty.tools.dotc.Main -classpath /Users/nicolasstucki/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.12.8.jar:/Users/nicolasstucki/GitHub/dotty/library/../out/bootstrap/dotty-library-bootstrapped/scala-0.17/dotty-library_0.17-0.17.0-bin-SNAPSHOT.jar lib.scala
-- [E129] Potential Issue Warning: lib.scala:4:32 
4 |inline def foo(): Unit = given (x: Ctx) => ()
  |                                ^^^^^^^^^^^^^
  |A pure expression does nothing in statement position; you may be omitting necessary parentheses

longer explanation available when compiling with `-explain`
one warning found

[success] Total time: 3 s, completed Jul 16, 2019 5:45:25 PM


sbt:dotty> dotc -classpath . app.scala
[warn] Multiple main classes detected.  Run 'show discoveredMainClasses' to see the list
[info] Running (fork) dotty.tools.dotc.Main -classpath .:/Users/nicolasstucki/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.12.8.jar:/Users/nicolasstucki/GitHub/dotty/library/../out/bootstrap/dotty-library-bootstrapped/scala-0.17/dotty-library_0.17-0.17.0-bin-SNAPSHOT.jar app.scala
exception occurred while typechecking app.scala
exception occurred while compiling app.scala
java.lang.AssertionError: assertion failed: Select(TypedSplice(Block(List(DefDef($anonfun,List(),List(List(ValDef(x,Ident(Ctx),EmptyTree))),TypeTree[TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),module scala),Unit)],Literal(Constant(())))),Closure(List(),Ident($anonfun),EmptyTree))),apply) while compiling app.scala
Exception in thread "main" java.lang.AssertionError: assertion failed: Select(TypedSplice(Block(List(DefDef($anonfun,List(),List(List(ValDef(x,Ident(Ctx),EmptyTree))),TypeTree[TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),module scala),Unit)],Literal(Constant(())))),Closure(List(),Ident($anonfun),EmptyTree))),apply)
	at dotty.DottyPredef$.assertFail(DottyPredef.scala:16)
	at dotty.tools.dotc.typer.Inliner$InlineTyper.typedSelect(Inliner.scala:1011)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2304)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2377)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:124)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2416)
	at dotty.tools.dotc.typer.Typer.adaptNoArgsOther$6(Typer.scala:2987)
	at dotty.tools.dotc.typer.Typer.adaptNoArgs$1(Typer.scala:3095)
	at dotty.tools.dotc.typer.Typer.adapt1(Typer.scala:3302)
	at dotty.tools.dotc.typer.Typer.adapt(Typer.scala:2716)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2416)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2428)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2471)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2493)
	at dotty.tools.dotc.typer.Typer.typedBlockStats(Typer.scala:703)
	at dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:706)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2331)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2378)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:124)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2416)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2428)
	at dotty.tools.dotc.typer.ReTyper.typedTyped(ReTyper.scala:60)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2328)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2378)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:124)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2416)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2414)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2428)
	at dotty.tools.dotc.typer.Inliner.inlined(Inliner.scala:547)
	at dotty.tools.dotc.typer.Inliner$.inlineCall(Inliner.scala:109)
	at dotty.tools.dotc.typer.Typer.adaptNoArgsOther$6(Typer.scala:2998)
	at dotty.tools.dotc.typer.Typer.adaptNoArgs$1(Typer.scala:3095)
	at dotty.tools.dotc.typer.Typer.adapt1(Typer.scala:3302)
	at dotty.tools.dotc.typer.Typer.adapt(Typer.scala:2716)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2416)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2428)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2471)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2493)
	at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:1670)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2314)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2377)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2416)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2428)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2447)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2493)
	at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:1794)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2354)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2378)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2416)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2428)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2506)
	at dotty.tools.dotc.typer.FrontEnd.typeCheck$$anonfun$1(FrontEnd.scala:75)
	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.typer.FrontEnd.monitor(FrontEnd.scala:41)
	at dotty.tools.dotc.typer.FrontEnd.typeCheck(FrontEnd.scala:79)
	at dotty.tools.dotc.typer.FrontEnd.runOn$$anonfun$3(FrontEnd.scala:109)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:392)
	at dotty.tools.dotc.typer.FrontEnd.runOn(FrontEnd.scala:109)
	at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:158)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:36)
	at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:33)
	at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:198)
	at dotty.tools.dotc.Run.runPhases$5(Run.scala:170)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:178)
	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:102)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:185)
	at dotty.tools.dotc.Run.compileSources(Run.scala:120)
	at dotty.tools.dotc.Run.compile(Run.scala:104)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:34)
	at dotty.tools.dotc.Driver.process(Driver.scala:172)
	at dotty.tools.dotc.Driver.process(Driver.scala:141)
	at dotty.tools.dotc.Driver.process(Driver.scala:153)
	at dotty.tools.dotc.Driver.main(Driver.scala:180)
	at dotty.tools.dotc.Main.main(Main.scala)

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