Skip to content

Commit a041f07

Browse files
committed
Unexpand names of type lambda params
Otherwise we would print Foo[([+scala$Option$$A] => Option[+A])^] which is ugly and not even coherent
1 parent 0a7e6c9 commit a041f07

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ class PlainPrinter(_ctx: Context) extends Printer {
174174
case tp: ExprType =>
175175
changePrec(GlobalPrec) { "=> " ~ toText(tp.resultType) }
176176
case tp: TypeLambda =>
177-
def paramText(name: Name, bounds: TypeBounds): Text = name.toString ~ toText(bounds)
177+
def paramText(name: Name, bounds: TypeBounds): Text = name.unexpandedName.toString ~ toText(bounds)
178178
changePrec(GlobalPrec) {
179179
"[" ~ Text((tp.paramNames, tp.paramInfos).zipped.map(paramText), ", ") ~
180180
"]" ~ lambdaHash(tp) ~ (" => " provided !tp.resultType.isInstanceOf[MethodType]) ~

tests/repl/i2492.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ scala> val s: Map {type Map$K =String;type Map$V = Int} = null
44
-- [E055] Syntax Error: <console>:5:7 ------------------------------------------
55
5 |val s: Map {type Map$K =String;type Map$V = Int} = null
66
| ^^^
7-
|missing type parameter for [line1$object$$iw$$iw$Map$$K, line1$object$$iw$$iw$Map$$V] => Map[K, V]
7+
| missing type parameter for [K, V] => Map[K, V]
88
scala> :quit

tests/repl/names.check

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
scala> case class Foo[M[_]](x: M[Int])
2+
defined class Foo
3+
scala> Foo(Option(1))
4+
val res0: Foo[[+A] => Option[+A]] = Foo(Some(1))
5+
scala> :quit

0 commit comments

Comments
 (0)