Skip to content

Commit 62433d2

Browse files
committed
Merge pull request #406 from dotty-staging/inner-classes
Emit inner classes table.
2 parents d578a53 + e27655e commit 62433d2

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

project/Build.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ object DottyBuild extends Build {
3131
// get reflect and xml onboard
3232
libraryDependencies ++= Seq("org.scala-lang" % "scala-reflect" % scalaVersion.value,
3333
"org.scala-lang.modules" %% "scala-xml" % "1.0.1",
34-
"me.d-d" % "scala-compiler" % "2.11.5-20150216-154453-f58d45491b",
34+
"me.d-d" % "scala-compiler" % "2.11.5-20150402-193021-0c75410da3",
3535
"jline" % "jline" % "2.12"),
3636

3737
// get junit onboard

src/dotty/tools/backend/jvm/DottyBackendInterface.scala

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import dotty.tools.dotc.util.{Positions, DotClass}
2828
import Decorators._
2929
import tpd._
3030
import StdNames.nme
31+
import NameOps._
3132

3233
class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
3334
trait NonExistentTree extends tpd.Tree
@@ -382,7 +383,7 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
382383
def toTypeName: Name = n.toTypeName
383384
def isTypeName: Boolean = n.isTypeName
384385
def toTermName: Name = n.toTermName
385-
def dropModule: Name = ???
386+
def dropModule: Name = n.stripModuleClassSuffix
386387

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

410411
// tests
411412
def isClass: Boolean = {
412-
sym.isClass && (sym.isPackageObject || !(sym is Flags.Package))
413+
sym.isPackageObject || (sym.isClass)
413414
}
414415
def isType: Boolean = sym.isType
415416
def isAnonymousClass: Boolean = toDenot(sym).isAnonymousClass
@@ -475,16 +476,17 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
475476

476477
// navigation
477478
def owner: Symbol = toDenot(sym).owner
478-
def rawowner: Symbol = owner
479+
def rawowner: Symbol = {
480+
originalOwner
481+
}
479482
def originalOwner: Symbol = {
480483
try {
481484
if (sym.exists) {
482485
val original = toDenot(sym).initial
483486
val validity = original.validFor
484487
val shiftedContext = ctx.withPhase(validity.phaseId)
485-
val r = toDenot(sym)(shiftedContext).maybeOwner
486-
if(r is Flags.Package) NoSymbol
487-
else r
488+
val r = toDenot(sym)(shiftedContext).maybeOwner.enclosingClass(shiftedContext)
489+
r
488490
} else NoSymbol
489491
} catch {
490492
case e: NotDefinedHere => NoSymbol // todo: do we have a method to tests this?
@@ -511,14 +513,20 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
511513
def companionModule: Symbol = toDenot(sym).companionModule
512514
def companionSymbol: Symbol = if (sym is Flags.Module) companionClass else companionModule
513515
def moduleClass: Symbol = toDenot(sym).moduleClass
514-
def enclosingClassSym: Symbol = enclClass //todo is handled specially for JavaDefined symbols in scalac
516+
def enclosingClassSym: Symbol = {
517+
if(this.isClass) {
518+
val ct = ctx.withPhase(ctx.flattenPhase.prev)
519+
toDenot(sym)(ct).owner.enclosingClass(ct)
520+
}
521+
else sym.enclosingClass(ctx.withPhase(ctx.flattenPhase.prev))
522+
} //todo is handled specially for JavaDefined symbols in scalac
515523

516524

517525

518526
// members
519527
def primaryConstructor: Symbol = toDenot(sym).primaryConstructor
520528
def nestedClasses: List[Symbol] = memberClasses //exitingPhase(currentRun.lambdaliftPhase)(sym.memberClasses)
521-
def memberClasses: List[Symbol] = toDenot(sym).info.memberClasses.map(_.symbol).toList
529+
def memberClasses: List[Symbol] = toDenot(sym).info.memberClasses(ctx.withPhase(ctx.flattenPhase.prev)).map(_.symbol).toList
522530
def annotations: List[Annotation] = Nil
523531
def companionModuleMembers: List[Symbol] = {
524532
// phase travel to exitingPickler: this makes sure that memberClassesOf only sees member classes,

src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,9 @@ object SymDenotations {
716716
* but in turn the enclosing class of the latter. This reflects
717717
* the context created by `Context#superCallContext`, `Contect#thisCallArgContext`
718718
* for these definitions.
719+
*
720+
* Note, that as packages have ClassSymbols, top level classes will have an `enclosingClass`
721+
* with Package flag set.
719722
*/
720723
final def enclosingClass(implicit ctx: Context): Symbol = {
721724
def enclClass(sym: Symbol, skip: Boolean): Symbol = {

0 commit comments

Comments
 (0)