Skip to content

Assertion when recompiling package object containing trait with companion object #4052

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
scabug opened this issue Dec 2, 2010 · 8 comments

Comments

@scabug
Copy link

scabug commented Dec 2, 2010

What steps will reproduce the problem?

package object test {
	trait PackageError {
	}
	 
	object PackageError {
	}
}

What is the expected behavior?
No compiler error, or error messages explaining restrictions on package object.

What do you see instead?

Exception in thread "main" java.lang.AssertionError: assertion failed: List(object package$$PackageError, object package$$
PackageError)
        at scala.tools.nsc.symtab.Symbols$$Symbol.suchThat(Symbols.scala:1056)
        at scala.tools.nsc.symtab.Symbols$$Symbol.companionModule0(Symbols.scala:1271)
        at scala.tools.nsc.symtab.Symbols$$Symbol.companionModule(Symbols.scala:1281)
        at scala.tools.nsc.backend.jvm.GenJVM$$BytecodeGenerator.javaName(GenJVM.scala:1753)
        at scala.tools.nsc.backend.jvm.GenJVM$$BytecodeGenerator.genClass(GenJVM.scala:189)
        at scala.tools.nsc.backend.jvm.GenJVM$$JvmPhase.apply(GenJVM.scala:56)
        at scala.tools.nsc.backend.jvm.GenJVM$$JvmPhase$$$$anonfun$$run$$3.apply(GenJVM.scala:52)
        at scala.tools.nsc.backend.jvm.GenJVM$$JvmPhase$$$$anonfun$$run$$3.apply(GenJVM.scala:52)
        at scala.collection.mutable.HashMap$$$$anon$$2$$$$anonfun$$foreach$$3.apply(HashMap.scala:89)
        at scala.collection.mutable.HashMap$$$$anon$$2$$$$anonfun$$foreach$$3.apply(HashMap.scala:89)
        at scala.collection.Iterator$$class.foreach(Iterator.scala:631)
        at scala.collection.mutable.HashTable$$$$anon$$1.foreach(HashTable.scala:161)
        at scala.collection.mutable.HashTable$$class.foreachEntry(HashTable.scala:194)
        at scala.collection.mutable.HashMap.foreachEntry(HashMap.scala:39)
        at scala.collection.mutable.HashMap$$$$anon$$2.foreach(HashMap.scala:89)
        at scala.tools.nsc.backend.jvm.GenJVM$$JvmPhase.run(GenJVM.scala:52)
        at scala.tools.nsc.Global$$Run.compileSources(Global.scala:741)
        at scala.tools.nsc.Global$$Run.compile(Global.scala:822)
        at scala.tools.nsc.Main$$.process(Main.scala:106)
        at scala.tools.nsc.Main$$.main(Main.scala:120)
        at scala.tools.nsc.Main.main(Main.scala)
}

What versions of the following are you using?
Scala: 2.8.1
Java: 1.6.u22
Operating system: Windows 7

@scabug
Copy link
Author

scabug commented Dec 2, 2010

Imported From: https://issues.scala-lang.org/browse/SI-4052?orig=1
Reporter: Trond Olsen (tolsen)

@scabug
Copy link
Author

scabug commented Dec 2, 2010

Trond Olsen (tolsen) said:
Note: source was stored in file named package.scala

@scabug
Copy link
Author

scabug commented Dec 3, 2010

@hubertp said:
Works for me in 2.8.1 and trunk.

@scabug
Copy link
Author

scabug commented Dec 3, 2010

Trond Olsen (tolsen) said:
Replying to [comment:3 plocinic]:

Works for me in 2.8.1 and trunk.
What setup do you use? Maybe this is Windows related?

@scabug
Copy link
Author

scabug commented Dec 3, 2010

@hubertp said:
Linux. I will add the test to our test-suite and see if it fails overnight on windows but I doubt it.

@scabug
Copy link
Author

scabug commented Dec 7, 2010

@hubertp said:
It didn't fail, so it must have been something with your setup. Feel free to reopen if you provide steps to reproduce.

@scabug
Copy link
Author

scabug commented Dec 10, 2010

gerferra said:
I've been able to reproduce this with the following steps:

