aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-07-20 15:13:07 +0200
committerMartin Odersky <odersky@gmail.com>2015-09-18 18:12:16 +0200
commitab6e5cebebe8c59901413f89281073d6eec7f8e1 (patch)
tree3f3e7545bc371caac18206bbc9f05f5a7407947d
parent38ac02916ec0beef0cb93f0fdd48ad1f9dfdcf48 (diff)
downloaddotty-ab6e5cebebe8c59901413f89281073d6eec7f8e1.tar.gz
dotty-ab6e5cebebe8c59901413f89281073d6eec7f8e1.tar.bz2
dotty-ab6e5cebebe8c59901413f89281073d6eec7f8e1.zip
Rewrite compareHK to be kind-correct
-rw-r--r--src/dotty/tools/dotc/core/TypeApplications.scala6
-rw-r--r--src/dotty/tools/dotc/core/TypeComparer.scala16
2 files changed, 13 insertions, 9 deletions
diff --git a/src/dotty/tools/dotc/core/TypeApplications.scala b/src/dotty/tools/dotc/core/TypeApplications.scala
index 66542d02d..18256b9e4 100644
--- a/src/dotty/tools/dotc/core/TypeApplications.scala
+++ b/src/dotty/tools/dotc/core/TypeApplications.scala
@@ -149,6 +149,12 @@ class TypeApplications(val self: Type) extends AnyVal {
case _ => false
}
+ /** is receiver of the form T#$apply? */
+ def isHKApply: Boolean = self match {
+ case TypeRef(_, name) => name == tpnme.hkApply
+ case _ => false
+ }
+
/** Encode the type resulting from applying this type to given arguments */
final def appliedTo(args: List[Type])(implicit ctx: Context): Type = /*>|>*/ track("appliedTo") /*<|<*/ {
def matchParams(tp: Type, tparams: List[TypeSymbol], args: List[Type]): Type = args match {
diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala
index 35e4d804b..9e86a22a7 100644
--- a/src/dotty/tools/dotc/core/TypeComparer.scala
+++ b/src/dotty/tools/dotc/core/TypeComparer.scala
@@ -466,18 +466,16 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
false
}
- /** If `projection` is of the form T # Apply where `T` is an instance of a Lambda class,
- * and `other` is not a type lambda projection, then convert `other` to a type lambda `U`, and
+ /** If `projection` is a hk projection T#$apply
+ * and `other` is not a hk projection, then convert `other` to a hk projection `U`, and
* continue with `T <:< U` if `inOrder` is true and `U <:< T` otherwise.
*/
def compareHK(projection: NamedType, other: Type, inOrder: Boolean) =
- projection.name == tpnme.hkApply && { // @@@ rewrite
- val lambda = projection.prefix.LambdaClass(forcing = true)
- lambda.exists && !other.isLambda &&
- other.testLifted(lambda.typeParams,
- if (inOrder) isSubType(projection.prefix, _) else isSubType(_, projection.prefix),
- if (inOrder) Nil else classBounds(projection.prefix))
- }
+ projection.name == tpnme.hkApply &&
+ !other.isHKApply &&
+ other.testLifted(projection.prefix.LambdaClass(forcing = true).typeParams,
+ if (inOrder) isSubType(projection.prefix, _) else isSubType(_, projection.prefix),
+ if (inOrder) Nil else classBounds(projection.prefix))
/** The class symbols bounding the type of the `Apply` member of `tp` */
private def classBounds(tp: Type) = tp.member(tpnme.hkApply).info.classSymbols