@@ -1891,10 +1891,10 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] {
1891
1891
def intersecting (tp1 : Type , tp2 : Type )(implicit ctx : Context ): Boolean = {
1892
1892
// println(s"intersecting(${tp1.show}, ${tp2.show})")
1893
1893
/** Can we enumerate all instantiations of this type? */
1894
- def isClosed (tp : Symbol ): Boolean =
1894
+ def isClosedSum (tp : Symbol ): Boolean =
1895
1895
tp.is(Sealed ) && tp.is(AbstractOrTrait ) && ! tp.hasAnonymousChild
1896
1896
1897
- /** Splits a close type into a disjunction of smaller types.
1897
+ /** Splits a closed type into a disjunction of smaller types.
1898
1898
* It should hold that `tp` and `decompose(tp).reduce(_ or _)`
1899
1899
* denote the same set of values.
1900
1900
*/
@@ -1919,19 +1919,19 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] {
1919
1919
// subtype, so they must be unrelated by single inheritance
1920
1920
// of classes.
1921
1921
false
1922
- else if (isClosed (cls1))
1922
+ else if (isClosedSum (cls1))
1923
1923
decompose(cls1, tp1).exists(x => intersecting(x, tp2))
1924
- else if (isClosed (cls2))
1924
+ else if (isClosedSum (cls2))
1925
1925
decompose(cls2, tp2).exists(x => intersecting(x, tp1))
1926
1926
else
1927
1927
true
1928
1928
}
1929
1929
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 {
1935
1935
case z :: zs => f(x, y, z) && zip_zip_forall(xs, ys, zs)(f)
1936
1936
case _ => true
1937
1937
}
@@ -1943,9 +1943,6 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] {
1943
1943
zip_zip_forall(args1, args2, tycon1.typeParams) {
1944
1944
(arg1, arg2, tparam) =>
1945
1945
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
1949
1946
if (v > 0 )
1950
1947
intersecting(arg1, arg2) || {
1951
1948
// We still need to proof that `Nothing` is not a valid
@@ -1979,7 +1976,7 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] {
1979
1976
override def apply (x : Boolean , t : Type ) =
1980
1977
x && {
1981
1978
t match {
1982
- case tp : TypeRef if tp.symbol.is( TypeParam ) => false
1979
+ case tp : TypeRef if tp.symbol.isAbstractOrParamType => false
1983
1980
case _ : SkolemType | _ : TypeVar | _ : TypeParamRef => false
1984
1981
case _ => foldOver(x, t)
1985
1982
}
0 commit comments