Skip to content
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

Compiler crashes when class is set to private of non-enclosing scope #7388

Closed
scabug opened this issue Apr 18, 2013 · 2 comments
Closed

Compiler crashes when class is set to private of non-enclosing scope #7388

scabug opened this issue Apr 18, 2013 · 2 comments

Comments

@scabug
Copy link

scabug commented Apr 18, 2013

The following line of code without foo being an enclosing entity leads to a compiler crash, while correctly stating the error in the code.

// Test.scala
class Test private[foo]()
Test.scala:1: error: foo is not an enclosing class
class Test private[foo]()
           ^
error:
     while compiling: Test.scala
        during phase: typer
     library version: version 2.10.1
    compiler version: version 2.10.1
  reconstructed args:

  last tree to typer: term <init>
              symbol: constructor Test in class Test (flags: <method>)
   symbol definition: def <init><_>
       symbol owners: constructor Test -> class Test -> package <empty>
      context owners: class Test -> package <empty>

== Enclosing template or block ==

Template( // val <local Test>: <notype> in class Test
  "java.lang.Object" // parents
  ValDef(
    private
    "_"
    <tpt>
    <empty>
  )
  DefDef( // def <init><_> in class Test
    <method>
    "<init>"
    []
    List(Nil)
    <tpt>
    Block(
      Apply(
        super."<init>"
        Nil
      )
      ()
    )
  )
)

uncaught exception during compilation: java.lang.AssertionError
error: java.lang.AssertionError: assertion failed: <init>
	at scala.reflect.internal.Symbols$Symbol.info(Symbols.scala:1210)
	at scala.reflect.internal.Symbols$Symbol.initialize(Symbols.scala:1365)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5282)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5630)
	at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedStat$1(Typers.scala:2921)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$62.apply(Typers.scala:3025)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$62.apply(Typers.scala:3025)
	at scala.collection.immutable.List.loop$1(List.scala:170)
	at scala.collection.immutable.List.mapConserve(List.scala:186)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3025)
	at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:1914)
	at scala.tools.nsc.typechecker.Typers$Typer.typedClassDef(Typers.scala:1751)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5571)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5630)
	at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedStat$1(Typers.scala:2921)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$62.apply(Typers.scala:3025)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$62.apply(Typers.scala:3025)
	at scala.collection.immutable.List.loop$1(List.scala:170)
	at scala.collection.immutable.List.mapConserve(List.scala:186)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3025)
	at scala.tools.nsc.typechecker.Typers$Typer.typedPackageDef$1(Typers.scala:5288)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5575)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5630)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5687)
	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.apply(Analyzer.scala:99)
	at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:463)
	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3$$anonfun$run$1.apply(Analyzer.scala:91)
	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3$$anonfun$run$1.apply(Analyzer.scala:91)
	at scala.collection.Iterator$class.foreach(Iterator.scala:727)
	at scala.collection.AbstractIterator.foreach(Iterator.scala:1157)
	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.run(Analyzer.scala:91)
	at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1582)
	at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1556)
	at scala.tools.nsc.Global$Run.compileSources(Global.scala:1552)
	at scala.tools.nsc.Global$Run.compile(Global.scala:1661)
	at scala.tools.nsc.Driver.doCompile(Driver.scala:33)
	at scala.tools.nsc.Main$.doCompile(Main.scala:79)
	at scala.tools.nsc.Driver.process(Driver.scala:54)
	at scala.tools.nsc.Driver.main(Driver.scala:67)
	at scala.tools.nsc.Main.main(Main.scala)

Exception in thread "main" java.lang.AssertionError: assertion failed: <init>
	at scala.reflect.internal.Symbols$Symbol.info(Symbols.scala:1210)
	at scala.reflect.internal.Symbols$Symbol.initialize(Symbols.scala:1365)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5282)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5630)
	at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedStat$1(Typers.scala:2921)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$62.apply(Typers.scala:3025)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$62.apply(Typers.scala:3025)
	at scala.collection.immutable.List.loop$1(List.scala:170)
	at scala.collection.immutable.List.mapConserve(List.scala:186)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3025)
	at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:1914)
	at scala.tools.nsc.typechecker.Typers$Typer.typedClassDef(Typers.scala:1751)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5571)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5630)
	at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedStat$1(Typers.scala:2921)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$62.apply(Typers.scala:3025)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$62.apply(Typers.scala:3025)
	at scala.collection.immutable.List.loop$1(List.scala:170)
	at scala.collection.immutable.List.mapConserve(List.scala:186)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3025)
	at scala.tools.nsc.typechecker.Typers$Typer.typedPackageDef$1(Typers.scala:5288)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5575)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5630)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5687)
	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.apply(Analyzer.scala:99)
	at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:463)
	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3$$anonfun$run$1.apply(Analyzer.scala:91)
	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3$$anonfun$run$1.apply(Analyzer.scala:91)
	at scala.collection.Iterator$class.foreach(Iterator.scala:727)
	at scala.collection.AbstractIterator.foreach(Iterator.scala:1157)
	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.run(Analyzer.scala:91)
	at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1582)
	at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1556)
	at scala.tools.nsc.Global$Run.compileSources(Global.scala:1552)
	at scala.tools.nsc.Global$Run.compile(Global.scala:1661)
	at scala.tools.nsc.Driver.doCompile(Driver.scala:33)
	at scala.tools.nsc.Main$.doCompile(Main.scala:79)
	at scala.tools.nsc.Driver.process(Driver.scala:54)
	at scala.tools.nsc.Driver.main(Driver.scala:67)
	at scala.tools.nsc.Main.main(Main.scala)
@scabug
Copy link
Author

scabug commented Apr 18, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7388?orig=1
Reporter: Dario Rexin (evonox)
Affected Versions: 2.10.1

@scabug
Copy link
Author

scabug commented Apr 18, 2013

@retronym said:
scala/scala#2411

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