Skip to content

Commit dc8c5c3

Browse files
committed
Pretty-print method types with a ": " before a non-method return type
1 parent a566635 commit dc8c5c3

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ class PlainPrinter(_ctx: Context) extends Printer {
169169
changePrec(GlobalPrec) {
170170
(if (tp.isImplicit) "(implicit " else "(") ~
171171
Text((tp.paramNames, tp.paramInfos).zipped map paramText, ", ") ~
172-
")" ~ toText(tp.resultType)
172+
(if (tp.resultType.isInstanceOf[MethodType]) ")" else "): ") ~
173+
toText(tp.resultType)
173174
}
174175
case tp: ExprType =>
175176
changePrec(GlobalPrec) { "=> " ~ toText(tp.resultType) }

compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ class ErrorMessagesTests extends ErrorMessagesTest {
384384
val MethodDoesNotTakeParameters(tree, methodPart) :: Nil = messages
385385

386386
assertEquals("Scope.foo(1)", tree.show)
387-
assertEquals("((a: Int)Unit)(Scope.foo)", methodPart.show)
387+
assertEquals("((a: Int): Unit)(Scope.foo)", methodPart.show)
388388
}
389389

390390
@Test def ambiugousOverloadWithWildcard =
@@ -408,7 +408,7 @@ class ErrorMessagesTests extends ErrorMessagesTest {
408408
assertMessageCount(1, messages)
409409
val AmbiguousOverload(tree, List(alt1, alt2), pt: WildcardType) :: Nil = messages
410410
assertEquals("method foo", alt1.show)
411-
assertEquals("(s: String)String", alt1.info.show)
411+
assertEquals("(s: String): String", alt1.info.show)
412412
assertEquals("method foo", alt2.show)
413413
}
414414

0 commit comments

Comments
 (0)