@@ -300,8 +300,8 @@ trait ConstraintHandling[AbstractContext] {
300
300
* (i.e. `inst.widenSingletons <:< bound` succeeds with satisfiable constraint)
301
301
* 2. If `inst` is a union type, approximate the union type from above by an intersection
302
302
* of all common base types, provided the result is a subtype of `bound`.
303
- * 3. (currently not enabled) If `inst` is an intersection with some protected base types, drop
304
- * the protected base types from the intersection, provided the result is a subtype of `bound`.
303
+ * 3. (currently not enabled) If `inst` is an intersection with some restricted base types, drop
304
+ * the restricted base types from the intersection, provided the result is a subtype of `bound`.
305
305
*
306
306
* Don't do these widenings if `bound` is a subtype of `scala.Singleton`.
307
307
* Also, if the result of these widenings is a TypeRef to a module class,
@@ -313,18 +313,20 @@ trait ConstraintHandling[AbstractContext] {
313
313
*/
314
314
def widenInferred (inst : Type , bound : Type )(implicit actx : AbstractContext ): Type =
315
315
316
- def isProtected (tp : Type ) = tp.typeSymbol == defn.EnumValueClass // for now, to be generalized later
316
+ def isRestricted (tp : Type ) = tp.typeSymbol == defn.EnumValueClass // for now, to be generalized later
317
317
318
- def dropProtected (tp : Type ): Type = tp.dealias match
319
- case tp @ AndType (tp1, tp2) =>
320
- if isProtected(tp1) then tp2
321
- else if isProtected(tp2) then tp1
322
- else tp.derivedAndType(dropProtected(tp1), dropProtected(tp2))
318
+ def dropRestricted (tp : Type ): Type = tp.dealias match
319
+ case tpd @ AndType (tp1, tp2) =>
320
+ if isRestricted(tp1) then tp2
321
+ else if isRestricted(tp2) then tp1
322
+ else
323
+ val tpw = tpd.derivedAndType(dropRestricted(tp1), dropRestricted(tp2))
324
+ if tpw ne tpd then tpw else tp
323
325
case _ =>
324
326
tp
325
327
326
- def widenProtected (tp : Type ) =
327
- val tpw = dropProtected (tp)
328
+ def widenRestricted (tp : Type ) =
329
+ val tpw = dropRestricted (tp)
328
330
if (tpw ne tp) && (tpw <:< bound) then tpw else tp
329
331
330
332
def widenOr (tp : Type ) =
@@ -341,8 +343,8 @@ trait ConstraintHandling[AbstractContext] {
341
343
342
344
val wideInst =
343
345
if isSingleton(bound) then inst
344
- else /* widenProtected */ (widenOr(widenSingle(inst)))
345
- // widenProtected is currently not called since it's special cased in `dropEnumValue`
346
+ else /* widenRestricted */ (widenOr(widenSingle(inst)))
347
+ // widenRestricted is currently not called since it's special cased in `dropEnumValue`
346
348
// in `Namer`. It's left in here in case we want to generalize the scheme to other
347
349
// "protected inheritance" classes.
348
350
wideInst match
0 commit comments