@@ -185,17 +185,6 @@ class ElimRepeated extends MiniPhase with InfoTransformer { thisPhase =>
185
185
info = toJavaVarArgs(ddef.symbol.info)
186
186
).enteredAfter(thisPhase).asTerm
187
187
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
-
199
188
val bridgeDenot = bridge.denot
200
189
currentClass.info.member(bridge.name).alternatives.find { s =>
201
190
s.matches(bridgeDenot) &&
@@ -205,6 +194,21 @@ class ElimRepeated extends MiniPhase with InfoTransformer { thisPhase =>
205
194
ctx.error(s " @varargs produces a forwarder method that conflicts with ${conflict.showDcl}" , ddef.sourcePos)
206
195
EmptyTree
207
196
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
+ ctx.atNextPhase {
206
+ ref(original.termRef)
207
+ .appliedToTypes(trefs)
208
+ .appliedToArgss(init)
209
+ .appliedToArgs(last :+ tpd.wrapArray(vararg, elemtp))
210
+ }
211
+ })
208
212
Thicket (ddef, bridgeDef)
209
213
210
214
/** Convert type from Scala to Java varargs method */
0 commit comments