Skip to content

Commit c9f0b37

Browse files
committed
Fix printing right-associative extension methods
1 parent aeba1ba commit c9f0b37

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -795,9 +795,14 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
795795
withEnclosingDef(tree) {
796796
val (prefix, vparamss) =
797797
if isExtension then
798-
(keywordStr("extension") ~~ paramsText(tree.vparamss.head)
798+
val (leadingParams, otherParamss) = (tree.vparamss: @unchecked) match
799+
case vparams1 :: vparams2 :: rest if !isLeftAssoc(tree.name) =>
800+
(vparams2, vparams1 :: rest)
801+
case vparams1 :: rest =>
802+
(vparams1, rest)
803+
(keywordStr("extension") ~~ paramsText(leadingParams)
799804
~~ (defKeyword ~~ valDefText(nameIdText(tree, dropExtension = true))).close,
800-
tree.vparamss.tail)
805+
otherParamss)
801806
else (defKeyword ~~ valDefText(nameIdText(tree)), tree.vparamss)
802807

803808
addVparamssText(prefix ~ tparamsText(tree.tparams), vparamss) ~

0 commit comments

Comments
 (0)