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 6be2091
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
10 changes: 7 additions & 3 deletions compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Variances.varianceSign
import util.SourcePosition
import scala.util.control.NonFatal
import scala.annotation.switch
import Decorators._

class PlainPrinter(_ctx: Context) extends Printer {
/** The context of all public methods in Printer and subclasses.
Expand Down Expand Up @@ -354,9 +355,12 @@ class PlainPrinter(_ctx: Context) extends Printer {
val names =
if lam.isDeclaredVarianceLambda then
lam.paramNames.lazyZip(lam.declaredVariances).map((name, v) =>
varianceSign(v) + name)
else lam.paramNames
(names.mkString("[", ", ", "]"), lam.resType)
varianceSign(v) ~ name.toString)
else lam.paramNames.map(toTextGlobal)
val infos = lam.paramInfos.map(toTextGlobal)
val tparamStr = names.zip(infos).map((n, i) => (n ~ i).show)
.mkString("[", ", ", "]")
(tparamStr, 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 6be2091

Please sign in to comment.