Skip to content

Commit a566635

Browse files
committed
Eta-reduce before pretty-printing if possible
1 parent eb9952e commit a566635

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
156156
if (defn.isTupleClass(cls)) return toTextTuple(args)
157157
if (isInfixType(tp)) return toTextInfixType(tycon, args)
158158
return (toTextLocal(tycon) ~ "[" ~ Text(args map argText, ", ") ~ "]").close
159+
case EtaExpansion(tycon) =>
160+
return toText(tycon)
159161
case tp: TypeRef =>
160162
val hideType = !ctx.settings.debugAlias.value && (tp.symbol.isAliasPreferred)
161163
if (hideType && !ctx.phase.erasedTypes && !tp.symbol.isCompleting) {

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 [K, V] => Map[K, V]
7+
| missing type parameter for Map
88
scala> :quit

tests/repl/names.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
scala> case class Foo[M[_]](x: M[Int])
22
defined class Foo
33
scala> Foo(Option(1))
4-
val res0: Foo[[+A] => Option[A]] = Foo(Some(1))
4+
val res0: Foo[Option] = Foo(Some(1))
55
scala> :quit

0 commit comments

Comments
 (0)