Skip to content

Commit 55a122d

Browse files
committed
Fix PlainPrinter.scala: incorect type pararameters
What it prints might be counter intuitive at first, but is correct The clearest example is in i5345, where otherwise the printed output doesn't correspond to the declaration
1 parent 8b9e6d6 commit 55a122d

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ class PlainPrinter(_ctx: Context) extends Printer {
223223
case tp: PolyType =>
224224
changePrec(GlobalPrec) {
225225
"[" ~ paramsText(tp) ~ "]" ~ lambdaHash(tp) ~
226-
(Str(" => ") provided !tp.resultType.isInstanceOf[MethodType]) ~
226+
(Str(": ") provided !tp.resultType.isInstanceOf[MethodType]) ~
227227
toTextGlobal(tp.resultType)
228228
}
229229
case AnnotatedType(tpe, annot) =>

compiler/test-resources/repl/i5345

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
scala> def x[A, B]: Conversion[A, B] = _ => ???
2-
def x[A, B] => Conversion[A, B]
2+
def x[A, B]: Conversion[A, B]

language-server/test/dotty/tools/languageserver/CompletionTest.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ class CompletionTest {
610610
code"""object Foo
611611
|extension (foo: Foo.type) def xxxx[A]: Int = 1
612612
|object Main { Foo.xx${m1} }""".withSource
613-
.completion(m1, Set(("xxxx", Method, "[A] => Int")))
613+
.completion(m1, Set(("xxxx", Method, "[A]: Int")))
614614
}
615615

616616
@Test def completeExtensionMethodWithParameterAndTypeParameter: Unit = {
@@ -729,7 +729,7 @@ class CompletionTest {
729729
|given Baz with {}
730730
|extension [A](using bar: Bar)(a: A)(using baz: Baz) def xxxx[B]: Either[A, B] = Left(a)
731731
|object Main { 123.xx${m1} }""".withSource
732-
.completion(m1, Set(("xxxx", Method, "(using baz: Baz): [B] => Either[Int, B]")))
732+
.completion(m1, Set(("xxxx", Method, "(using baz: Baz)[B]: Either[Int, B]")))
733733
}
734734

735735
@Test def completeExtensionMethodWithTypeBounds: Unit = {
@@ -739,7 +739,7 @@ class CompletionTest {
739739
|extension [A >: Bar](a: A) def xxxx[B <: a.type]: Either[A, B] = Left(a)
740740
|val foo = new Foo {}
741741
|object Main { foo.xx${m1} }""".withSource
742-
.completion(m1, Set(("xxxx", Method, "[B <: (foo : Foo)] => Either[Foo, B]")))
742+
.completion(m1, Set(("xxxx", Method, "[B <: (foo : Foo)]: Either[Foo, B]")))
743743
}
744744

745745
@Test def completeInheritedExtensionMethod: Unit = {

tests/neg-custom-args/fatal-warnings/i9408a.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
-- Error: tests/neg-custom-args/fatal-warnings/i9408a.scala:26:20 ------------------------------------------------------
1010
26 | val length: Int = "qwerty" // error
1111
| ^^^^^^^^
12-
|The conversion (Test5.implicitLength : [A] => String => Int) will not be applied implicitly here in Scala 3 because only implicit methods and instances of Conversion class will continue to work as implicit views.
12+
|The conversion (Test5.implicitLength : [A]: String => Int) will not be applied implicitly here in Scala 3 because only implicit methods and instances of Conversion class will continue to work as implicit views.
1313
-- Error: tests/neg-custom-args/fatal-warnings/i9408a.scala:31:20 ------------------------------------------------------
1414
31 | val length: Int = "qwerty" // error
1515
| ^^^^^^^^
@@ -21,4 +21,4 @@
2121
-- Error: tests/neg-custom-args/fatal-warnings/i9408a.scala:59:2 -------------------------------------------------------
2222
59 | 123.foo // error
2323
| ^^^
24-
|The conversion (Test11.a2foo : [A] => A => Test11.Foo) will not be applied implicitly here in Scala 3 because only implicit methods and instances of Conversion class will continue to work as implicit views.
24+
|The conversion (Test11.a2foo : [A]: A => Test11.Foo) will not be applied implicitly here in Scala 3 because only implicit methods and instances of Conversion class will continue to work as implicit views.

0 commit comments

Comments
 (0)