Skip to content

Commit b9052da

Browse files
lrytzadriaanm
authored andcommitted
Fix enclosing method attribute for classes nested in trait fields
Trait fields are now created as MethodSymbol (no longer TermSymbol). This symbol shows up in the `originalOwner` chain of a class declared within the field initializer. This promoted the field getter to being the enclosing method of the nested class, which it is not (the EnclosingMethod attribute is a source-level property).
1 parent 2b916f4 commit b9052da

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ final class BCodeAsmCommon[G <: Global](val global: G) {
162162

163163
def enclosingMethod(sym: Symbol): Option[Symbol] = {
164164
if (sym.isClass || sym == NoSymbol) None
165-
else if (sym.isMethod) {
165+
else if (sym.isMethod && !sym.isGetter) {
166166
if (doesNotExist(sym)) None else Some(sym)
167167
}
168168
else enclosingMethod(nextEnclosing(sym))

0 commit comments

Comments
 (0)