Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/dotty/tools/dotc/transform/LambdaLift.scala
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class LambdaLift extends MiniPhase with IdentityDenotTransformer { thisTransform
/** A map from local methods and classes to the owners to which they will be lifted as members.
* For methods and classes that do not have any dependencies this will be the enclosing package.
* symbols with packages as lifted owners will subsequently represented as static
* members of their toplevel class.
* members of their toplevel class, unless their enclosing class was already static.
*/
private val liftedOwner = new HashMap[Symbol, Symbol]

Expand Down Expand Up @@ -288,7 +288,17 @@ class LambdaLift extends MiniPhase with IdentityDenotTransformer { thisTransform
private def liftLocals()(implicit ctx: Context): Unit = {
for ((local, lOwner) <- liftedOwner) {
val (newOwner, maybeStatic) =
if (lOwner is Package) (local.topLevelClass, JavaStatic)
if (lOwner is Package) {
val encClass = local.enclosingClass
val topClass = local.topLevelClass
// member of a static object
if (encClass.isStatic && encClass.isProperlyContainedIn(topClass)) {
// though the second condition seems weird, it's not true for symbols which are defined in some
// weird combinations of super calls.
(encClass, EmptyFlags)
} else
(topClass, JavaStatic)
}
else (lOwner, EmptyFlags)
local.copySymDenotation(
owner = newOwner,
Expand Down