Skip to content

Commit d2b9c9d

Browse files
committed
Drop checkBoxes switch
Always account for boxes in subtyping
1 parent fa37358 commit d2b9c9d

File tree

3 files changed

+14
-19
lines changed

3 files changed

+14
-19
lines changed

compiler/src/dotty/tools/dotc/config/Config.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,4 @@ object Config {
245245
* cases, though.
246246
*/
247247
inline val ccAllowUnsoundMaps = false
248-
249-
val checkBoxes = true
250248
}

compiler/src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2555,9 +2555,8 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
25552555
refs1.subCaptures(refs2, frozen)
25562556

25572557
protected def sameBoxed(tp1: Type, tp2: Type, refs: CaptureSet)(using Context): Boolean =
2558-
!Config.checkBoxes
2559-
|| (tp1.isBoxedCapturing == tp2.isBoxedCapturing)
2560-
|| refs.subCaptures(CaptureSet.empty, frozenConstraint).isOK
2558+
(tp1.isBoxedCapturing == tp2.isBoxedCapturing)
2559+
|| refs.subCaptures(CaptureSet.empty, frozenConstraint).isOK
25612560

25622561
// ----------- Diagnostics --------------------------------------------------
25632562

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

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -571,20 +571,18 @@ class CheckCaptures extends Recheck, SymTransformer:
571571
.toFunctionType(isJava = false, alwaysDependent = true))
572572
case _ => actual
573573

574-
if Config.checkBoxes then
575-
var actualw = actual.widenDealias
576-
actual match
577-
case ref: CaptureRef if ref.isTracked =>
578-
actualw match
579-
case CapturingType(p, refs) =>
580-
actualw = actualw.derivedCapturingType(p, ref.singletonCaptureSet)
581-
case _ =>
582-
case _ =>
583-
val adapted = adapt(actualw, expected, covariant = true)
584-
if adapted ne actualw then
585-
capt.println(i"adapt boxed $actual vs $expected ===> $adapted")
586-
adapted
587-
else actual
574+
var actualw = actual.widenDealias
575+
actual match
576+
case ref: CaptureRef if ref.isTracked =>
577+
actualw match
578+
case CapturingType(p, refs) =>
579+
actualw = actualw.derivedCapturingType(p, ref.singletonCaptureSet)
580+
case _ =>
581+
case _ =>
582+
val adapted = adapt(actualw, expected, covariant = true)
583+
if adapted ne actualw then
584+
capt.println(i"adapt boxed $actual vs $expected ===> $adapted")
585+
adapted
588586
else actual
589587
end adaptBoxed
590588

0 commit comments

Comments
 (0)