diff options
author | Martin Odersky <odersky@gmail.com> | 2016-10-01 21:48:34 +0200 |
---|---|---|
committer | Guillaume Martres <smarter@ubuntu.com> | 2016-10-11 19:21:02 +0200 |
commit | d47f3280a7d46fa5e65ebfc986ed04b7b739aae2 (patch) | |
tree | b9cde01f8f498313138a6260daca76c8fae2396a /src | |
parent | 98a69d90b16f0cc997255f097d3d5d9f2a60301b (diff) | |
download | dotty-d47f3280a7d46fa5e65ebfc986ed04b7b739aae2.tar.gz dotty-d47f3280a7d46fa5e65ebfc986ed04b7b739aae2.tar.bz2 dotty-d47f3280a7d46fa5e65ebfc986ed04b7b739aae2.zip |
Handle feature interaction between subtyping or types and hk types
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/core/TypeComparer.scala | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala index 991dd2664..0a51b896a 100644 --- a/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/src/dotty/tools/dotc/core/TypeComparer.scala @@ -324,8 +324,18 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling { case AndType(tp11, tp12) => if (tp11.stripTypeVar eq tp12.stripTypeVar) isSubType(tp11, tp2) else thirdTry(tp1, tp2) - case OrType(tp11, tp12) => - isSubType(tp11, tp2) && isSubType(tp12, tp2) + case tp1 @ OrType(tp11, tp12) => + def joinOK = tp2.dealias match { + case tp12: HKApply => + // If we apply the default algorithm for `A[X] | B[Y] <: C[Z]` where `C` is a + // type parameter, we will instantiate `C` to `A` and then fail when comparing + // with `B[Y]`. To do the right thing, we need to instantiate `C` to the + // common superclass of `A` and `B`. + isSubType(tp1.join, tp2) + case _ => + false + } + joinOK || isSubType(tp11, tp2) && isSubType(tp12, tp2) case ErrorType => true case _ => |