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
AssertionFailed with implicit class inside package object #7940
Comments
Imported From: https://issues.scala-lang.org/browse/SI-7940?orig=1 |
@retronym said: |
@dragos said: |
@retronym said: /** if there's a `package` member object in `pkgClass`, enter its members into it. */
def openPackageModule(pkgClass: Symbol) {
val pkgModule = pkgClass.info.decl(nme.PACKAGEkw)
def fromSource = pkgModule.rawInfo match {
case ltp: SymLoader => ltp.fromSource
case _ => false
}
if (pkgModule.isModule && !fromSource) {
// println("open "+pkgModule)//DEBUG
openPackageModule(pkgModule, pkgClass)
}
} |
@retronym said (edited on Oct 31, 2013 9:23:02 AM UTC): package p
trait D {
class C1 { override def toString = "D#C1" }
}
object `package` extends D {
class C2 { override def toString = "`package`.C2" }
}
class C1 { override def toString = "C1" }
class C2 { override def toString = "C2" }
object Test {
def main(args: Array[String]) {
println(new p.C1, new p.C2)
}
}
|
@retronym said: // unlink existing symbols in the package
for (member <- container.info.decls.iterator) {
if (!member.isPrivate && !member.isConstructor) {
// todo: handle overlapping definitions in some way: mark as errors
// or treat as abstractions. For now the symbol in the package module takes precedence.
for (existing <- dest.info.decl(member.name).alternatives)
dest.info.decls.unlink(existing)
}
} It only considers the |
@retronym said (edited on Oct 31, 2013 9:38:10 AM UTC): object packageObjects extends {
val global: Analyzer.this.global.type = Analyzer.this.global
} with SubComponent {
val phaseName = "packageobjects"
val runsAfter = List[String]()
val runsRightAfter= Some("namer")
def newPhase(_prev: Phase): StdPhase = new StdPhase(_prev) {
override val checkable = false
import global._
val openPackageObjectsTraverser = new Traverser {
override def traverse(tree: Tree): Unit = tree match {
case ModuleDef(_, _, _) =>
if (tree.symbol.name == nme.PACKAGEkw) {
openPackageModule(tree.symbol, tree.symbol.owner)
}
case ClassDef(_, _, _, _) => () // make it fast
case _ => super.traverse(tree)
}
}
def apply(unit: CompilationUnit) {
openPackageObjectsTraverser(unit.body)
}
}
} Does this run as per normal in the presentation compiler? Or, might the compilation unit containing the package object be evade from this phase, only to be later loaded by the presentations compiler's BrowsingLoader? |
@dragos said: |
@retronym said: case ModuleDef(_, name, _) =>
if (packagePrefix == root.fullName) {
val module = enterModule(root, name.toString, new SourcefileLoader(src))
entered += 1
if (name == nme.PACKAGEkw) {
println("open package module: "+module)
openPackageModule(module, root)
}
} else println("prefixes differ: "+packagePrefix+","+root.fullName) Do you see the console output: "open package module" in the logs? |
@dragos said: |
this is so old I'm going to provisionally close it without attempting to reproduce it. we can reopen if someone steps forward with evidence it's still relevant |
I had the following code:
It resulted in a compiler crash (logged on the console). It is non-deterministic, and it probably has to do with an unfortunate ordering of forcing symbols.
The text was updated successfully, but these errors were encountered: