@@ -2527,6 +2527,11 @@ object Types {
2527
2527
case _ : MethodType => true
2528
2528
case _ => false
2529
2529
}
2530
+
2531
+ /** Is this polytype a higher-kinded type lambda as opposed to a polymorphic?
2532
+ * method type? Only type lambdas get created with variances, that's how we can tell.
2533
+ */
2534
+ def isTypeLambda : Boolean = variances.nonEmpty
2530
2535
2531
2536
/** PolyParam references to all type parameters of this type */
2532
2537
lazy val paramRefs : List [PolyParam ] = paramNames.indices.toList.map(PolyParam (this , _))
@@ -2914,9 +2919,15 @@ object Types {
2914
2919
def instantiate (fromBelow : Boolean )(implicit ctx : Context ): Type = {
2915
2920
val inst = ctx.typeComparer.instanceType(origin, fromBelow)
2916
2921
if (ctx.typerState.isGlobalCommittable)
2917
- assert(! inst.isInstanceOf [PolyParam ], i " bad inst $this := $inst, constr = ${ctx.typerState.constraint}" )
2918
- // If this fails, you might want to turn on Config.debugCheckConstraintsClosed
2919
- // to help find the root of the problem.
2922
+ inst match {
2923
+ case inst : PolyParam =>
2924
+ assert(inst.binder.isTypeLambda, i " bad inst $this := $inst, constr = ${ctx.typerState.constraint}" )
2925
+ // If this fails, you might want to turn on Config.debugCheckConstraintsClosed
2926
+ // to help find the root of the problem.
2927
+ // Note: Parameters of type lambdas are excluded from the assertion because
2928
+ // they might arise from ill-kinded code. See #1652
2929
+ case _ =>
2930
+ }
2920
2931
instantiateWith(inst)
2921
2932
}
2922
2933
0 commit comments