13 Oct 06:39
class file of a Symbol (compiler question)
From: Mark Harrah <harrah <at> bu.edu>
Subject: class file of a Symbol (compiler question)
Newsgroups: gmane.comp.lang.scala
Date: 2008-10-13 04:40:00 GMT
Subject: class file of a Symbol (compiler question)
Newsgroups: gmane.comp.lang.scala
Date: 2008-10-13 04:40:00 GMT
I'm trying to get the class file that a Symbol was loaded from in a compiler
plugin. Specifically, inside the run method of a Phase I am doing something
like:
for(unit <- currentRun.units; sym <- unit.depends)
println(sym.toplevelClass.asInstanceOf[ClassSymbol].classFile)
but this always seems to print null. From what I can tell,
ClassSymbol.classFile is not set anywhere in the compiler. It looks to me
like this used to happen in ClassfileParser.parse around line 66, but was
commented out in changeset 12705.
So, instead, I have to do something like
val name = sym.fullNameString(File.separatorChar) +
(if(sym.hasFlag(MODULE)) "$" else "")
println(classPath.root.find(name, false).classFile)
(as is done in DefaultDocDriver) and this works as expected but is relatively
slow.
Should ClassSymbol.classFile work the way I think it should or am I doing
something wrong?
Thanks,
Mark
RSS Feed