From b2e22fa308b2f402d78dc3d3afc33256c1d3cbba Mon Sep 17 00:00:00 2001 From: Lukas Rytz Date: Tue, 3 Feb 2015 11:29:08 +0100 Subject: Fix InnerClass / EnclosingMethod for closures nested in value classes Members of value classes are moved over to the companion object early. This change ensures that closure classes nested in value classes appear that way to Java reflection. This commit also changes the EnclosingMethod attribute for classes (and anonymous functions) nested in anonymous function bodies. Before, the enclosing method was in some cases the function's apply method. Not always though: () => { class C ... val a = { class D ...} } The class C used to be nested in the function's apply method, but not D, because the value definition for a was lifted out of the apply. After this commit, we uniformly set the enclosing method of classes nested in function bodies to `null`. This is consistent with the source-level view of the code. Note that under delambdafy:method, closures never appear as enclosing classes (this didn't change in this commit). --- src/interactive/scala/tools/nsc/interactive/Global.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/interactive') diff --git a/src/interactive/scala/tools/nsc/interactive/Global.scala b/src/interactive/scala/tools/nsc/interactive/Global.scala index 9b34a39e02..a3d0346f81 100644 --- a/src/interactive/scala/tools/nsc/interactive/Global.scala +++ b/src/interactive/scala/tools/nsc/interactive/Global.scala @@ -152,7 +152,7 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "") // don't keep the original owner in presentation compiler runs // (the map will grow indefinitely, and the only use case is the backend) - override protected def saveOriginalOwner(sym: Symbol) { } + override def defineOriginalOwner(sym: Symbol, owner: Symbol): Unit = { } override def forInteractive = true override protected def synchronizeNames = true -- cgit v1.2.3