@@ -204,25 +204,27 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
204204 /** Pull out an embedded capture set from a part of `tp` */
205205 def normalizeCaptures (tp : Type )(using Context ): Type = tp match
206206 case tp @ RefinedType (parent @ CapturingType (parent1, refs), rname, rinfo) =>
207- CapturingType (tp.derivedRefinedType(parent1, rname, rinfo), refs, parent.isBoxed)
207+ CapturingType (tp.derivedRefinedType(parent1, rname, rinfo), refs, parent.isBoxed).withOrigin(parent)
208208 case tp : RecType =>
209209 tp.parent match
210210 case parent @ CapturingType (parent1, refs) =>
211- CapturingType (tp.derivedRecType(parent1), refs, parent.isBoxed)
211+ CapturingType (tp.derivedRecType(parent1), refs, parent.isBoxed).withOrigin(parent)
212212 case _ =>
213213 tp // can return `tp` here since unlike RefinedTypes, RecTypes are never created
214214 // by `mapInferred`. Hence if the underlying type admits capture variables
215215 // a variable was already added, and the first case above would apply.
216216 case AndType (tp1 @ CapturingType (parent1, refs1), tp2 @ CapturingType (parent2, refs2)) =>
217217 assert(tp1.isBoxed == tp2.isBoxed)
218218 CapturingType (AndType (parent1, parent2), refs1 ** refs2, tp1.isBoxed)
219+ .withOrigins(Set (tp1, tp2))
219220 case tp @ OrType (tp1 @ CapturingType (parent1, refs1), tp2 @ CapturingType (parent2, refs2)) =>
220221 assert(tp1.isBoxed == tp2.isBoxed)
221222 CapturingType (OrType (parent1, parent2, tp.isSoft), refs1 ++ refs2, tp1.isBoxed)
223+ .withOrigins(Set (tp1, tp2))
222224 case tp @ OrType (tp1 @ CapturingType (parent1, refs1), tp2) =>
223- CapturingType (OrType (parent1, tp2, tp.isSoft), refs1, tp1.isBoxed)
225+ CapturingType (OrType (parent1, tp2, tp.isSoft), refs1, tp1.isBoxed).withOrigin(tp1)
224226 case tp @ OrType (tp1, tp2 @ CapturingType (parent2, refs2)) =>
225- CapturingType (OrType (tp1, parent2, tp.isSoft), refs2, tp2.isBoxed)
227+ CapturingType (OrType (tp1, parent2, tp.isSoft), refs2, tp2.isBoxed).withOrigin(tp2)
226228 case tp @ AppliedType (tycon, args)
227229 if ! defn.isFunctionClass(tp.dealias.typeSymbol) && (tp.dealias eq tp) =>
228230 tp.derivedAppliedType(tycon, args.mapConserve(_.boxDeeply))
@@ -266,7 +268,6 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
266268 tp.typeSymbol match
267269 case cls : ClassSymbol
268270 if ! defn.isFunctionClass(cls) && cls.is(CaptureChecked ) =>
269- RecType : _ =>
270271 cls.paramGetters.foldLeft(tp): (core, getter) =>
271272 if atPhase(thisPhase.next)(getter.hasTrackedParts)
272273 && getter.isRefiningParamAccessor
0 commit comments