diff options
author | Martin Odersky <odersky@gmail.com> | 2016-06-22 09:49:03 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-07-11 13:35:04 +0200 |
commit | e0db04db51bc17d311b95a6f65913d138a955b6c (patch) | |
tree | 47b597ce6618055c8cda4beb0fce52ba29ae9bbd /src/dotty/tools/dotc/core/TypeComparer.scala | |
parent | 960ea75c97e69ae65e2c6df2aa8dd266b0b09e50 (diff) | |
download | dotty-e0db04db51bc17d311b95a6f65913d138a955b6c.tar.gz dotty-e0db04db51bc17d311b95a6f65913d138a955b6c.tar.bz2 dotty-e0db04db51bc17d311b95a6f65913d138a955b6c.zip |
Drop bounds checking for type lambdas
Diffstat (limited to 'src/dotty/tools/dotc/core/TypeComparer.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/TypeComparer.scala | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala index 58d286951..12e9e638a 100644 --- a/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/src/dotty/tools/dotc/core/TypeComparer.scala @@ -394,11 +394,19 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling { case tp2 @ TypeLambda(tparams2, body2) => def compareHkLambda = tp1.stripTypeVar match { case tp1 @ TypeLambda(tparams1, body1) => - val boundsConform = - tparams1.corresponds(tparams2)((tparam1, tparam2) => - isSubType(tparam2.memberBounds.subst(tp2, tp1), tparam1.memberBounds)) - val bodiesConform = isSubType(body1, body2.subst(tp2, tp1)) - variancesConform(tparams1, tparams2) && boundsConform && bodiesConform + // Don't compare bounds of lambdas, or t2994 will fail + // The issue is that, logically, bounds should compare contravariantly, + // so the bounds checking should look like this: + // + // tparams1.corresponds(tparams2)((tparam1, tparam2) => + // isSubType(tparam2.memberBounds.subst(tp2, tp1), tparam1.memberBounds)) + // + // But that would invalidate a pattern such as + // `[X0 <: Number] -> Number <:< [X0] -> Any` + // This wpuld mean that there is no convenient means anymore to express a kind + // as a supertype. The fix is to delay the checking of bounds so that only + // bounds of * types are checked. + variancesConform(tparams1, tparams2) && isSubType(body1, body2.subst(tp2, tp1)) case _ => fourthTry(tp1, tp2) } |