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

Making objects for existing java classes crashes the compiler #7738

Open
hobwekiva opened this issue Dec 13, 2019 · 3 comments
Open

Making objects for existing java classes crashes the compiler #7738

hobwekiva opened this issue Dec 13, 2019 · 3 comments

Comments

@hobwekiva
Copy link

minimized code

package java
package lang
object String
Stack trace
dotty.tools.dotc.core.Denotations$StaleSymbol: stale symbol; class String#1417 in module class lang, defined in Period(1..2, run = 1), is referred to in run Period(1..1, run = 2) while compiling testing/Test.scala
Exception in thread "main" dotty.tools.dotc.core.Denotations$StaleSymbol: stale symbol; class String#1417 in module class lang, defined in Period(1..2, run = 1), is referred to in run Period(1..1, run = 2)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.staleSymbolError(Denotations.scala:1060)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.bringForward(Denotations.scala:870)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.current(Denotations.scala:918)
	at dotty.tools.dotc.core.Symbols$Symbol.recomputeDenot(Symbols.scala:486)
	at dotty.tools.dotc.core.Symbols$Symbol.computeDenot(Symbols.scala:481)
	at dotty.tools.dotc.core.Symbols$Symbol.denot(Symbols.scala:475)
	at dotty.tools.dotc.core.Symbols$ClassSymbol.classDenot(Symbols.scala:810)
	at dotty.tools.dotc.core.Symbols$.toClassDenot(Symbols.scala:850)
	at dotty.tools.dotc.core.Definitions.StringModule(Definitions.scala:509)
	at dotty.tools.dotc.core.Definitions.String_valueOf_Object(Definitions.scala:511)
	at dotty.tools.backend.jvm.DottyBackendInterface.<init>(DottyBackendInterface.scala:148)
	at dotty.tools.backend.jvm.GenBCode.run(GenBCode.scala:51)
	at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:315)
	at scala.collection.immutable.List.map(List.scala:219)
	at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:316)
	at dotty.tools.backend.jvm.GenBCode.runOn(GenBCode.scala:55)
	at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:161)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
	at dotty.tools.dotc.Run.runPhases$5(Run.scala:171)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:179)
	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:65)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:186)
	at dotty.tools.dotc.Run.compileSources(Run.scala:123)
	at dotty.tools.dotc.Run.compile(Run.scala:106)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:36)
	at dotty.tools.dotc.Driver.process(Driver.scala:189)
	at dotty.tools.dotc.Driver.process(Driver.scala:158)
	at dotty.tools.dotc.Driver.process(Driver.scala:170)
	at dotty.tools.dotc.Driver.main(Driver.scala:197)
	at dotty.tools.dotc.Main.main(Main.scala)
package java
package lang
object Integer
Stack trace
Error while emitting Test.scala
exception occurred while compiling testing/Test.scala
java.lang.AssertionError: assertion failed: Bad superClass for class Integer: val <none> while compiling testing/Test.scala
Exception in thread "main" java.lang.AssertionError: assertion failed: Bad superClass for class Integer: val <none>
	at dotty.DottyPredef$.assertFail(DottyPredef.scala:17)
	at dotty.tools.backend.jvm.BTypesFromSymbols.setClassInfo(BTypesFromSymbols.scala:66)
	at dotty.tools.backend.jvm.BTypesFromSymbols.classBTypeFromSymbol$$anonfun$4(BTypesFromSymbols.scala:60)
	at scala.collection.mutable.HashMap.getOrElse(HashMap.scala:416)
	at dotty.tools.backend.jvm.BTypesFromSymbols.classBTypeFromSymbol(BTypesFromSymbols.scala:61)
	at dotty.tools.backend.jvm.CoreBTypes.BOXED_INT(CoreBTypes.scala:59)
	at dotty.tools.backend.jvm.CoreBTypes.boxedClassOfPrimitive(CoreBTypes.scala:74)
	at dotty.tools.backend.jvm.CoreBTypes.boxedClasses(CoreBTypes.scala:80)
	at dotty.tools.backend.jvm.CoreBTypesProxy.boxedClasses(CoreBTypes.scala:223)
	at dotty.tools.backend.jvm.BTypes$BType.isBoxed(BTypes.scala:93)
	at dotty.tools.backend.jvm.BTypes$ClassBType.isBoxed(BTypes.scala:579)
	at dotty.tools.backend.jvm.BTypes$BType.conformsTo(BTypes.scala:121)
	at dotty.tools.backend.jvm.BTypes$ClassBType.conformsTo(BTypes.scala:579)
	at dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.adapt(BCodeBodyBuilder.scala:931)
	at dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoad(BCodeBodyBuilder.scala:437)
	at dotty.tools.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.emitNormalMethodBody$1(BCodeSkelBuilder.scala:597)
	at dotty.tools.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.genDefDef(BCodeSkelBuilder.scala:630)
	at dotty.tools.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.gen(BCodeSkelBuilder.scala:501)
	at dotty.tools.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.gen$$anonfun$1(BCodeSkelBuilder.scala:503)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:305)
	at dotty.tools.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.gen(BCodeSkelBuilder.scala:503)
	at dotty.tools.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.genPlainClass(BCodeSkelBuilder.scala:109)
	at dotty.tools.backend.jvm.GenBCodePipeline$Worker1.visit(GenBCode.scala:217)
	at dotty.tools.backend.jvm.GenBCodePipeline$Worker1.run(GenBCode.scala:184)
	at dotty.tools.backend.jvm.GenBCodePipeline.buildAndSendToDisk(GenBCode.scala:514)
	at dotty.tools.backend.jvm.GenBCodePipeline.run(GenBCode.scala:480)
	at dotty.tools.backend.jvm.GenBCode.run(GenBCode.scala:51)
	at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:315)
	at scala.collection.immutable.List.map(List.scala:219)
	at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:316)
	at dotty.tools.backend.jvm.GenBCode.runOn(GenBCode.scala:55)
	at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:161)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
	at dotty.tools.dotc.Run.runPhases$5(Run.scala:171)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:179)
	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:65)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:186)
	at dotty.tools.dotc.Run.compileSources(Run.scala:123)
	at dotty.tools.dotc.Run.compile(Run.scala:106)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:36)
	at dotty.tools.dotc.Driver.process(Driver.scala:189)
	at dotty.tools.dotc.Driver.process(Driver.scala:158)
	at dotty.tools.dotc.Driver.process(Driver.scala:170)
	at dotty.tools.dotc.Driver.main(Driver.scala:197)
	at dotty.tools.dotc.Main.main(Main.scala)
@odersky
Copy link
Contributor

odersky commented Dec 15, 2019

Not sure we should even try to fix this

@sjrd
Copy link
Member

sjrd commented Dec 15, 2019

Supporting this will be necessary to be able to compile the JDK implementations of Scala.js and Native with Dotty.

@griggt
Copy link
Collaborator

griggt commented Oct 19, 2020

The String example compiles since f8dbf7c in #9099.

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