Skip to content

Commit 017686c

Browse files
committed
Rename BackendIntf.originalOwner into originalLexicallyEnclosingClass.
The implementation goes further than the original owner and follows up with then original lexically enclosing class, so `originalOwner` was misleading.
1 parent 6871ce6 commit 017686c

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

compiler/src/dotty/tools/backend/jvm/BCodeAsmCommon.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import interface._
2020
// Here used to be an `assert(!classSym.isDelambdafyFunction)`: delambdafy lambda classes are
2121
// always top-level. However, SI-8900 shows an example where the weak name-based implementation
2222
// of isDelambdafyFunction failed (for a function declared in a package named "lambda").
23-
classSym.isAnonymousClass || (classSym.originalOwner != NoSymbol && !classSym.originalOwner.isClass)
23+
classSym.isAnonymousClass || (classSym.originalLexicallyEnclosingClass != NoSymbol && !classSym.originalLexicallyEnclosingClass.isClass)
2424
}
2525

2626
/**
@@ -44,29 +44,29 @@ import interface._
4444
* In this case, for B, we return None.
4545
*
4646
* The EnclosingMethod attribute needs to be added to non-member classes (see doc in BTypes).
47-
* This is a source-level property, so we need to use the originalOwner chain to reconstruct it.
47+
* This is a source-level property, so we need to use the originalLexicallyEnclosingClass chain to reconstruct it.
4848
*/
4949
private def enclosingMethodForEnclosingMethodAttribute(classSym: Symbol): Option[Symbol] = {
5050
assert(classSym.isClass, classSym)
5151
def enclosingMethod(sym: Symbol): Option[Symbol] = {
5252
if (sym.isClass || sym == NoSymbol) None
5353
else if (sym.isMethod) Some(sym)
54-
else enclosingMethod(sym.originalOwner)
54+
else enclosingMethod(sym.originalLexicallyEnclosingClass)
5555
}
56-
enclosingMethod(classSym.originalOwner)
56+
enclosingMethod(classSym.originalLexicallyEnclosingClass)
5757
}
5858

5959
/**
6060
* The enclosing class for emitting the EnclosingMethod attribute. Since this is a source-level
61-
* property, this method looks at the originalOwner chain. See doc in BTypes.
61+
* property, this method looks at the originalLexicallyEnclosingClass chain. See doc in BTypes.
6262
*/
6363
private def enclosingClassForEnclosingMethodAttribute(classSym: Symbol): Symbol = {
6464
assert(classSym.isClass, classSym)
6565
def enclosingClass(sym: Symbol): Symbol = {
6666
if (sym.isClass) sym
67-
else enclosingClass(sym.originalOwner)
67+
else enclosingClass(sym.originalLexicallyEnclosingClass)
6868
}
69-
enclosingClass(classSym.originalOwner)
69+
enclosingClass(classSym.originalLexicallyEnclosingClass)
7070
}
7171

7272
/*final*/ case class EnclosingMethodEntry(owner: String, name: String, methodDescriptor: String)

compiler/src/dotty/tools/backend/jvm/BTypesFromSymbols.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class BTypesFromSymbols[I <: BackendInterface](val int: I) extends BTypes {
147147
if (!isNested) None
148148
else {
149149
// See comment in BTypes, when is a class marked static in the InnerClass table.
150-
val isStaticNestedClass = innerClassSym.originalOwner.isOriginallyStaticOwner
150+
val isStaticNestedClass = innerClassSym.originalLexicallyEnclosingClass.isOriginallyStaticOwner
151151

152152
// After lambdalift (which is where we are), the rawowoner field contains the enclosing class.
153153
val enclosingClassSym = innerClassSym.enclosingClassSym

compiler/src/dotty/tools/backend/jvm/BackendInterface.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ abstract class BackendInterface extends BackendInterfaceDefinitions {
526526
// navigation
527527
def owner: Symbol
528528
def rawowner: Symbol // todo ???
529-
def originalOwner: Symbol
529+
def originalLexicallyEnclosingClass: Symbol
530530
def parentSymbols: List[Symbol]
531531
def superClass: Symbol
532532
def enclClass: Symbol
@@ -584,7 +584,7 @@ abstract class BackendInterface extends BackendInterfaceDefinitions {
584584
* the owner of U is T, so UModuleClass.isStatic is true. Phase travel does not help here.
585585
*/
586586
def isOriginallyStaticOwner: Boolean =
587-
isPackageClass || isModuleClass && originalOwner.isOriginallyStaticOwner
587+
isPackageClass || isModuleClass && originalLexicallyEnclosingClass.isOriginallyStaticOwner
588588

589589
def samMethod(): Symbol
590590

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -727,9 +727,9 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
727727
// navigation
728728
def owner: Symbol = toDenot(sym).owner
729729
def rawowner: Symbol = {
730-
originalOwner
730+
originalLexicallyEnclosingClass
731731
}
732-
def originalOwner: Symbol =
732+
def originalLexicallyEnclosingClass: Symbol =
733733
// used to populate the EnclosingMethod attribute.
734734
// it is very tricky in presence of classes(and annonymous classes) defined inside supper calls.
735735
if (sym.exists) {

0 commit comments

Comments
 (0)