File tree 2 files changed +14
-1
lines changed
src/dotty/tools/dotc/transform
2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -143,7 +143,11 @@ class TailRec extends MiniPhaseTransform with DenotTransformer with FullParamete
143
143
newOwners = label :: Nil
144
144
).transform(rhsSemiTransformed)
145
145
})
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)
147
151
}} else {
148
152
if (mandatory) ctx.error(
149
153
" TailRec optimisation not applicable, method not tail recursive" ,
Original file line number Diff line number Diff line change
1
+ object Foobar {
2
+ def apply (): Option [String ] = {
3
+ def foobar [A ](f : (String , String ) => A ): List [A ] = List [String ]() match {
4
+ case _ :: ls => foobar(f)
5
+ }
6
+ foobar((a1, a2) => (a1 + a2)).headOption
7
+ }
8
+ }
9
+
You can’t perform that action at this time.
0 commit comments