From 9b17c6c86f3150afa7b5b395c23ec3fdf9c14200 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 21 Mar 2014 18:39:35 +0100 Subject: Fix of Fix of t1236: higher-kinded Fix of d6df293d2120f2247198cb6646a23c338f7dcbbf. It turned out the original commit was faulty in that iterator.flatten did not typecheck. The problem is fixed in this commit and flatten is added to the collections test. --- src/dotty/tools/dotc/core/TypeComparer.scala | 6 +++--- src/dotty/tools/dotc/core/Types.scala | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala index d66d4069c..ce1c1e869 100644 --- a/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/src/dotty/tools/dotc/core/TypeComparer.scala @@ -649,13 +649,13 @@ class TypeComparer(initctx: Context) extends DotClass { val base = tp1.narrow tparams.map(base.memberInfo) } - val hkArgs = tp2.argInfos - hk.println(s"isSubTypeHK: args1 = $args1, hkargs = $hkArgs") - val boundsOK = (args1 corresponds hkArgs)(isSubType) + val hkBounds = tp2.argInfos.map(_.asInstanceOf[TypeBounds]) + val boundsOK = (hkBounds corresponds args1)(_ contains _) val variancesOK = argInfos1.nonEmpty || (tparams corresponds tp2.typeSymbol.name.hkVariances) { (tparam, v) => v == 0 || tparam.variance == v } + hk.println(s"isSubTypeHK: args1 = $args1, hk-bounds = $hkBounds $boundsOK $variancesOK") boundsOK && variancesOK } diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index e9c3c56b2..7cd66f5dd 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -1926,7 +1926,10 @@ object Types { if (lo eq tp) this else TypeAlias(tp, variance) - def contains(tp: Type)(implicit ctx: Context) = lo <:< tp && tp <:< hi + def contains(tp: Type)(implicit ctx: Context) = tp match { + case tp: TypeBounds => lo <:< tp.lo && tp.hi <:< hi + case _ => lo <:< tp && tp <:< hi + } def & (that: TypeBounds)(implicit ctx: Context): TypeBounds = { val v = this commonVariance that -- cgit v1.2.3