Skip to content

Commit cbd0e31

Browse files
Merge pull request #7545 from dotty-staging/fix-#6475
Fix #6475: Print type lambdas in type defs
2 parents 1aeeffe + 7b06393 commit cbd0e31

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -522,19 +522,19 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
522522
(varianceText(tree.mods) ~ typeText(nameIdText(tree))) ~
523523
withEnclosingDef(tree) { tparamsText ~ rhsText }
524524
}
525-
def recur(rhs: Tree, tparamsTxt: => Text): Text = rhs match {
525+
def recur(rhs: Tree, tparamsTxt: => Text, printMemberArgs: Boolean): Text = rhs match {
526526
case impl: Template =>
527527
templateText(tree, impl)
528528
case rhs: TypeBoundsTree =>
529529
typeDefText(tparamsTxt, toText(rhs))
530-
case LambdaTypeTree(tparams, body) =>
531-
recur(body, tparamsText(tparams))
530+
case LambdaTypeTree(tparams, body) if printMemberArgs =>
531+
recur(body, tparamsText(tparams), false)
532532
case rhs: TypeTree if isBounds(rhs.typeOpt) =>
533533
typeDefText(tparamsTxt, toText(rhs))
534534
case rhs =>
535535
typeDefText(tparamsTxt, optText(rhs)(" = " ~ _))
536536
}
537-
recur(rhs, "")
537+
recur(rhs, "", true)
538538
case Import(expr, selectors) =>
539539
keywordText("import ") ~ importText(expr, selectors)
540540
case Export(expr, selectors) =>

tests/pos/i6475.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
object Foo1 { type T[+A] = (A, Int) }
2+
object Foo2 { type T[+A] = [+B] =>> (A, B) }
3+
object Foo3 { type T[+A] = [+B] =>> [C] =>> (A, B) }
4+
object Foo4 { type T = [+A] =>> [+B] =>> [C] =>> (A, B) }

0 commit comments

Comments
 (0)