Skip to content

Emit inner classes table. #406

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

Merged
merged 3 commits into from
Apr 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ object DottyBuild extends Build {
// get reflect and xml onboard
libraryDependencies ++= Seq("org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.scala-lang.modules" %% "scala-xml" % "1.0.1",
"me.d-d" % "scala-compiler" % "2.11.5-20150216-154453-f58d45491b",
"me.d-d" % "scala-compiler" % "2.11.5-20150402-193021-0c75410da3",
"jline" % "jline" % "2.12"),

// get junit onboard
Expand Down
24 changes: 16 additions & 8 deletions src/dotty/tools/backend/jvm/DottyBackendInterface.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import dotty.tools.dotc.util.{Positions, DotClass}
import Decorators._
import tpd._
import StdNames.nme
import NameOps._

class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
trait NonExistentTree extends tpd.Tree
Expand Down Expand Up @@ -382,7 +383,7 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
def toTypeName: Name = n.toTypeName
def isTypeName: Boolean = n.isTypeName
def toTermName: Name = n.toTermName
def dropModule: Name = ???
def dropModule: Name = n.stripModuleClassSuffix

def len: Int = n.length
def offset: Int = n.start
Expand All @@ -409,7 +410,7 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{

// tests
def isClass: Boolean = {
sym.isClass && (sym.isPackageObject || !(sym is Flags.Package))
sym.isPackageObject || (sym.isClass)
}
def isType: Boolean = sym.isType
def isAnonymousClass: Boolean = toDenot(sym).isAnonymousClass
Expand Down Expand Up @@ -475,16 +476,17 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{

// navigation
def owner: Symbol = toDenot(sym).owner
def rawowner: Symbol = owner
def rawowner: Symbol = {
originalOwner
}
def originalOwner: Symbol = {
try {
if (sym.exists) {
val original = toDenot(sym).initial
val validity = original.validFor
val shiftedContext = ctx.withPhase(validity.phaseId)
val r = toDenot(sym)(shiftedContext).maybeOwner
if(r is Flags.Package) NoSymbol
else r
val r = toDenot(sym)(shiftedContext).maybeOwner.enclosingClass(shiftedContext)
r
} else NoSymbol
} catch {
case e: NotDefinedHere => NoSymbol // todo: do we have a method to tests this?
Expand All @@ -511,14 +513,20 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
def companionModule: Symbol = toDenot(sym).companionModule
def companionSymbol: Symbol = if (sym is Flags.Module) companionClass else companionModule
def moduleClass: Symbol = toDenot(sym).moduleClass
def enclosingClassSym: Symbol = enclClass //todo is handled specially for JavaDefined symbols in scalac
def enclosingClassSym: Symbol = {
if(this.isClass) {
val ct = ctx.withPhase(ctx.flattenPhase.prev)
toDenot(sym)(ct).owner.enclosingClass(ct)
}
else sym.enclosingClass(ctx.withPhase(ctx.flattenPhase.prev))
} //todo is handled specially for JavaDefined symbols in scalac



// members
def primaryConstructor: Symbol = toDenot(sym).primaryConstructor
def nestedClasses: List[Symbol] = memberClasses //exitingPhase(currentRun.lambdaliftPhase)(sym.memberClasses)
def memberClasses: List[Symbol] = toDenot(sym).info.memberClasses.map(_.symbol).toList
def memberClasses: List[Symbol] = toDenot(sym).info.memberClasses(ctx.withPhase(ctx.flattenPhase.prev)).map(_.symbol).toList
def annotations: List[Annotation] = Nil
def companionModuleMembers: List[Symbol] = {
// phase travel to exitingPickler: this makes sure that memberClassesOf only sees member classes,
Expand Down
3 changes: 3 additions & 0 deletions src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,9 @@ object SymDenotations {
* but in turn the enclosing class of the latter. This reflects
* the context created by `Context#superCallContext`, `Contect#thisCallArgContext`
* for these definitions.
*
* Note, that as packages have ClassSymbols, top level classes will have an `enclosingClass`
* with Package flag set.
*/
final def enclosingClass(implicit ctx: Context): Symbol = {
def enclClass(sym: Symbol, skip: Boolean): Symbol = {
Expand Down