Skip to content

Missing symbol for inlined contextual closure #6862

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

Closed
nicolasstucki opened this issue Jul 16, 2019 · 1 comment
Closed

Missing symbol for inlined contextual closure #6862

nicolasstucki opened this issue Jul 16, 2019 · 1 comment

Comments

@nicolasstucki
Copy link
Contributor

nicolasstucki commented Jul 16, 2019

Minimized code

lib.scala

trait Ctx
inline def foo(): Unit = given (x: Ctx) => ()
def bar[T](b: given Ctx => Unit): Unit = ???

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
[success] Total time: 3 s, completed Jul 16, 2019 5:10:35 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 while compiling app.scala
Exception in thread "main" java.lang.AssertionError: assertion failed
	at dotty.DottyPredef$.assertFail(DottyPredef.scala:15)
	at dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:1507)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2311)
	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.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.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.Typer.typedFunctionValue(Typer.scala:979)
	at dotty.tools.dotc.typer.Typer.typedFunction(Typer.scala:801)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2333)
	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.Typer.makeContextualFunction(Typer.scala:2404)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2375)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:124)
	at dotty.tools.dotc.typer.ProtoTypes$FunProto.$anonfun$3(ProtoTypes.scala:326)
	at dotty.tools.dotc.typer.ProtoTypes$FunProto.cacheTypedArg(ProtoTypes.scala:289)
	at dotty.tools.dotc.typer.ProtoTypes$FunProto.typedArg(ProtoTypes.scala:326)
	at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:767)
	at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:767)
	at dotty.tools.dotc.typer.Applications$Application.addTyped$1(Applications.scala:531)
	at dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:576)
	at dotty.tools.dotc.typer.Applications$Application.init(Applications.scala:352)
	at dotty.tools.dotc.typer.Applications$TypedApply.<init>(Applications.scala:668)
	at dotty.tools.dotc.typer.Applications$ApplyToUntyped.<init>(Applications.scala:766)
	at dotty.tools.dotc.typer.Applications.simpleApply$1(Applications.scala:839)
	at dotty.tools.dotc.typer.Applications.realApply$4$$anonfun$3(Applications.scala:868)
	at dotty.tools.dotc.typer.Typer.tryEither(Typer.scala:2514)
	at dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:879)
	at dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:914)
	at dotty.tools.dotc.typer.Inliner$InlineTyper.typedApply(Inliner.scala:1037)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2324)
	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)

@nicolasstucki
Copy link
Contributor Author

Similar issue with

trait Expr[+T]
trait Ctx
inline def foo(): Int = splice( bar() )
def bar() given Ctx: Expr[Int] = ???
def splice[T](f: given Ctx => Expr[T]): T = ???

nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 18, 2019
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 18, 2019
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 22, 2019
odersky added a commit that referenced this issue Jul 22, 2019
…closures-while-inlining

Fix #6862, fix #6863: Do not adapt contextual closures while inlining
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant