Skip to content

Crash: Inlining private definition from companion object #4754

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
allanrenucci opened this issue Jul 2, 2018 · 1 comment
Closed

Crash: Inlining private definition from companion object #4754

allanrenucci opened this issue Jul 2, 2018 · 1 comment

Comments

@allanrenucci
Copy link
Contributor

object Foo {
  private final val C = 1
}

class Foo {
  import Foo._
  inline def foo(x: Int): Boolean = x == C
}

This code snippet crashes the compiler

dotc -d out tests/allan/Foo.scala
exception occurred while compiling Foo.scala
Exception in thread "main" java.lang.AssertionError: assertion failed: unresolved symbols: method inline$C in object Foo when pickling Foo.scala
	at scala.Predef$.assert(Predef.scala:219)
	at dotty.tools.dotc.core.tasty.TreePickler.pickle(TreePickler.scala:642)
	at dotty.tools.dotc.transform.Pickler.$anonfun$run$3(Pickler.scala:56)
	at dotty.tools.dotc.transform.Pickler.$anonfun$run$3$adapted(Pickler.scala:49)
	at scala.collection.immutable.List.foreach(List.scala:389)
	at dotty.tools.dotc.transform.Pickler.$anonfun$run$2(Pickler.scala:49)
	at dotty.tools.dotc.transform.Pickler.$anonfun$run$2$adapted(Pickler.scala:48)
	at scala.collection.immutable.List.foreach(List.scala:389)
	at dotty.tools.dotc.transform.Pickler.run(Pickler.scala:48)
	at dotty.tools.dotc.core.Phases$Phase.$anonfun$runOn$1(Phases.scala:298)
	at scala.collection.immutable.List.map(List.scala:283)
	at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:296)
	at dotty.tools.dotc.core.Phases$Phase.runOn$(Phases.scala:295)
	at dotty.tools.dotc.transform.Pickler.runOn(Pickler.scala:83)
	at dotty.tools.dotc.Run.$anonfun$compileUnits$3(Run.scala:174)
...
@allanrenucci
Copy link
Contributor Author

allanrenucci commented Jul 5, 2018

Actually, this is not specific to constants. The following code snippet crashes too:

object Foo {
  private def C: String = "NotConstant"
}

class Foo {
  import Foo._
  inline def foo2 = C
}

@allanrenucci allanrenucci changed the title Inlining + Constant Crash: Inlining private definition from companion object Jul 5, 2018
@odersky odersky closed this as completed in 17a0429 Jul 6, 2018
odersky added a commit that referenced this issue Jul 6, 2018
Fix #4754: Don't generate inline accessor for constants
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

2 participants