aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core
diff options
context:
space:
mode:
authorodersky <odersky@gmail.com>2016-11-04 10:18:23 +0100
committerGitHub <noreply@github.com>2016-11-04 10:18:23 +0100
commit0665c4f5accae915afd8abc57ed19f6d57e2cc08 (patch)
tree9c52f57ca89fd6b2f23e4f56afa376a064d1c777 /src/dotty/tools/dotc/core
parent6ba6ea542d7915a48b426fea1f75f9cb8c2db424 (diff)
parent372140c7acc46a690f7b7538114f425afdc07e4f (diff)
downloaddotty-0665c4f5accae915afd8abc57ed19f6d57e2cc08.tar.gz
dotty-0665c4f5accae915afd8abc57ed19f6d57e2cc08.tar.bz2
dotty-0665c4f5accae915afd8abc57ed19f6d57e2cc08.zip
Merge pull request #1656 from dotty-staging/fix-#1652
Fix #1652: Make assertion more robust
Diffstat (limited to 'src/dotty/tools/dotc/core')
-rw-r--r--src/dotty/tools/dotc/core/Types.scala17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index 38913a7d0..8b27db05d 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -2527,6 +2527,11 @@ object Types {
case _: MethodType => true
case _ => false
}
+
+ /** Is this polytype a higher-kinded type lambda as opposed to a polymorphic?
+ * method type? Only type lambdas get created with variances, that's how we can tell.
+ */
+ def isTypeLambda: Boolean = variances.nonEmpty
/** PolyParam references to all type parameters of this type */
lazy val paramRefs: List[PolyParam] = paramNames.indices.toList.map(PolyParam(this, _))
@@ -2914,9 +2919,15 @@ object Types {
def instantiate(fromBelow: Boolean)(implicit ctx: Context): Type = {
val inst = ctx.typeComparer.instanceType(origin, fromBelow)
if (ctx.typerState.isGlobalCommittable)
- assert(!inst.isInstanceOf[PolyParam], i"bad inst $this := $inst, constr = ${ctx.typerState.constraint}")
- // If this fails, you might want to turn on Config.debugCheckConstraintsClosed
- // to help find the root of the problem.
+ inst match {
+ case inst: PolyParam =>
+ assert(inst.binder.isTypeLambda, i"bad inst $this := $inst, constr = ${ctx.typerState.constraint}")
+ // If this fails, you might want to turn on Config.debugCheckConstraintsClosed
+ // to help find the root of the problem.
+ // Note: Parameters of type lambdas are excluded from the assertion because
+ // they might arise from ill-kinded code. See #1652
+ case _ =>
+ }
instantiateWith(inst)
}