aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorodersky <odersky@gmail.com>2015-04-03 16:09:39 +0200
committerodersky <odersky@gmail.com>2015-04-03 16:09:39 +0200
commit62433d2877e3c3dd8a5385b2057274c7f36d6ff2 (patch)
tree503e57c7a0e888b1a1f5b1e3090fdf21a9ebb5e1 /src
parentd578a53e92a4c315662df28bb3ba65496d204131 (diff)
parente27655eadb4dbe84d67d95cf5ba00762a88ac2de (diff)
downloaddotty-62433d2877e3c3dd8a5385b2057274c7f36d6ff2.tar.gz
dotty-62433d2877e3c3dd8a5385b2057274c7f36d6ff2.tar.bz2
dotty-62433d2877e3c3dd8a5385b2057274c7f36d6ff2.zip
Merge pull request #406 from dotty-staging/inner-classes
Emit inner classes table.
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/backend/jvm/DottyBackendInterface.scala24
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala3
2 files changed, 19 insertions, 8 deletions
diff --git a/src/dotty/tools/backend/jvm/DottyBackendInterface.scala b/src/dotty/tools/backend/jvm/DottyBackendInterface.scala
index 357018857..368145847 100644
--- a/src/dotty/tools/backend/jvm/DottyBackendInterface.scala
+++ b/src/dotty/tools/backend/jvm/DottyBackendInterface.scala
@@ -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
@@ -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
@@ -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
@@ -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?
@@ -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,
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index e8008eeb3..1285d3fdd 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -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 = {