@@ -95,19 +95,21 @@ 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
107
108
&& symd.is(Private )
108
109
&& symd.owner.is(CaptureChecked )
109
110
&& containsCovarRetains(symd.symbol.originDenotation.info)
110
- then symd.flags &~ Private
111
+ then
112
+ symd.flags &~ Private
111
113
else symd.flags
112
114
end newFlagsFor
113
115
@@ -270,6 +272,8 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
270
272
def mapInferred (refine : Boolean ): TypeMap = new TypeMap with SetupTypeMap :
271
273
override def toString = " map inferred"
272
274
275
+ var refiningNames : Set [Name ] = Set ()
276
+
273
277
/** Refine a possibly applied class type C where the class has tracked parameters
274
278
* 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
279
* where CV_1, ..., CV_n are fresh capture set variables.
@@ -282,7 +286,7 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
282
286
cls.paramGetters.foldLeft(tp) { (core, getter) =>
283
287
if atPhase(thisPhase.next)(getter.hasTrackedParts)
284
288
&& getter.isRefiningParamAccessor
285
- && ! getter.is( Tracked )
289
+ && ! refiningNames.contains(getter.name) // Don't add a refinement if we have already an explicit one for the same name
286
290
then
287
291
val getterType =
288
292
mapInferred(refine = false )(tp.memberInfo(getter)).strippedDealias
@@ -306,6 +310,11 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
306
310
tp.derivedLambdaType(
307
311
paramInfos = tp.paramInfos.mapConserve(_.dropAllRetains.bounds),
308
312
resType = this (tp.resType))
313
+ case tp @ RefinedType (parent, rname, rinfo) =>
314
+ val saved = refiningNames
315
+ refiningNames += rname
316
+ val parent1 = try this (parent) finally refiningNames = saved
317
+ tp.derivedRefinedType(parent1, rname, this (rinfo))
309
318
case _ =>
310
319
mapFollowingAliases(tp)
311
320
addVar(
0 commit comments