@@ -95,12 +95,13 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
95
95
def apply (x : Boolean , tp : Type ): Boolean =
96
96
if x then true
97
97
else if tp.derivesFromCapability && variance >= 0 then true
98
- else tp match
98
+ else tp.dealiasKeepAnnots match
99
99
case AnnotatedType (_, ann) if ann.symbol.isRetains && variance >= 0 => true
100
100
case t : TypeRef if t.symbol.isAbstractOrParamType && ! seen.contains(t.symbol) =>
101
101
seen += t.symbol
102
102
apply(x, t.info.bounds.hi)
103
- case _ => foldOver(x, tp)
103
+ case tp1 =>
104
+ foldOver(x, tp1)
104
105
def apply (tp : Type ): Boolean = apply(false , tp)
105
106
106
107
if symd.symbol.isRefiningParamAccessor
@@ -270,6 +271,8 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
270
271
def mapInferred (refine : Boolean ): TypeMap = new TypeMap with SetupTypeMap :
271
272
override def toString = " map inferred"
272
273
274
+ var refiningNames : Set [Name ] = Set ()
275
+
273
276
/** Refine a possibly applied class type C where the class has tracked parameters
274
277
* x_1: T_1, ..., x_n: T_n to C { val x_1: T_1^{CV_1}, ..., val x_n: T_n^{CV_n} }
275
278
* where CV_1, ..., CV_n are fresh capture set variables.
@@ -282,7 +285,7 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
282
285
cls.paramGetters.foldLeft(tp) { (core, getter) =>
283
286
if atPhase(thisPhase.next)(getter.hasTrackedParts)
284
287
&& getter.isRefiningParamAccessor
285
- && ! getter.is( Tracked )
288
+ && ! refiningNames.contains(getter.name) // Don't add a refinement if we have already an explicit one for the same name
286
289
then
287
290
val getterType =
288
291
mapInferred(refine = false )(tp.memberInfo(getter)).strippedDealias
@@ -306,6 +309,11 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
306
309
tp.derivedLambdaType(
307
310
paramInfos = tp.paramInfos.mapConserve(_.dropAllRetains.bounds),
308
311
resType = this (tp.resType))
312
+ case tp @ RefinedType (parent, rname, rinfo) =>
313
+ val saved = refiningNames
314
+ refiningNames += rname
315
+ val parent1 = try this (parent) finally refiningNames = saved
316
+ tp.derivedRefinedType(parent1, rname, this (rinfo))
309
317
case _ =>
310
318
mapFollowingAliases(tp)
311
319
addVar(
0 commit comments