Skip to content

Compiler crash during explicitOuter #5083

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
liufengyun opened this issue Sep 5, 2018 · 1 comment · Fixed by #5108
Closed

Compiler crash during explicitOuter #5083

liufengyun opened this issue Sep 5, 2018 · 1 comment · Fixed by #5108

Comments

@liufengyun
Copy link
Contributor

The following code crashes Dotty:

class A(a: Int) {
  class X {
    val x = a
  }

  trait Y {
    val y = a
  }

  trait Z(val o: A) extends o.Y {
    val z = a
  }

  class B extends X with Z(new A(4))
}
error message
Exception in thread "main" java.lang.AssertionError: assertion failed: failure to construct path from method A$Y$$$outer/class B/class A/package /package  to `this` of trait Z in class A;
class A does not have an outer accessor
	at dotty.DottyPredef$.assertFail(DottyPredef.scala:36)
	at dotty.tools.dotc.transform.ExplicitOuter$OuterOps$.loop$1(ExplicitOuter.scala:388)
	at dotty.tools.dotc.transform.ExplicitOuter$OuterOps$.path$extension(ExplicitOuter.scala:394)
	at dotty.tools.dotc.transform.LambdaLift$Lifter.memberRef(LambdaLift.scala:400)
	at dotty.tools.dotc.transform.LambdaLift.transformIdent(LambdaLift.scala:519)
	at dotty.tools.dotc.transform.MegaPhase.goIdent(MegaPhase.scala:518)
	at dotty.tools.dotc.transform.MegaPhase.transformNamed$1(MegaPhase.scala:210)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:366)
	at dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:250)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:367)
	at dotty.tools.dotc.transform.MegaPhase.mapDefDef$1(MegaPhase.scala:230)
	at dotty.tools.dotc.transform.MegaPhase.transformNamed$1(MegaPhase.scala:233)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:366)
	at dotty.tools.dotc.transform.MegaPhase.transformStat$2(MegaPhase.scala:375)
	at dotty.tools.dotc.transform.MegaPhase.$anonfun$1(MegaPhase.scala:380)
	at scala.collection.immutable.List.mapConserve(List.scala:176)
	at dotty.tools.dotc.transform.MegaPhase.transformStats(MegaPhase.scala:380)
	at dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:319)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:367)
	at dotty.tools.dotc.transform.MegaPhase.transformNamed$1(MegaPhase.scala:236)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:366)
	at dotty.tools.dotc.transform.MegaPhase.transformStat$2(MegaPhase.scala:375)
	at dotty.tools.dotc.transform.MegaPhase.$anonfun$1(MegaPhase.scala:380)
	at scala.collection.immutable.List.mapConserve(List.scala:176)
	at dotty.tools.dotc.transform.MegaPhase.transformStats(MegaPhase.scala:380)
	at dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:319)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:367)
	at dotty.tools.dotc.transform.MegaPhase.transformNamed$1(MegaPhase.scala:236)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:366)
	at dotty.tools.dotc.transform.MegaPhase.transformStat$2(MegaPhase.scala:375)
	at dotty.tools.dotc.transform.MegaPhase.$anonfun$1(MegaPhase.scala:380)
	at scala.collection.immutable.List.mapConserve(List.scala:176)
	at dotty.tools.dotc.transform.MegaPhase.transformStats(MegaPhase.scala:380)
	at dotty.tools.dotc.transform.MegaPhase.mapPackage$1(MegaPhase.scala:336)
	at dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:339)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:367)
	at dotty.tools.dotc.transform.MegaPhase.transformUnit(MegaPhase.scala:386)
	at dotty.tools.dotc.transform.MegaPhase.run(MegaPhase.scala:398)
	at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:295)
	at scala.collection.immutable.List.map(List.scala:283)
	at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:297)
	at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:171)
	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:32)
	at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:29)
	at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:191)
	at dotty.tools.dotc.Run.runPhases$5(Run.scala:186)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:194)
	at scala.compat.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:88)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:201)
	at dotty.tools.dotc.Run.compileSources(Run.scala:136)
	at dotty.tools.dotc.Run.compile(Run.scala:120)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:29)
	at dotty.tools.dotc.Driver.process(Driver.scala:127)
	at dotty.tools.dotc.Driver.process(Driver.scala:96)
	at dotty.tools.dotc.Driver.process(Driver.scala:108)
	at dotty.tools.dotc.Driver.main(Driver.scala:135)
	at dotty.tools.dotc.Main.main(Main.scala)
odersky added a commit to dotty-staging/dotty that referenced this issue Sep 12, 2018
i5083 provides an example where a field reference had NoPrefix as a parameter, which made
it fail for producing an outer path. It's not quite clear where this came from. The fix
addresses it
@liufengyun liufengyun self-assigned this Sep 13, 2018
@liufengyun
Copy link
Contributor Author

As discussed in #5099, we should disallow usage of trait parameters as outers for parent classes.

liufengyun added a commit to dotty-staging/dotty that referenced this issue Sep 14, 2018
…ents

The rationale is to ensure outer-related NPE never happen in Scala.
Otherwise, outer NPE may happen, see tests/neg/i5083.scala
liufengyun added a commit that referenced this issue Sep 19, 2018
 Fix #5083: Disallow using trait parameters as prefix for its parents
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant