aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/core/Types.scala14
-rw-r--r--tests/pos/i1652.scala5
2 files changed, 16 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index 38913a7d0..b67ff8141 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -2527,6 +2527,8 @@ object Types {
case _: MethodType => true
case _ => false
}
+
+ 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 +2916,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)
}
diff --git a/tests/pos/i1652.scala b/tests/pos/i1652.scala
new file mode 100644
index 000000000..a48b500fa
--- /dev/null
+++ b/tests/pos/i1652.scala
@@ -0,0 +1,5 @@
+object Test {
+ val v: Array[Array[Array]] = Array() // happens because of the kindedness error here.
+ def f[T](w: Array[Array[T]]) = { for (r <- w) () }
+ f(v)
+}