Skip to content

Commit

Permalink
Merge pull request scala#6004 from retronym/ticket/10423
Browse files Browse the repository at this point in the history
Don't assume final member class in another comp. unit will stay final
  • Loading branch information
retronym authored Jul 25, 2017
2 parents 8721ec3 + f4c8aab commit 6ac6da8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/transform/Constructors.scala
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ abstract class Constructors extends Statics with Transform with TypingTransforme
primaryConstrBody.expr)
})

if (omittableAccessor.exists(_.isOuterField) && !constructorStats.exists(_.exists { case i: Ident if i.symbol.isOuterParam => true; case _ => false}))
if ((exitingPickler(clazz.isAnonymousClass) || clazz.originalOwner.isTerm) && omittableAccessor.exists(_.isOuterField) && !constructorStats.exists(_.exists { case i: Ident if i.symbol.isOuterParam => true; case _ => false}))
primaryConstructor.symbol.updateAttachment(OuterArgCanBeElided)

val constructors = primaryConstructor :: auxConstructors
Expand Down
11 changes: 11 additions & 0 deletions test/files/run/t10423/A_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Outer {
final class Inner {
def foo: Unit = ()
}
}
object Test {
def main(args: Array[String]): Unit = {
val o = new Outer
new o.Inner().foo
}
}
6 changes: 6 additions & 0 deletions test/files/run/t10423/A_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class Outer {
class Inner {
def foo: Unit = assert(Outer.this ne null)
}
}

0 comments on commit 6ac6da8

Please sign in to comment.