@@ -1891,10 +1891,10 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] {
18911891 def intersecting (tp1 : Type , tp2 : Type )(implicit ctx : Context ): Boolean = {
18921892 // println(s"intersecting(${tp1.show}, ${tp2.show})")
18931893 /** Can we enumerate all instantiations of this type? */
1894- def isClosed (tp : Symbol ): Boolean =
1894+ def isClosedSum (tp : Symbol ): Boolean =
18951895 tp.is(Sealed ) && tp.is(AbstractOrTrait ) && ! tp.hasAnonymousChild
18961896
1897- /** Splits a close type into a disjunction of smaller types.
1897+ /** Splits a closed type into a disjunction of smaller types.
18981898 * It should hold that `tp` and `decompose(tp).reduce(_ or _)`
18991899 * denote the same set of values.
19001900 */
@@ -1919,19 +1919,19 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] {
19191919 // subtype, so they must be unrelated by single inheritance
19201920 // of classes.
19211921 false
1922- else if (isClosed (cls1))
1922+ else if (isClosedSum (cls1))
19231923 decompose(cls1, tp1).exists(x => intersecting(x, tp2))
1924- else if (isClosed (cls2))
1924+ else if (isClosedSum (cls2))
19251925 decompose(cls2, tp2).exists(x => intersecting(x, tp1))
19261926 else
19271927 true
19281928 }
19291929 case (AppliedType (tycon1, args1), AppliedType (tycon2, args2)) if tycon1 == tycon2 =>
1930- // Unboxed x .zip(y ).zip(z ).forall { case ((a, b), c) => f(a, b, c) }
1931- def zip_zip_forall [A , B , C ](x : List [A ], y : List [B ], z : List [C ])(f : (A , B , C ) => Boolean ): Boolean =
1932- x match {
1933- case x :: xs => y match {
1934- case y :: ys => z match {
1930+ // Unboxed xs .zip(ys ).zip(zs ).forall { case ((a, b), c) => f(a, b, c) }
1931+ def zip_zip_forall [A , B , C ](xs : List [A ], ys : List [B ], zs : List [C ])(f : (A , B , C ) => Boolean ): Boolean =
1932+ xs match {
1933+ case x :: xs => ys match {
1934+ case y :: ys => zs match {
19351935 case z :: zs => f(x, y, z) && zip_zip_forall(xs, ys, zs)(f)
19361936 case _ => true
19371937 }
@@ -1943,9 +1943,6 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] {
19431943 zip_zip_forall(args1, args2, tycon1.typeParams) {
19441944 (arg1, arg2, tparam) =>
19451945 val v = tparam.paramVariance
1946- // Note that the logic below is conservative in that is
1947- // assumes that Covariant type parameters are Contravariant
1948- // type
19491946 if (v > 0 )
19501947 intersecting(arg1, arg2) || {
19511948 // We still need to proof that `Nothing` is not a valid
@@ -1979,7 +1976,7 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] {
19791976 override def apply (x : Boolean , t : Type ) =
19801977 x && {
19811978 t match {
1982- case tp : TypeRef if tp.symbol.is( TypeParam ) => false
1979+ case tp : TypeRef if tp.symbol.isAbstractOrParamType => false
19831980 case _ : SkolemType | _ : TypeVar | _ : TypeParamRef => false
19841981 case _ => foldOver(x, t)
19851982 }
0 commit comments