Skip to content

Commit 6898d2c

Browse files
smarterDarkDimius
authored andcommitted
Fix #580: use isContainedIn to support cases where the enclosing class is also the top-level class
1 parent 4bac1a5 commit 6898d2c

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ class LambdaLift extends MiniPhase with IdentityDenotTransformer { thisTransform
292292
val encClass = local.enclosingClass
293293
val topClass = local.topLevelClass
294294
// member of a static object
295-
if (encClass.isStatic && encClass.isProperlyContainedIn(topClass)) {
295+
if (encClass.isStatic && encClass.isContainedIn(topClass)) {
296296
// though the second condition seems weird, it's not true for symbols which are defined in some
297297
// weird combinations of super calls.
298298
(encClass, EmptyFlags)

tests/run/innerInObject.check

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1
2+
2

tests/run/innerInObject.scala

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
object Test {
2+
def foo(x: Int) = {
3+
println(x)
4+
}
5+
6+
def outer(x: Int) = {
7+
def inner() = {
8+
foo(x)
9+
}
10+
inner()
11+
}
12+
13+
def outer2(x: Int) = {
14+
def inner2() = {
15+
Test.foo(x)
16+
}
17+
inner2()
18+
}
19+
20+
def main(args: Array[String]): Unit = {
21+
outer(1)
22+
outer2(2)
23+
}
24+
}

0 commit comments

Comments
 (0)