Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 0e22004

Browse files
committed
Module failure
1 parent f1e3b3e commit 0e22004

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

compiler/src/dotty/tools/dotc/transform/Constructors.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class Constructors extends MiniPhase with IdentityDenotTransformer { thisPhase =
7575
||
7676
method.owner.owner == sym.owner && !method.owner.isOneOf(MethodOrLazy)
7777
)
78+
&& !sym.owner.is(Module) // lambdalift doesn't transform correctly (to do)
7879
val inConstructor =
7980
(method.isPrimaryConstructor || inAnonFunInCtor)
8081
&& ctx.owner.enclosingClass == sym.owner

tests/pos/i22979.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,10 @@ import scala.util.boundary
99

1010
class Leak()(using @constructorOnly l: boundary.Label[String]):
1111
Option("stop").foreach(boundary.break(_))
12+
13+
14+
class Lapse:
15+
def f = Lapse.DefaultSentinelFn()
16+
object Lapse:
17+
private val DefaultSentinel: AnyRef = new AnyRef
18+
private val DefaultSentinelFn: () => AnyRef = () => DefaultSentinel

tests/run/i22979/test.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,17 @@ import util.Try
66
assert(classOf[Leak].getFields.length == 0)
77
//classOf[Leak].getFields.map(_.getName).foreach(println) //DEBUG
88
assert(classOf[C].getFields.length == 0)
9+
//classOf[Lapse.type].getFields.map(_.getName).foreach(println) //DEBUG
910

1011
class C:
1112
private val x = 42
1213
println(x)
1314
println(List(27).map(_ + x))
15+
16+
// The easy tweak for lambdas does not work for module owner.
17+
// The lambdalifted anonfun is not transformed correctly.
18+
class Lapse:
19+
def f = Lapse.DefaultSentinelFn()
20+
object Lapse:
21+
private val DefaultSentinel: AnyRef = new AnyRef
22+
private val DefaultSentinelFn: () => AnyRef = () => DefaultSentinel

0 commit comments

Comments
 (0)