@@ -2478,19 +2478,31 @@ object Types {
2478
2478
case _ : ExprType => tp
2479
2479
case _ => AnnotatedType (tp, Annotation (defn.InlineParamAnnot ))
2480
2480
}
2481
+ def integrate (tp : Type , mt : MethodType ) =
2482
+ tp.subst(params, (0 until params.length).toList.map(MethodParam (mt, _)))
2481
2483
def paramInfo (param : Symbol ): Type = {
2482
2484
val paramType = translateRepeated(param.info)
2483
2485
if (param.is(Inline )) translateInline(paramType) else paramType
2484
2486
}
2485
- def transformResult (mt : MethodType ) =
2486
- resultType.subst(params, (0 until params.length).toList map (MethodParam (mt, _)))
2487
- apply(params map (_.name.asTermName), params map paramInfo)(transformResult _)
2487
+ apply(params.map(_.name.asTermName))(
2488
+ mt => params.map(param => integrate(paramInfo(param), mt)),
2489
+ mt => integrate(resultType, mt))
2490
+ }
2491
+
2492
+ def checkValid (mt : MethodType )(implicit ctx : Context ): mt.type = {
2493
+ if (Config .checkMethodTypes)
2494
+ for ((paramType, idx) <- mt.paramTypes.zipWithIndex)
2495
+ paramType.foreachPart {
2496
+ case MethodParam (`mt`, j) => assert(j < idx, mt)
2497
+ case _ =>
2498
+ }
2499
+ mt
2488
2500
}
2489
2501
}
2490
2502
2491
2503
object MethodType extends MethodTypeCompanion {
2492
2504
def apply (paramNames : List [TermName ])(paramTypesExp : MethodType => List [Type ], resultTypeExp : MethodType => Type )(implicit ctx : Context ): MethodType =
2493
- unique(new CachedMethodType (paramNames)(paramTypesExp, resultTypeExp))
2505
+ checkValid( unique(new CachedMethodType (paramNames)(paramTypesExp, resultTypeExp) ))
2494
2506
2495
2507
private type DependencyStatus = Byte
2496
2508
private final val Unknown : DependencyStatus = 0 // not yet computed
@@ -2508,7 +2520,7 @@ object Types {
2508
2520
2509
2521
object ImplicitMethodType extends MethodTypeCompanion {
2510
2522
def apply (paramNames : List [TermName ])(paramTypesExp : MethodType => List [Type ], resultTypeExp : MethodType => Type )(implicit ctx : Context ): MethodType =
2511
- unique(new ImplicitMethodType (paramNames)(paramTypesExp, resultTypeExp))
2523
+ checkValid( unique(new ImplicitMethodType (paramNames)(paramTypesExp, resultTypeExp) ))
2512
2524
}
2513
2525
2514
2526
/** A ternary extractor for MethodType */
0 commit comments