scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
232 stars 21 forks source link

Objects in structural types explodes compiler #1030

Closed scabug closed 13 years ago

scabug commented 16 years ago
scala> val y = new AnyRef { object Foo { val x = 3 } }
Exception in thread "main" java.lang.AssertionError: assertion failed
    at scala.Predef$$.assert(Predef.scala:87)
    at scala.tools.nsc.symtab.Types$$adaptToNewRunMap$$.adaptToNewRun(Types.scala:3087)
    at scala.tools.nsc.symtab.Types$$adaptToNewRunMap$$.adaptToNewRun(Types.scala:3067)
    at scala.tools.nsc.symtab.Types$$adaptToNewRunMap$$.apply(Types.scala:3116)
    at scala.tools.nsc.symtab.Symbols$$Symbol.adaptToNewRun$$1(Symbols.scala:590)
    at scala.tools.nsc.symtab.Symbols$$Symbol.adaptInfos(Symbols.scala:594)
    at scala.tools.nsc.symtab.Symbols$$Symbol.rawInfo(Symbols.scala:553)
    at scala.tools.nsc.symtab.Symbols$$Symbol.info(Symbols.scala:504)
    at scala.tools.nsc.symtab.Types$$TypeMap$$$$anonfun$$12.apply(Types.scala:2362)
    at scala.tools.nsc.symtab.Types$$TypeMap$$$$anonfun$$12.apply(Types.scala:2359)
    at scala.List.map(List.scala:798)
    at scala.tools.nsc.symtab.Types$$TypeMap.mapOver(Types.scala:2359)
    at scala.tools.nsc.symtab.Types$$TypeMap.mapOver(Types.scala:2351)
    at scala.tools.nsc.symtab.Types$$TypeMap.mapOver(Types.scala:2281)
    at scala.tools.nsc.symtab.Types$$AsSeenFromMap.apply(Types.scala:2661)
    at scala.tools.nsc.symtab.Types$$AsSeenFromMap.apply(Types.scala:2528)
    at scala.tools.nsc.symtab.Types$$TypeMap.mapOver(Types.scala:2303)
    at scala.tools.nsc.symtab.Types$$AsSeenFromMap.apply(Types.scala:2661)
    at scala.tools.nsc.symtab.Types$$Type.asSeenFrom(Types.scala:394)
    at scala.tools.nsc.symtab.Types$$Type.memberType(Types.scala:425)
    at scala.tools.nsc.typechecker.Infer$$Inferencer.checkAccessible(Infer.scala:366)
    at scala.tools.nsc.typechecker.Typers$$Typer.typedSelect$$1(Typers.scala:2715)
    at scala.tools.nsc.typechecker.Typers$$Typer.typed1(Typers.scala:3147)
    at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3228)
    at scala.tools.nsc.typechecker.Typers$$Typer.typedQualifier(Typers.scala:3285)
    at scala.tools.nsc.typechecker.Typers$$Typer.typed1(Typers.scala:3145)
    at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3228)
    at scala.tools.nsc.typechecker.Typers$$Typer.typed1(Typers.scala:3095)
    at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3228)
    at scala.tools.nsc.typechecker.Typers$$Typer.typedQualifier(Typers.scala:3285)
    at scala.tools.nsc.typechecker.Typers$$Typer.typed1(Typers.scala:3145)
    at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3228)
    at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$typedApply$$1$$1.apply(Typers.scala:2526)
    at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$typedApply$$1$$1.apply(Typers.scala:2526)
    at scala.tools.nsc.typechecker.Typers$$Typer.silent(Typers.scala:570)
    at scala.tools.nsc.typechecker.Typers$$Typer.typedApply$$1(Typers.scala:2526)
    at scala.tools.nsc.typechecker.Typers$$Typer.typed1(Typers.scala:3125)
    at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3228)
    at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3276)
    at scala.tools.nsc.typechecker.Typers$$Typer.typedIf$$1(Typers.scala:2325)
    at scala.tools.nsc.typechecker.Typers$$Typer.typed1(Typers.scala:3028)
    at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3228)
    at scala.tools.nsc.typechecker.Typers$$Typer.typedArg(Typers.scala:1591)
    at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$typedArgs$$2.apply(Typers.scala:1607)
    at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$typedArgs$$2.apply(Typers.scala:1607)
    at scala.List$$.map2(List.scala:326)
    at scala.tools.nsc.typechecker.Typers$$Typer.typedArgs(Typers.scala:1607)
    at scala.tools.nsc.typechecker.Typers$$Typer.doTypedApply(Typers.scala:1691)
    at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$tryTypedApply$$1$$1.apply(Typers.scala:2485)
    at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$tryTypedApply$$1$$1.apply(Typers.scala:2485)
    at scala.tools.nsc.typechecker.Typers$$Typer.silent(Typers.scala:565)
    at scala.tools.nsc.typechecker.Typers$$Typer.tryTypedApply$$1(Typers.scala:2485)
    at scala.tools.nsc.typechecker.Typers$$Typer.typedApply$$1(Typers.scala:2536)
    at scala.tools.nsc.typechecker.Typers$$Typer.typed1(Typers.scala:3125)
    at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3228)
    at scala.tools.nsc.typechecker.Typers$$Typer.typedBlock(Typers.scala:1378)
    at scala.tools.nsc.typechecker.Typers$$Typer.typed1(Typers.scala:2990)
    at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3228)
    at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3276)
    at scala.tools.nsc.typechecker.Typers$$Typer.transformedOrTyped(Typers.scala:3325)
    at scala.tools.nsc.typechecker.Typers$$Typer.typedValDef(Typers.scala:1199)
    at scala.tools.nsc.typechecker.Typers$$Typer.typed1(Typers.scala:2963)
    at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3228)
    at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3265)
    at scala.tools.nsc.typechecker.Typers$$Typer.typedStat$$1(Typers.scala:1540)
    at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$19.apply(Typers.scala:1585)
    at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$19.apply(Typers.scala:1585)
    at scala.List$$.loop$$1(List.scala:293)
    at scala.List$$.mapConserve(List.scala:310)
    at scala.tools.nsc.typechecker.Typers$$Typer.typedStats(Typers.scala:1585)
    at scala.tools.nsc.typechecker.Typers$$Typer.typedTemplate(Typers.scala:1165)
    at scala.tools.nsc.typechecker.Typers$$Typer.typedModuleDef(Typers.scala:1063)
    at scala.tools.nsc.typechecker.Typers$$Typer.typed1(Typers.scala:2960)
    at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3228)
    at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3265)
    at scala.tools.nsc.typechecker.Typers$$Typer.typedStat$$1(Typers.scala:1540)
    at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$19.apply(Typers.scala:1585)
    at scala.tools.nsc.typechecker.Typers$$Typer$$$$anonfun$$19.apply(Typers.scala:1585)
    at scala.List$$.loop$$1(List.scala:293)
    at scala.List$$.mapConserve(List.scala:310)
    at scala.tools.nsc.typechecker.Typers$$Typer.typedStats(Typers.scala:1585)
    at scala.tools.nsc.typechecker.Typers$$Typer.typed1(Typers.scala:2953)
    at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3228)
    at scala.tools.nsc.typechecker.Typers$$Typer.typed(Typers.scala:3265)
    at scala.tools.nsc.typechecker.Analyzer$$typerFactory$$$$anon$$2.apply(Analyzer.scala:40)
    at scala.tools.nsc.Global$$GlobalPhase.applyPhase(Global.scala:257)
    at scala.tools.nsc.Global$$GlobalPhase$$$$anonfun$$run$$1.apply(Global.scala:243)
    at scala.tools.nsc.Global$$GlobalPhase$$$$anonfun$$run$$1.apply(Global.scala:243)
    at scala.Iterator$$class.foreach(Iterator.scala:395)
    at scala.collection.mutable.ListBuffer$$$$anon$$1.foreach(ListBuffer.scala:266)
    at scala.tools.nsc.Global$$GlobalPhase.run(Global.scala:243)
    at scala.tools.nsc.Global$$Run.compileSources(Global.scala:555)
    at scala.tools.nsc.Interpreter$$Request.compile(Interpreter.scala:833)
    at scala.tools.nsc.Interpreter.interpret(Interpreter.scala:495)
    at scala.tools.nsc.InterpreterLoop.interpretStartingWith(InterpreterLoop.scala:248)
    at scala.tools.nsc.InterpreterLoop.command(InterpreterLoop.scala:236)
    at scala.tools.nsc.InterpreterLoop.repl(InterpreterLoop.scala:148)
    at scala.tools.nsc.InterpreterLoop.main(InterpreterLoop.scala:306)
    at scala.tools.nsc.MainGenericRunner$$.main(MainGenericRunner.scala:147)
    at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
scabug commented 16 years ago

Imported From: https://issues.scala-lang.org/browse/SI-1030?orig=1 Reporter: Geoffrey Alan Washburn (washburn)

scabug commented 16 years ago

Michael Pradel (pradel) said: I cannot reproduce it with scalac (only in the interpreter). Putting it in an object or a class works fine.

scabug commented 16 years ago

Geoffrey Alan Washburn (washburn) said: Interesting. I tried some additional variations, and I can in fact browse the tree at the refchecks stage if I use the compiler. Looking closer at the stack trace, the fact that this occurs in adaptToNewRunMap does seem like this is more of an issue related to the interpreter or fsc. However, I still think that my proposal to erase objects to be vals in structural types is the correct overall direction.

scabug commented 16 years ago

@odersky said: fixed in r15613