File tree 3 files changed +5
-35
lines changed
compiler/src/dotty/tools/dotc
3 files changed +5
-35
lines changed Original file line number Diff line number Diff line change @@ -170,32 +170,6 @@ extension (tree: Tree)
170
170
171
171
extension (tp : Type )
172
172
173
- /**
174
- * Is the type `tp` a `CapSet` type, i.e., a capture variable?
175
- *
176
- * @param tp The type to check
177
- * @param includeCapSet Whether to include the bare `CapSet` type itself in the check, false at the top level
178
- */
179
- final def isCapSet (includeCapSet : Boolean = false )(using Context ): Boolean = tp match
180
- case tp : TypeRef => (includeCapSet && (tp.symbol eq defn.Caps_CapSet )) || {
181
- tp.underlying match
182
- case TypeBounds (lo, hi) => lo.isCapSet(true ) && hi.isCapSet(true )
183
- case TypeAlias (alias) => alias.isCapSet() // TODO: test cases involving type aliases
184
- case _ => false
185
- }
186
- case tp : SingletonType => tp.underlying.isCapSet()
187
- case CapturingType (parent, _) => parent.isCapSet(true )
188
- case _ => false
189
-
190
- /**
191
- * The capture set of a capture variable. Assumes that tp.isCapSet() is true.
192
- */
193
- final def captureSetOfCapSet (using Context ): CaptureSet = tp match
194
- case CapturingType (_,c) => c
195
- case tp : TypeRef if tp.symbol eq defn.Caps_CapSet => CaptureSet .empty
196
- case tp : SingletonType => tp.underlying.captureSetOfCapSet
197
- case tp : CaptureRef => CaptureSet (tp)
198
-
199
173
/** Is this type a CaptureRef that can be tracked?
200
174
* This is true for
201
175
* - all ThisTypes and all TermParamRef,
Original file line number Diff line number Diff line change @@ -1073,9 +1073,6 @@ object CaptureSet:
1073
1073
case ReachCapability (ref1) =>
1074
1074
ref1.widen.deepCaptureSet(includeTypevars = true )
1075
1075
.showing(i " Deep capture set of $ref: ${ref1.widen} = ${result}" , capt)
1076
- case tp : TypeRef if tp.isCapSet() => tp.underlying match
1077
- case TypeBounds (lo, hi) if hi.isCapSet() => hi.captureSetOfCapSet
1078
- case _ => ofType(ref.underlying, followResult = true )
1079
1076
case _ =>
1080
1077
if ref.isMaxCapability then ref.singletonCaptureSet
1081
1078
else ofType(ref.underlying, followResult = true )
@@ -1088,10 +1085,9 @@ object CaptureSet:
1088
1085
tp.captureSet
1089
1086
case tp : TermParamRef =>
1090
1087
tp.captureSet
1091
- case _ : TypeRef =>
1092
- empty
1093
- case _ : TypeParamRef =>
1094
- empty
1088
+ case tp : (TypeRef | TypeParamRef ) =>
1089
+ if tp.derivesFrom(defn.Caps_CapSet ) then tp.captureSet
1090
+ else empty
1095
1091
case CapturingType (parent, refs) =>
1096
1092
recur(parent) ++ refs
1097
1093
case tp @ AnnotatedType (parent, ann) if ann.hasSymbol(defn.ReachCapabilityAnnot ) =>
Original file line number Diff line number Diff line change @@ -307,8 +307,8 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
307
307
* 0 if both tp1 and tp2 are capture variables but tp1 is not a subcapture of tp2.
308
308
*/
309
309
inline def tryHandleCaptureVars : Int =
310
- if ! (isCaptureCheckingOrSetup && tp1.isCapSet( ) && tp2.isCapSet( )) then - 1
311
- else if (subCaptures(tp1.captureSetOfCapSet , tp2.captureSetOfCapSet , frozenConstraint).isOK) then 1
310
+ if ! (isCaptureCheckingOrSetup && tp1.derivesFrom(defn. Caps_CapSet ) && tp1.derivesFrom(defn. Caps_CapSet )) then - 1
311
+ else if (subCaptures(tp1.captureSet , tp2.captureSet , frozenConstraint).isOK) then 1
312
312
else 0
313
313
314
314
def firstTry : Boolean = tp2 match {
You can’t perform that action at this time.
0 commit comments