Skip to content

Commit 3d2a4cd

Browse files
committed
Make constructors level owners
1 parent 0ffba0d commit 3d2a4cd

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

compiler/src/dotty/tools/dotc/cc/CaptureOps.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ private val adaptUnpickledFunctionTypes = false
2828
*/
2929
private val constrainRootsWhenMapping = true
3030

31-
private val constructorsAreLevelOwners = false
32-
3331
def allowUniversalInBoxed(using Context) =
3432
Feature.sourceVersion.isAtLeast(SourceVersion.`3.3`)
3533

@@ -394,7 +392,6 @@ extension (sym: Symbol)
394392
|| symd.owner.is(CaptureChecked)
395393
|| Synthetics.needsTransform(symd)
396394
)
397-
&& !symd.isConstructor
398395
&& (!symd.isAnonymousFunction || sym.definedLocalRoot.exists)
399396
&& takesCappedParamIn(symd.info)
400397
&& { ccSetup.println(i"Level owner $sym"); true }

compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ class CheckCaptures extends Recheck, SymTransformer:
378378
val tpw = tp.widen
379379
var tp1 = tpw
380380
val rootVar = CaptureRoot.Var(ctx.owner, sym)
381-
if sym.skipConstructor.isLevelOwner then
381+
if sym.isLevelOwner then
382382
tp1 = mapRoots(sym.localRoot.termRef, rootVar)(tp1)
383383
if tp1 ne tpw then
384384
ccSetup.println(i"INST local $sym: $tp, ${sym.localRoot} = $tp1")

compiler/src/dotty/tools/dotc/cc/Setup.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -566,12 +566,14 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
566566
val newInfo = absInfo(localReturnType)
567567
if newInfo ne sym.info then
568568
val updatedInfo =
569-
if sym.isAnonymousFunction || sym.is(Param) || sym.is(ParamAccessor) then
569+
if sym.isAnonymousFunction
570+
|| sym.is(Param)
571+
|| sym.is(ParamAccessor)
572+
|| sym.isPrimaryConstructor
573+
then
570574
// closures are handled specially; the newInfo is constrained from
571575
// the expected type and only afterwards we recheck the definition
572576
newInfo
573-
else if sym.isPrimaryConstructor then
574-
newInfo
575577
else new LazyType:
576578
def complete(denot: SymDenotation)(using Context) =
577579
// infos of other methods are determined from their definitions which

0 commit comments

Comments
 (0)