aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/TypeComparer.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-07-22 15:22:13 +0200
committerMartin Odersky <odersky@gmail.com>2016-07-22 15:22:13 +0200
commit013101d9f77d8283007911c61aaae7ac9cc2d486 (patch)
treeca3895373443d42008a31d505fdab66fd10b578d /src/dotty/tools/dotc/core/TypeComparer.scala
parent5968e9f6154cc8642fc3f6cef636a12104dd7a26 (diff)
downloaddotty-013101d9f77d8283007911c61aaae7ac9cc2d486.tar.gz
dotty-013101d9f77d8283007911c61aaae7ac9cc2d486.tar.bz2
dotty-013101d9f77d8283007911c61aaae7ac9cc2d486.zip
Take curried type lambdas into account
Adapt operations TypeApplications and TypeComparer to account for the possibilities of curried type lambdas.
Diffstat (limited to 'src/dotty/tools/dotc/core/TypeComparer.scala')
-rw-r--r--src/dotty/tools/dotc/core/TypeComparer.scala19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala
index e984970b4..18eb424bc 100644
--- a/src/dotty/tools/dotc/core/TypeComparer.scala
+++ b/src/dotty/tools/dotc/core/TypeComparer.scala
@@ -665,6 +665,13 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
}
}
+ /** Fall back to comparing either with `fourthTry` or against the lower
+ * approximation of the rhs.
+ * @param tyconLo The type constructor's lower approximation.
+ */
+ def fallback(tyconLo: Type) =
+ either(fourthTry(tp1, tp2), isSubType(tp1, tyconLo.applyIfParameterized(args2)))
+
/** Let `tycon2bounds` be the bounds of the RHS type constructor `tycon2`.
* Let `app2 = tp2` where the type constructor of `tp2` is replaced by
* `tycon2bounds.lo`.
@@ -674,13 +681,13 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
* tp1 <:< tp2 using fourthTry (this might instantiate params in tp1)
* tp1 <:< app2 using isSubType (this might instantiate params in tp2)
*/
- def compareLower(tycon2bounds: TypeBounds, tyconIsTypeRef: Boolean): Boolean = {
- def app2 = tycon2bounds.lo.applyIfParameterized(args2)
+ def compareLower(tycon2bounds: TypeBounds, tyconIsTypeRef: Boolean): Boolean =
if (tycon2bounds.lo eq tycon2bounds.hi)
- isSubType(tp1, if (tyconIsTypeRef) tp2.superType else app2)
+ isSubType(tp1,
+ if (tyconIsTypeRef) tp2.superType
+ else tycon2bounds.lo.applyIfParameterized(args2))
else
- either(fourthTry(tp1, tp2), isSubType(tp1, app2))
- }
+ fallback(tycon2bounds.lo)
tycon2 match {
case param2: PolyParam =>
@@ -693,6 +700,8 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
compareLower(tycon2.info.bounds, tyconIsTypeRef = true)
case _: TypeVar | _: AnnotatedType =>
isSubType(tp1, tp2.superType)
+ case tycon2: HKApply =>
+ fallback(tycon2.lowerBound)
case _ =>
false
}