aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/Types.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-11-03 19:19:34 +0100
committerMartin Odersky <odersky@gmail.com>2016-11-03 19:19:43 +0100
commitba8c4c8a592e9070b5a7c1d887daed16e11d732d (patch)
treefbfccd5323f626628416883c4299a20ab4ed0570 /src/dotty/tools/dotc/core/Types.scala
parent98a92c6f4ec743edb9465071dcfd43f17dbf054b (diff)
downloaddotty-ba8c4c8a592e9070b5a7c1d887daed16e11d732d.tar.gz
dotty-ba8c4c8a592e9070b5a7c1d887daed16e11d732d.tar.bz2
dotty-ba8c4c8a592e9070b5a7c1d887daed16e11d732d.zip
Fix #1652: Make assertion more robust
An assertion fired giving a false negative after a fuzzing test which introduced an ill-kinded type argument.
Diffstat (limited to 'src/dotty/tools/dotc/core/Types.scala')
-rw-r--r--src/dotty/tools/dotc/core/Types.scala14
1 files changed, 11 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)
}