Skip to content

Commit

Permalink
[Fix scala#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 fb448b4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
7 changes: 5 additions & 2 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 @@ -355,8 +356,10 @@ class PlainPrinter(_ctx: Context) extends Printer {
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(_.show)
val tparamStr = names.zip(infos).map(_ + _).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 fb448b4

Please sign in to comment.