german@ssl2:~$$ scalac -version
Scala compiler version 2.8.1.r23076-b20100923023203 -- Copyright 2002-2010, LAMP/EPFL
german@ssl2:~$$ mkdir 4052
german@ssl2:~$$ cd 4052/
german@ssl2:~/4052$$ ls
german@ssl2:~/4052$$ echo 'package object test { trait PE {}; object PE {} }' > package.scala
german@ssl2:~/4052$$ ls
package.scala
german@ssl2:~/4052$$ scalac package.scala 
german@ssl2:~/4052$$ ls *
package.scala

test:
package.class  package$$.class  package$$PE.class  package$$PE$$.class
german@ssl2:~/4052$$ scalac package.scala 
Exception in thread "main" java.lang.AssertionError: assertion failed: List(object package$$PE, object package$$PE)
	at scala.tools.nsc.symtab.Symbols$$Symbol.suchThat(Symbols.scala:1054)
	at scala.tools.nsc.symtab.Symbols$$Symbol.companionModule0(Symbols.scala:1269)
	at scala.tools.nsc.symtab.Symbols$$Symbol.companionModule(Symbols.scala:1279)
	at scala.tools.nsc.backend.jvm.GenJVM$$BytecodeGenerator.javaName(GenJVM.scala:1753)
	at scala.tools.nsc.backend.jvm.GenJVM$$BytecodeGenerator$$$$anonfun$$addInnerClasses$$3.apply(GenJVM.scala:563)
	at scala.tools.nsc.backend.jvm.GenJVM$$BytecodeGenerator$$$$anonfun$$addInnerClasses$$3.apply(GenJVM.scala:554)
	at scala.collection.LinearSeqOptimized$$class.foreach(LinearSeqOptimized.scala:61)
	at scala.collection.immutable.List.foreach(List.scala:45)
	at scala.tools.nsc.backend.jvm.GenJVM$$BytecodeGenerator.addInnerClasses(GenJVM.scala:554)
	at scala.tools.nsc.backend.jvm.GenJVM$$BytecodeGenerator.emitClass(GenJVM.scala:138)
	at scala.tools.nsc.backend.jvm.GenJVM$$BytecodeGenerator.dumpMirrorClass(GenJVM.scala:926)
	at scala.tools.nsc.backend.jvm.GenJVM$$BytecodeGenerator.genClass(GenJVM.scala:230)
	at scala.tools.nsc.backend.jvm.GenJVM$$JvmPhase.apply(GenJVM.scala:56)
	at scala.tools.nsc.backend.jvm.GenJVM$$JvmPhase$$$$anonfun$$run$$3.apply(GenJVM.scala:52)
	at scala.tools.nsc.backend.jvm.GenJVM$$JvmPhase$$$$anonfun$$run$$3.apply(GenJVM.scala:52)
	at scala.collection.mutable.HashMap$$$$anon$$2$$$$anonfun$$foreach$$3.apply(HashMap.scala:89)
	at scala.collection.mutable.HashMap$$$$anon$$2$$$$anonfun$$foreach$$3.apply(HashMap.scala:89)
	at scala.collection.Iterator$$class.foreach(Iterator.scala:631)
	at scala.collection.mutable.HashTable$$$$anon$$1.foreach(HashTable.scala:161)
	at scala.collection.mutable.HashTable$$class.foreachEntry(HashTable.scala:194)
	at scala.collection.mutable.HashMap.foreachEntry(HashMap.scala:39)
	at scala.collection.mutable.HashMap$$$$anon$$2.foreach(HashMap.scala:89)
	at scala.tools.nsc.backend.jvm.GenJVM$$JvmPhase.run(GenJVM.scala:52)
	at scala.tools.nsc.Global$$Run.compileSources(Global.scala:741)
	at scala.tools.nsc.Global$$Run.compile(Global.scala:822)
	at scala.tools.nsc.Main$$.process(Main.scala:106)
	at scala.tools.nsc.Main$$.main(Main.scala:120)
	at scala.tools.nsc.Main.main(Main.scala)

So, apparently only occurs when the folder already exists.

@scabug
Copy link
Author

scabug commented Dec 10, 2010

@paulp said:
Sorry for the trouble, I didn't see this the first time around. It's a duplicate of #3437.

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

1 participant