aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-07-20 18:12:04 +0200
committerMartin Odersky <odersky@gmail.com>2015-09-18 18:12:16 +0200
commit4aa1d5e1d9e4edfc1df6161504861840b24687ae (patch)
tree2bb6a57e65a8f69d490a52a7c2b80cc649afb294
parentab6e5cebebe8c59901413f89281073d6eec7f8e1 (diff)
downloaddotty-4aa1d5e1d9e4edfc1df6161504861840b24687ae.tar.gz
dotty-4aa1d5e1d9e4edfc1df6161504861840b24687ae.tar.bz2
dotty-4aa1d5e1d9e4edfc1df6161504861840b24687ae.zip
Fix problem in typeParams
Accidentally forwarded to rawTypeParams. This solved the problem with mismatching type params in appliedTo that was caught in testLifted.
-rw-r--r--src/dotty/tools/dotc/core/TypeApplications.scala19
-rw-r--r--src/dotty/tools/dotc/core/TypeComparer.scala2
2 files changed, 8 insertions, 13 deletions
diff --git a/src/dotty/tools/dotc/core/TypeApplications.scala b/src/dotty/tools/dotc/core/TypeApplications.scala
index 18256b9e4..062867353 100644
--- a/src/dotty/tools/dotc/core/TypeApplications.scala
+++ b/src/dotty/tools/dotc/core/TypeApplications.scala
@@ -60,7 +60,7 @@ class TypeApplications(val self: Type) extends AnyVal {
case tp: TypeRef =>
val tsym = tp.typeSymbol
if (tsym.isClass) tsym.typeParams
- else if (tsym.isAliasType) tp.underlying.rawTypeParams
+ else if (tsym.isAliasType) tp.underlying.typeParams
else {
val lam = LambdaClass(forcing = false)
if (lam.exists) lam.typeParams else Nil
@@ -525,12 +525,12 @@ class TypeApplications(val self: Type) extends AnyVal {
}
}
- /** Test whether this type has a base type of the form `B[T1, ..., Bn]` where
+ /** Test whether this type has a base type of the form `B[T1, ..., Tn]` where
* the type parameters of `B` match one-by-one the variances of `tparams`,
* and where the lambda abstracted type
*
- * LambdaXYZ { type Apply = B[$hkArg$0, ..., $hkArg$n] }
- * { type $hkArg$0 = T1; ...; type $hkArg$n = Tn }
+ * LambdaXYZ { type Apply = B[$hkArg$0, ..., $hkArg${n-1}] }
+ * { type $hkArg$0 = T1; ...; type $hkArg${n-1} = Tn }
*
* satisfies predicate `p`. Try base types in the order of their occurrence in `baseClasses`.
* A type parameter matches a variance V if it has V as its variance or if V == 0.
@@ -560,13 +560,8 @@ class TypeApplications(val self: Type) extends AnyVal {
case nil =>
false
}
- try { // temporary, to avoid type mismatches in applications. Should come back to this
- // when subtyping is rewritten to account for new hk-scheme.
- if (tparams.isEmpty) false
- else if (typeParams.nonEmpty) p(EtaExpand) || classBounds.nonEmpty && tryLift(self.baseClasses)
- else classBounds.nonEmpty && tryLift(self.baseClasses)
- } catch {
- case ex: NoSuchElementException => false
- }
+ tparams.nonEmpty &&
+ (typeParams.nonEmpty && p(EtaExpand) ||
+ classBounds.nonEmpty && tryLift(self.baseClasses))
}
}
diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala
index 9e86a22a7..eb1dcacdd 100644
--- a/src/dotty/tools/dotc/core/TypeComparer.scala
+++ b/src/dotty/tools/dotc/core/TypeComparer.scala
@@ -634,7 +634,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
// if (tp.isLambda != tp.isHK) println(i"discrepancy for $tp, isLambda = ${tp.isLambda}, isHK = ${tp.isHK}")
val name = target.refinedName
(name.isLambdaArgName || (name eq tpnme.hkApply)) &&
- tp.exists && !tp.isLambda // we do encounter Lambda classes without any arguments here @@@ check whether this makes sense.
+ tp.exists && !tp.isLambda // we do encounter Lambda classes without any arguments here
}
/** Narrow gadt.bounds for the type parameter referenced by `tr` to include