@@ -263,11 +263,12 @@ class CheckCaptures extends Recheck, SymTransformer:
263
263
pos, provenance)
264
264
265
265
/** Check subcapturing `cs1 <: cs2`, report error on failure */
266
- def checkSubset (cs1 : CaptureSet , cs2 : CaptureSet , pos : SrcPos , provenance : => String = " " )(using Context ) =
266
+ def checkSubset (cs1 : CaptureSet , cs2 : CaptureSet , pos : SrcPos ,
267
+ provenance : => String = " " , cs1description : String = " " )(using Context ) =
267
268
checkOK(
268
269
cs1.subCaptures(cs2, frozen = false ),
269
- if cs1.elems.size == 1 then i " reference ${cs1.elems.toList.head} is not "
270
- else i " references $cs1 are not all " ,
270
+ if cs1.elems.size == 1 then i " reference ${cs1.elems.toList.head}$cs1description is not "
271
+ else i " references $cs1$cs1description are not all " ,
271
272
pos, provenance)
272
273
273
274
/** The current environment */
@@ -683,9 +684,15 @@ class CheckCaptures extends Recheck, SymTransformer:
683
684
if ! param.hasAnnotation(defn.ConstructorOnlyAnnot ) then
684
685
checkSubset(param.termRef.captureSet, thisSet, param.srcPos) // (3)
685
686
for pureBase <- cls.pureBaseClass do // (4)
687
+ def selfType = impl.body
688
+ .collect:
689
+ case TypeDef (tpnme.SELF , rhs) => rhs
690
+ .headOption
691
+ .getOrElse(tree)
692
+ .orElse(tree)
686
693
checkSubset(thisSet,
687
694
CaptureSet .empty.withDescription(i " of pure base class $pureBase" ),
688
- tree .srcPos)
695
+ selfType .srcPos, cs1description = " captured by this self type " )
689
696
super .recheckClassDef(tree, impl, cls)
690
697
finally
691
698
curEnv = saved
0 commit comments