This page is no longer maintained — Please continue to the home page at www.scala-lang.org

symbol emancipation

No replies
extempore
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.

I've been trying to bring -Ycheck back to life, and my limited success
so far indicates I should keep going, because I am a drowning man
looking for invariants and here we have some, at least once upon a time.
Here's the first thing I don't know how to resolve. If you have a file
that starts like:

package scala.tools.nsc

(as opposed to)

package scala
package tools
package nsc

Then nsc has symbol owner "tools" but when traversing after typer,
currentOwner is never updated with the symbols between and nsc.
I expect this happened when package semantics were changed to let us
avoid having to share com._ with the whole world.

The check performed on each tree in TreeCheckers is something like: does
this tree's symbol's owner (or possibly a little further up the owner
chain: the first symbol which could be currentOwner) equal to
currentOwner? And here, it isn't.

So the question is, what should nsc's owner be in the first file? I
can't find a very precise definition of what a symbol's owner is. If
the owner is a property of "nsc" and not something which can vary
between files (which is my present understanding) then the owner has to
be tools, or this is some symbol which looks like "nsc" but isn't. The
"real" nsc does this:

scala> global.definitions.getModule("scala.tools.nsc").ownerChain
res3: List[global.Symbol] = List(package nsc, package tools, package scala, package )

Then either the check being performed has to be relaxed for this case,
or currentOwner has to be "faked" when traversing a dotted PackageDef,
or there is a symbol representing "scala.tools.nsc" which shares some
but not all of the properties of symbols "nsc" (which surely can't be
right) or... none of my currentIdeas feel at all correct.

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland