Skip to content

Commit

Permalink
[Fix #13306] Print paramInfo of HKTypeLambda
Browse files Browse the repository at this point in the history
Co-authored-by: Jamie Thompson <jamie.thompson@bath.edu>
Co-authored-by: Meriam Lachkar <meriam.lachkar@gmail.com>
  • Loading branch information
3 people committed Aug 24, 2021
1 parent ea63740 commit a4c4767
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
10 changes: 6 additions & 4 deletions compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions tests/printing/i13306.check
Original file line number Diff line number Diff line change
@@ -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]
}
}

12 changes: 12 additions & 0 deletions tests/printing/i13306.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package example

class MyClass

class MembersContainer {
type MyType[T <: MyClass] = Comparable[T]
}

object Exports {
val instance = new MembersContainer
export instance.*
}

0 comments on commit a4c4767

Please sign in to comment.