From a4c47671054691ec0fa19b6f73322f9b0b192b48 Mon Sep 17 00:00:00 2001 From: Adrien Piquerez Date: Tue, 24 Aug 2021 16:18:54 +0200 Subject: [PATCH] [Fix #13306] Print paramInfo of HKTypeLambda Co-authored-by: Jamie Thompson Co-authored-by: Meriam Lachkar --- .../dotty/tools/dotc/printing/PlainPrinter.scala | 10 ++++++---- tests/printing/i13306.check | 14 ++++++++++++++ tests/printing/i13306.scala | 12 ++++++++++++ 3 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 tests/printing/i13306.check create mode 100644 tests/printing/i13306.scala diff --git a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala index 64d825ca7c26..c412afaf0487 100644 --- a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala @@ -348,15 +348,17 @@ class PlainPrinter(_ctx: Context) extends Printer { case None => "?" } - protected def decomposeLambdas(bounds: TypeBounds): (String, TypeBounds) = - def decompose(tp: Type) = tp.stripTypeVar match + protected def decomposeLambdas(bounds: TypeBounds): (Text, TypeBounds) = + def decompose(tp: Type): (Text, Type) = tp.stripTypeVar match case lam: HKTypeLambda => val names = if lam.isDeclaredVarianceLambda then lam.paramNames.lazyZip(lam.declaredVariances).map((name, v) => varianceSign(v) + name) - else lam.paramNames - (names.mkString("[", ", ", "]"), lam.resType) + else lam.paramNames.map(_.toString) + val infos = lam.paramInfos.map(toText) + val tparams = names.zip(infos).map(_ ~ _) + ("[" ~ Text(tparams, ",") ~ "]", lam.resType) case _ => ("", tp) bounds match diff --git a/tests/printing/i13306.check b/tests/printing/i13306.check new file mode 100644 index 000000000000..053d2f861cf3 --- /dev/null +++ b/tests/printing/i13306.check @@ -0,0 +1,14 @@ +[[syntax trees at end of typer]] // tests/printing/i13306.scala +package example { + class MyClass() extends Object() {} + class MembersContainer() extends Object() { + type MyType[T >: Nothing <: example.MyClass] = Comparable[T] + } + final lazy module val Exports: example.Exports = new example.Exports() + final module class Exports() extends Object() { this: example.Exports.type => + val instance: example.MembersContainer = new example.MembersContainer() + export example.Exports.instance.* + final type MyType[T <: example.MyClass] = Comparable[T] + } +} + diff --git a/tests/printing/i13306.scala b/tests/printing/i13306.scala new file mode 100644 index 000000000000..790f55018404 --- /dev/null +++ b/tests/printing/i13306.scala @@ -0,0 +1,12 @@ +package example + +class MyClass + +class MembersContainer { + type MyType[T <: MyClass] = Comparable[T] +} + +object Exports { + val instance = new MembersContainer + export instance.* +}