Skip to content

Commit 155f3fe

Browse files
committed
Use LooseCaptureRoot checking for checking bounds of applied types
Temporary measure until we have class capture roots worked out
1 parent bb717fb commit 155f3fe

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ class CheckCaptures extends Recheck, SymTransformer:
376376
|| sym.isTerm && defn.isFunctionType(sym.info) && pt == AnySelectionProto
377377
if sym.skipConstructor.isLevelOwner && canInstantiate then
378378
val tpw = tp.widen
379-
val tp1 = mapRoots(sym.localRoot.termRef, CaptureRoot.Var(ctx.owner, sym))(tpw)
379+
var tp1 = mapRoots(sym.localRoot.termRef, CaptureRoot.Var(ctx.owner, sym))(tpw)
380380
.showing(i"INST $sym: $tp, ${sym.localRoot} = $result", ccSetup)
381381
if tpw eq tp1 then tp else tp1
382382
else
@@ -760,6 +760,8 @@ class CheckCaptures extends Recheck, SymTransformer:
760760
capt.println(i"fallBack from $actualWide to $actualInst to match $expected1")
761761
ok = (actualInst ne actualWide)
762762
&& isCompatible(adaptBoxed(actualInst, expected1, tree.srcPos), expected1)
763+
// Useful for debugging:
764+
// if !ok then err.typeMismatch(tree.withType(actualInst), expected1, addenda ++ CaptureSet.levelErrors)
763765
case _ =>
764766
if !ok then
765767
capt.println(i"conforms failed for ${tree}: $actual vs $expected")
@@ -1231,6 +1233,6 @@ class CheckCaptures extends Recheck, SymTransformer:
12311233
case tree: New =>
12321234
case tree: TypeTree => checkAppliedTypesIn(tree.withKnownType)
12331235
case _ => traverseChildren(t)
1234-
checkApplied.traverse(unit)
1236+
checkApplied.traverse(unit)(using ctx.withProperty(LooseRootChecking, Some(())))
12351237
end CaptureChecker
12361238
end CheckCaptures

0 commit comments

Comments
 (0)