@@ -170,7 +170,7 @@ object CheckCaptures:
170
170
traverse(parent)
171
171
case t =>
172
172
traverseChildren(t)
173
- if ccConfig.allowUniversalInBoxed then check.traverse(tp)
173
+ if ccConfig.useSealed then check.traverse(tp)
174
174
end disallowRootCapabilitiesIn
175
175
176
176
/** Attachment key for bodies of closures, provided they are values */
@@ -581,7 +581,7 @@ class CheckCaptures extends Recheck, SymTransformer:
581
581
end instantiate
582
582
583
583
override def recheckTypeApply (tree : TypeApply , pt : Type )(using Context ): Type =
584
- if ccConfig.allowUniversalInBoxed then
584
+ if ccConfig.useSealed then
585
585
val TypeApply (fn, args) = tree
586
586
val polyType = atPhase(thisPhase.prev):
587
587
fn.tpe.widen.asInstanceOf [TypeLambda ]
@@ -806,7 +806,7 @@ class CheckCaptures extends Recheck, SymTransformer:
806
806
807
807
override def recheckTry (tree : Try , pt : Type )(using Context ): Type =
808
808
val tp = super .recheckTry(tree, pt)
809
- if ccConfig.allowUniversalInBoxed && Feature .enabled(Feature .saferExceptions) then
809
+ if ccConfig.useSealed && Feature .enabled(Feature .saferExceptions) then
810
810
disallowRootCapabilitiesIn(tp, ctx.owner,
811
811
" result of `try`" , " have type" ,
812
812
" This is often caused by a locally generated exception capability leaking as part of its result." ,
@@ -875,7 +875,7 @@ class CheckCaptures extends Recheck, SymTransformer:
875
875
}
876
876
checkNotUniversal(parent)
877
877
case _ =>
878
- if ! ccConfig.allowUniversalInBoxed
878
+ if ! ccConfig.useSealed
879
879
&& ! tpe.hasAnnotation(defn.UncheckedCapturesAnnot )
880
880
&& needsUniversalCheck
881
881
then
@@ -1100,7 +1100,7 @@ class CheckCaptures extends Recheck, SymTransformer:
1100
1100
def msg = em """ $actual cannot be box-converted to $expected
1101
1101
|since at least one of their capture sets contains the root capability `cap` """
1102
1102
def allowUniversalInBoxed =
1103
- ccConfig.allowUniversalInBoxed
1103
+ ccConfig.useSealed
1104
1104
|| expected.hasAnnotation(defn.UncheckedCapturesAnnot )
1105
1105
|| actual.widen.hasAnnotation(defn.UncheckedCapturesAnnot )
1106
1106
if criticalSet.isUnboxable && expected.isValueType && ! allowUniversalInBoxed then
@@ -1129,20 +1129,6 @@ class CheckCaptures extends Recheck, SymTransformer:
1129
1129
recur(actual, expected, covariant)
1130
1130
end adaptBoxed
1131
1131
1132
- /** If actual derives from caps.Capability, yet is not a capturing type itself,
1133
- * make its capture set explicit.
1134
- */
1135
- private def makeCaptureSetExplicit (actual : Type )(using Context ): Type =
1136
- if ccConfig.expandCapabilityInSetup then actual
1137
- else actual match
1138
- case CapturingType (_, _) => actual
1139
- case _ if actual.derivesFromCapability =>
1140
- val cap : CaptureRef = actual match
1141
- case ref : CaptureRef if ref.isTracked => ref
1142
- case _ => defn.captureRoot.termRef // TODO: skolemize?
1143
- CapturingType (actual, cap.singletonCaptureSet)
1144
- case _ => actual
1145
-
1146
1132
/** If actual is a tracked CaptureRef `a` and widened is a capturing type T^C,
1147
1133
* improve `T^C` to `T^{a}`, following the VAR rule of CC.
1148
1134
*/
@@ -1163,12 +1149,11 @@ class CheckCaptures extends Recheck, SymTransformer:
1163
1149
if expected == LhsProto || expected.isSingleton && actual.isSingleton then
1164
1150
actual
1165
1151
else
1166
- val normalized = makeCaptureSetExplicit(actual)
1167
- val widened = improveCaptures(normalized.widen.dealiasKeepAnnots, actual)
1152
+ val widened = improveCaptures(actual.widen.dealiasKeepAnnots, actual)
1168
1153
val adapted = adaptBoxed(
1169
1154
widened.withReachCaptures(actual), expected, pos,
1170
1155
covariant = true , alwaysConst = false , boxErrors)
1171
- if adapted eq widened then normalized
1156
+ if adapted eq widened then actual
1172
1157
else adapted.showing(i " adapt boxed $actual vs $expected = $adapted" , capt)
1173
1158
end adapt
1174
1159
0 commit comments