From 7b063930f7fc113abb245b11c4954bd78286d77a Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Tue, 12 Nov 2019 20:35:04 +0100 Subject: [PATCH] Fix #6475: Print type lambdas in type defs --- .../src/dotty/tools/dotc/printing/RefinedPrinter.scala | 8 ++++---- tests/pos/i6475.scala | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 tests/pos/i6475.scala diff --git a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala index 809ea70a236f..85e81d3d586e 100644 --- a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala @@ -522,19 +522,19 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { (varianceText(tree.mods) ~ typeText(nameIdText(tree))) ~ withEnclosingDef(tree) { tparamsText ~ rhsText } } - def recur(rhs: Tree, tparamsTxt: => Text): Text = rhs match { + def recur(rhs: Tree, tparamsTxt: => Text, printMemberArgs: Boolean): Text = rhs match { case impl: Template => templateText(tree, impl) case rhs: TypeBoundsTree => typeDefText(tparamsTxt, toText(rhs)) - case LambdaTypeTree(tparams, body) => - recur(body, tparamsText(tparams)) + case LambdaTypeTree(tparams, body) if printMemberArgs => + recur(body, tparamsText(tparams), false) case rhs: TypeTree if isBounds(rhs.typeOpt) => typeDefText(tparamsTxt, toText(rhs)) case rhs => typeDefText(tparamsTxt, optText(rhs)(" = " ~ _)) } - recur(rhs, "") + recur(rhs, "", true) case Import(expr, selectors) => keywordText("import ") ~ importText(expr, selectors) case Export(expr, selectors) => diff --git a/tests/pos/i6475.scala b/tests/pos/i6475.scala new file mode 100644 index 000000000000..f0ebdf5de493 --- /dev/null +++ b/tests/pos/i6475.scala @@ -0,0 +1,4 @@ +object Foo1 { type T[+A] = (A, Int) } +object Foo2 { type T[+A] = [+B] =>> (A, B) } +object Foo3 { type T[+A] = [+B] =>> [C] =>> (A, B) } +object Foo4 { type T = [+A] =>> [+B] =>> [C] =>> (A, B) }