@@ -185,17 +185,6 @@ class ElimRepeated extends MiniPhase with InfoTransformer { thisPhase =>
185185 info = toJavaVarArgs(ddef.symbol.info)
186186 ).enteredAfter(thisPhase).asTerm
187187
188- val bridgeDef = polyDefDef(bridge, trefs => vrefss => {
189- val init :+ (last :+ vararg) = vrefss
190- // Can't call `.argTypes` here because the underlying array type is of the
191- // form `Array[? <: SomeType]`, so we need `.argInfos` to get the `TypeBounds`.
192- val elemtp = vararg.tpe.widen.argInfos.head
193- ref(original.termRef)
194- .appliedToTypes(trefs)
195- .appliedToArgss(init)
196- .appliedToArgs(last :+ tpd.wrapArray(vararg, elemtp))
197- })
198-
199188 val bridgeDenot = bridge.denot
200189 currentClass.info.member(bridge.name).alternatives.find { s =>
201190 s.matches(bridgeDenot) &&
@@ -205,6 +194,21 @@ class ElimRepeated extends MiniPhase with InfoTransformer { thisPhase =>
205194 ctx.error(s " @varargs produces a forwarder method that conflicts with ${conflict.showDcl}" , ddef.sourcePos)
206195 EmptyTree
207196 case None =>
197+ val bridgeDef = polyDefDef(bridge, trefs => vrefss => {
198+ val init :+ (last :+ vararg) = vrefss
199+ // Can't call `.argTypes` here because the underlying array type is of the
200+ // form `Array[? <: SomeType]`, so we need `.argInfos` to get the `TypeBounds`.
201+ val elemtp = vararg.tpe.widen.argInfos.head
202+
203+ // The generation of the forwarding call needs to be deferred, otherwise
204+ // generic and curried methods won't pass the tree checker.
205+ atNextPhase {
206+ ref(original.termRef)
207+ .appliedToTypes(trefs)
208+ .appliedToArgss(init)
209+ .appliedToArgs(last :+ tpd.wrapArray(vararg, elemtp))
210+ }
211+ })
208212 Thicket (ddef, bridgeDef)
209213
210214 /** Convert type from Scala to Java varargs method */
0 commit comments