Skip to content

REPL will crash when expression SAM converting to abstract class type #5733

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
Glavo opened this issue Jan 17, 2019 · 4 comments
Closed

REPL will crash when expression SAM converting to abstract class type #5733

Glavo opened this issue Jan 17, 2019 · 4 comments

Comments

@Glavo
Copy link
Contributor

Glavo commented Jan 17, 2019

scala> abstract class F {
     |   def f(arg: Any): Unit
     | }
// defined class F

scala> val f: F = println
Exception in thread "main" java.lang.AssertionError: assertion failed: private method $anonfun in rs$line$2 accessed from method f in null
	at dotty.DottyPredef$.assertFail(DottyPredef.scala:38)
	at dotty.tools.dotc.transform.ExpandPrivate.ensurePrivateAccessible(ExpandPrivate.scala:86)
	at dotty.tools.dotc.transform.ExpandPrivate.transformSelect(ExpandPrivate.scala:99)
	at dotty.tools.dotc.transform.ExpandPrivate.transformSelect(ExpandPrivate.scala:98)
	at dotty.tools.dotc.transform.MegaPhase.goSelect(MegaPhase.scala:562)
	at dotty.tools.dotc.transform.MegaPhase.transformNamed$1(MegaPhase.scala:229)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:391)
	at dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:270)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:392)
	at dotty.tools.dotc.transform.MegaPhase.mapDefDef$1(MegaPhase.scala:245)
	at dotty.tools.dotc.transform.MegaPhase.transformNamed$1(MegaPhase.scala:248)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:391)
	at dotty.tools.dotc.transform.MegaPhase.transformStat$2(MegaPhase.scala:400)
	at dotty.tools.dotc.transform.MegaPhase.$anonfun$1(MegaPhase.scala:405)
	at scala.collection.immutable.List.mapConserve(List.scala:179)
	at dotty.tools.dotc.transform.MegaPhase.transformStats(MegaPhase.scala:405)
	at dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:339)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:392)
	at dotty.tools.dotc.transform.MegaPhase.transformNamed$1(MegaPhase.scala:251)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:391)
	at dotty.tools.dotc.transform.MegaPhase.transformStat$2(MegaPhase.scala:400)
	at dotty.tools.dotc.transform.MegaPhase.$anonfun$1(MegaPhase.scala:405)
	at scala.collection.immutable.List.mapConserve(List.scala:179)
	at dotty.tools.dotc.transform.MegaPhase.transformStats(MegaPhase.scala:405)
	at dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:339)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:392)
	at dotty.tools.dotc.transform.MegaPhase.transformNamed$1(MegaPhase.scala:251)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:391)
	at dotty.tools.dotc.transform.MegaPhase.transformStat$2(MegaPhase.scala:400)
	at dotty.tools.dotc.transform.MegaPhase.$anonfun$1(MegaPhase.scala:405)
	at scala.collection.immutable.List.mapConserve(List.scala:179)
	at dotty.tools.dotc.transform.MegaPhase.transformStats(MegaPhase.scala:405)
	at dotty.tools.dotc.transform.MegaPhase.mapPackage$1(MegaPhase.scala:356)
	at dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:359)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:392)
	at dotty.tools.dotc.transform.MegaPhase.transformUnit(MegaPhase.scala:411)
	at dotty.tools.dotc.transform.MegaPhase.run(MegaPhase.scala:423)
	at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:297)
	at scala.collection.immutable.List.map(List.scala:286)
	at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:299)
	at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:172)
	at scala.compat.java8.JProcedure1.apply(JProcedure1.java:18)
	at scala.compat.java8.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:184)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:192)
	at scala.compat.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:90)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:199)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:139)
	at dotty.tools.repl.ReplCompiler.runCompilationUnit(ReplCompiler.scala:151)
	at dotty.tools.repl.ReplCompiler.compile(ReplCompiler.scala:160)
	at dotty.tools.repl.ReplDriver.compile(ReplDriver.scala:213)
	at dotty.tools.repl.ReplDriver.interpret(ReplDriver.scala:182)
	at dotty.tools.repl.ReplDriver.loop$1(ReplDriver.scala:127)
	at dotty.tools.repl.ReplDriver.runUntilQuit$$anonfun$1(ReplDriver.scala:130)
	at dotty.tools.repl.ReplDriver.withRedirectedOutput$$anonfun$2$$anonfun$1(ReplDriver.scala:143)
	at scala.util.DynamicVariable.withValue(DynamicVariable.scala:62)
	at scala.Console$.withErr(Console.scala:196)
	at dotty.tools.repl.ReplDriver.withRedirectedOutput$$anonfun$1(ReplDriver.scala:143)
	at scala.util.DynamicVariable.withValue(DynamicVariable.scala:62)
	at scala.Console$.withOut(Console.scala:167)
	at dotty.tools.repl.ReplDriver.withRedirectedOutput(ReplDriver.scala:143)
	at dotty.tools.repl.ReplDriver.runUntilQuit(ReplDriver.scala:130)
	at dotty.tools.repl.Main$.main(Main.scala:6)
	at dotty.tools.repl.Main.main(Main.scala)

Crash only occurs when working in REPL.

@allanrenucci
Copy link
Contributor

A new occurence of #4051

@nicolasstucki
Copy link
Contributor

nicolasstucki commented Jan 17, 2019

#5713 seems to fix this (probably with c606153 and 446f1c3)

@nicolasstucki
Copy link
Contributor

On that PR it prints

scala> abstract class F { def f(arg: Any): Unit }
// defined class F
scala> val f: F = println
1 | val f: F = println
  |            ^^^^^^^
  |method println is eta-expanded even though F does not have the @FunctionalInterface annotation.
val f: F = anon$1@459f0e10

Currently cannot easely add it as a test because of the @459f0e10.

@smarter
Copy link
Member

smarter commented Jan 28, 2019

Already fixed, regression test in #5800.

@smarter smarter closed this as completed Jan 28, 2019
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

4 participants