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 =
75
75
||
76
76
method.owner.owner == sym.owner && ! method.owner.isOneOf(MethodOrLazy )
77
77
)
78
+ && ! sym.owner.is(Module ) // lambdalift doesn't transform correctly (to do)
78
79
val inConstructor =
79
80
(method.isPrimaryConstructor || inAnonFunInCtor)
80
81
&& ctx.owner.enclosingClass == sym.owner
Original file line number Diff line number Diff line change @@ -9,3 +9,10 @@ import scala.util.boundary
9
9
10
10
class Leak ()(using @ constructorOnly l : boundary.Label [String ]):
11
11
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
6
6
assert(classOf [Leak ].getFields.length == 0 )
7
7
// classOf[Leak].getFields.map(_.getName).foreach(println) //DEBUG
8
8
assert(classOf [C ].getFields.length == 0 )
9
+ // classOf[Lapse.type].getFields.map(_.getName).foreach(println) //DEBUG
9
10
10
11
class C :
11
12
private val x = 42
12
13
println(x)
13
14
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