Skip to content

Commit a4c4767

Browse files
adpi2bishaboshamlachkar
committed
[Fix #13306] Print paramInfo of HKTypeLambda
Co-authored-by: Jamie Thompson <[email protected]> Co-authored-by: Meriam Lachkar <[email protected]>
1 parent ea63740 commit a4c4767

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,15 +348,17 @@ class PlainPrinter(_ctx: Context) extends Printer {
348348
case None => "?"
349349
}
350350

351-
protected def decomposeLambdas(bounds: TypeBounds): (String, TypeBounds) =
352-
def decompose(tp: Type) = tp.stripTypeVar match
351+
protected def decomposeLambdas(bounds: TypeBounds): (Text, TypeBounds) =
352+
def decompose(tp: Type): (Text, Type) = tp.stripTypeVar match
353353
case lam: HKTypeLambda =>
354354
val names =
355355
if lam.isDeclaredVarianceLambda then
356356
lam.paramNames.lazyZip(lam.declaredVariances).map((name, v) =>
357357
varianceSign(v) + name)
358-
else lam.paramNames
359-
(names.mkString("[", ", ", "]"), lam.resType)
358+
else lam.paramNames.map(_.toString)
359+
val infos = lam.paramInfos.map(toText)
360+
val tparams = names.zip(infos).map(_ ~ _)
361+
("[" ~ Text(tparams, ",") ~ "]", lam.resType)
360362
case _ =>
361363
("", tp)
362364
bounds match

tests/printing/i13306.check

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[[syntax trees at end of typer]] // tests/printing/i13306.scala
2+
package example {
3+
class MyClass() extends Object() {}
4+
class MembersContainer() extends Object() {
5+
type MyType[T >: Nothing <: example.MyClass] = Comparable[T]
6+
}
7+
final lazy module val Exports: example.Exports = new example.Exports()
8+
final module class Exports() extends Object() { this: example.Exports.type =>
9+
val instance: example.MembersContainer = new example.MembersContainer()
10+
export example.Exports.instance.*
11+
final type MyType[T <: example.MyClass] = Comparable[T]
12+
}
13+
}
14+

tests/printing/i13306.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package example
2+
3+
class MyClass
4+
5+
class MembersContainer {
6+
type MyType[T <: MyClass] = Comparable[T]
7+
}
8+
9+
object Exports {
10+
val instance = new MembersContainer
11+
export instance.*
12+
}

0 commit comments

Comments
 (0)