Skip to content
Next Next commit
Use .zipped.forall instead zip_zip_forall
  • Loading branch information
OlivierBlanvillain committed Apr 29, 2019
commit df1bf4d3fd2e80de4bdda120c3426511e3f2435b
22 changes: 4 additions & 18 deletions compiler/src/dotty/tools/dotc/core/TypeComparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1945,19 +1945,6 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] {
true
}
case (AppliedType(tycon1, args1), AppliedType(tycon2, args2)) if tycon1 == tycon2 =>
// Unboxed xs.zip(ys).zip(zs).forall { case ((a, b), c) => f(a, b, c) }
def zip_zip_forall[A, B, C](xs: List[A], ys: List[B], zs: List[C])(f: (A, B, C) => Boolean): Boolean = {
xs match {
case x :: xs => ys match {
case y :: ys => zs match {
case z :: zs => f(x, y, z) && zip_zip_forall(xs, ys, zs)(f)
case _ => true
}
case _ => true
}
case _ => true
}
}
def covariantIntersecting(tp1: Type, tp2: Type, tparam: TypeParamInfo): Boolean = {
intersecting(tp1, tp2) || {
// We still need to proof that `Nothing` is not a valid
Expand All @@ -1981,7 +1968,7 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] {
}
}

zip_zip_forall(args1, args2, tycon1.typeParams) {
(args1, args2, tycon1.typeParams).zipped.forall {
(arg1, arg2, tparam) =>
val v = tparam.paramVariance
if (v > 0)
Expand All @@ -1994,7 +1981,7 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] {
covariantIntersecting(arg1, arg2, tparam) && (isSameType(arg1, arg2) || {
// We can only trust a "no" from `isSameType` when both
// `arg1` and `arg2` are fully instantiated.
val fullyInstantiated = new TypeAccumulator[Boolean] {
def fullyInstantiated(tp: Type): Boolean = new TypeAccumulator[Boolean] {
override def apply(x: Boolean, t: Type) =
x && {
t match {
Expand All @@ -2003,9 +1990,8 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] {
case _ => foldOver(x, t)
}
}
}
!(fullyInstantiated.apply(true, arg1) &&
fullyInstantiated.apply(true, arg2))
}.apply(true, tp)
!(fullyInstantiated(arg1) && fullyInstantiated(arg2))
})
}
case (tp1: HKLambda, tp2: HKLambda) =>
Expand Down
2 changes: 1 addition & 1 deletion library/src-3.x/scala/compiletime/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ package object compiletime {
inline def constValue[T]: T = ???

type S[X <: Int] <: Int
}
}
2 changes: 1 addition & 1 deletion tests/run/tuples1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@ object Test extends App {
val us0: 0 = size(())
val x3s1: 3 = size0(x3)
val us1: 0 = size0(())
}
}