File tree 2 files changed +13
-4
lines changed 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -509,7 +509,7 @@ class TypeApplications(val self: Type) extends AnyVal {
509
509
* { type $hkArg$0 = T1; ...; type $hkArg$n = Tn }
510
510
*
511
511
* satisfies predicate `p`. Try base types in the order of their occurrence in `baseClasses`.
512
- * A type parameter matches a varianve V if it has V as its variance or if V == 0.
512
+ * A type parameter matches a variance V if it has V as its variance or if V == 0.
513
513
*/
514
514
def testLifted (tparams : List [Symbol ], p : Type => Boolean )(implicit ctx : Context ): Boolean = {
515
515
def tryLift (bcs : List [ClassSymbol ]): Boolean = bcs match {
@@ -534,7 +534,7 @@ class TypeApplications(val self: Type) extends AnyVal {
534
534
false
535
535
}
536
536
if (tparams.isEmpty) false
537
- else if (typeParams.nonEmpty) p(EtaExpand )
537
+ else if (typeParams.nonEmpty) p(EtaExpand ) || tryLift(self.baseClasses)
538
538
else tryLift(self.baseClasses)
539
539
}
540
540
}
Original file line number Diff line number Diff line change @@ -28,9 +28,18 @@ trait TypeAssigner {
28
28
}
29
29
}
30
30
31
- def avoid (tp : Type , syms : => List [Symbol ])(implicit ctx : Context ): Type = {
31
+ /** An upper approximation of the given type `tp` that does not refer to any symbol in `symsToAvoid`.
32
+ * Approximation steps are:
33
+ *
34
+ * - follow aliases if the original refers to a forbidden symbol
35
+ * - widen termrefs that refer to a forbidden symbol
36
+ * - replace ClassInfos of forbidden classes by the intersection of their parents, refined by all
37
+ * non-private fields, methods, and type members.
38
+ * - drop refinements referring to a forbidden symbol.
39
+ */
40
+ def avoid (tp : Type , symsToAvoid : => List [Symbol ])(implicit ctx : Context ): Type = {
32
41
val widenMap = new TypeMap {
33
- lazy val forbidden = syms .toSet
42
+ lazy val forbidden = symsToAvoid .toSet
34
43
def toAvoid (tp : Type ): Boolean = tp match {
35
44
case tp : TermRef =>
36
45
val sym = tp.symbol
You can’t perform that action at this time.
0 commit comments