@@ -503,35 +503,34 @@ object Erasure extends TypeTestsCasts{
503
503
traverse(newStats, oldStats)
504
504
}
505
505
506
- def makeBridgeDef (newDef : tpd.DefDef , parentSym : Symbol )(implicit ctx : Context ): tpd.DefDef = {
507
- val newDefSym = newDef.symbol
508
- val currentClass = newDefSym.owner.asClass
506
+ /** Create a bridge DefDef which overrides a parent method.
507
+ *
508
+ * @param implDef The existing DefDef which needs bridging
509
+ * @param overridenSym A symbol corresponding to a parent method to override
510
+ */
511
+ def makeBridgeDef (implDef : tpd.DefDef , overridenSym : Symbol )(implicit ctx : Context ): tpd.DefDef = {
512
+ val implDefSym = implDef.symbol
513
+ val currentClass = implDefSym.owner.asClass
509
514
510
- def error (reason : String ) = {
511
- assert(false , s " failure creating bridge from ${newDefSym} to ${parentSym}, reason: $reason" )
512
- ???
513
- }
514
515
val bridge = ctx.newSymbol(currentClass,
515
- parentSym .name, parentSym .flags | Flags .Bridge , parentSym .info, coord = newDefSym .owner.coord).asTerm
516
+ overridenSym .name, overridenSym .flags | Flags .Bridge , overridenSym .info, coord = implDefSym .owner.coord).asTerm
516
517
bridge.enteredAfter(ctx.phase.prev.asInstanceOf [DenotTransformer ]) // this should be safe, as we're executing in context of next phase
517
- ctx.debuglog(s " generating bridge from ${newDefSym } to $bridge" )
518
+ ctx.debuglog(s " generating bridge from ${implDefSym } to $bridge" )
518
519
519
- val sel : Tree = This (currentClass).select(newDefSym .termRef)
520
+ val implSel : Tree = This (currentClass).select(implDefSym .termRef)
520
521
521
- val resultType = parentSym .info.widen.resultType
522
+ val bridgeResultType = overridenSym .info.widen.resultType
522
523
523
524
val bridgeCtx = ctx.withOwner(bridge)
524
525
525
- tpd.DefDef (bridge, { paramss : List [List [tpd.Tree ]] =>
526
+ tpd.DefDef (bridge, { bridgeParamss : List [List [tpd.Tree ]] =>
526
527
implicit val ctx : Context = bridgeCtx
527
528
528
- val rhs = paramss.foldLeft(sel)((fun, vparams) =>
529
- fun.tpe.widen match {
530
- case MethodType (names, types) => Apply (fun, (vparams, types).zipped.map(adapt(_, _, untpd.EmptyTree )))
531
- case a => error(s " can not resolve apply type $a" )
532
-
533
- })
534
- adapt(rhs, resultType)
529
+ // Multiple parameter lists have been erased at this point
530
+ val List (bridgeParams) = bridgeParamss
531
+ val List (implParamTypes) = implSel.tpe.widen.paramTypess
532
+ val rhs = Apply (implSel, (bridgeParams, implParamTypes).zipped.map(adapt(_, _, untpd.EmptyTree )))
533
+ adapt(rhs, bridgeResultType)
535
534
})
536
535
}
537
536
0 commit comments