File tree Expand file tree Collapse file tree 3 files changed +17
-0
lines changed
compiler/src/dotty/tools/dotc/transform Expand file tree Collapse file tree 3 files changed +17
-0
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -9,3 +9,10 @@ import scala.util.boundary
99
1010class 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
Original file line number Diff line number Diff 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
1011class 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
You can’t perform that action at this time.
0 commit comments