Skip to content

Commit 629f4ac

Browse files
committed
Merge pull request #546 from dotty-staging/fix-#545
Fix #545: no need to make members of static classes static.
2 parents e095228 + 929e889 commit 629f4ac

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/dotty/tools/dotc/transform/LambdaLift.scala

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class LambdaLift extends MiniPhase with IdentityDenotTransformer { thisTransform
6666
/** A map from local methods and classes to the owners to which they will be lifted as members.
6767
* For methods and classes that do not have any dependencies this will be the enclosing package.
6868
* symbols with packages as lifted owners will subsequently represented as static
69-
* members of their toplevel class.
69+
* members of their toplevel class, unless their enclosing class was already static.
7070
*/
7171
private val liftedOwner = new HashMap[Symbol, Symbol]
7272

@@ -288,7 +288,17 @@ class LambdaLift extends MiniPhase with IdentityDenotTransformer { thisTransform
288288
private def liftLocals()(implicit ctx: Context): Unit = {
289289
for ((local, lOwner) <- liftedOwner) {
290290
val (newOwner, maybeStatic) =
291-
if (lOwner is Package) (local.topLevelClass, JavaStatic)
291+
if (lOwner is Package) {
292+
val encClass = local.enclosingClass
293+
val topClass = local.topLevelClass
294+
// member of a static object
295+
if (encClass.isStatic && encClass.isProperlyContainedIn(topClass)) {
296+
// though the second condition seems weird, it's not true for symbols which are defined in some
297+
// weird combinations of super calls.
298+
(encClass, EmptyFlags)
299+
} else
300+
(topClass, JavaStatic)
301+
}
292302
else (lOwner, EmptyFlags)
293303
local.copySymDenotation(
294304
owner = newOwner,

0 commit comments

Comments
 (0)