Skip to content

Commit bcb652b

Browse files
committed
Fix #1614: correctly handle polymorphic inner methods
Even if outer class & method isn't polymorpnic, inner method might be. Need to handle this correctly.
1 parent cdb83f9 commit bcb652b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/dotty/tools/dotc/transform/TailRec.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,11 @@ class TailRec extends MiniPhaseTransform with DenotTransformer with FullParamete
143143
newOwners = label :: Nil
144144
).transform(rhsSemiTransformed)
145145
})
146-
Block(List(labelDef), ref(label).appliedToArgss(vparamss0.map(_.map(x=> ref(x.symbol)))))
146+
val callIntoLabel = (
147+
if (dd.tparams.isEmpty) ref(label)
148+
else ref(label).appliedToTypes(dd.tparams.map(_.tpe))
149+
).appliedToArgss(vparamss0.map(_.map(x=> ref(x.symbol))))
150+
Block(List(labelDef), callIntoLabel)
147151
}} else {
148152
if (mandatory) ctx.error(
149153
"TailRec optimisation not applicable, method not tail recursive",

0 commit comments

Comments
 (0)