Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ class PlainPrinter(_ctx: Context) extends Printer {
~ keywordText("erased ").provided(tp.isErasedMethod)
~ keywordText("implicit ").provided(tp.isImplicitMethod && !tp.isContextualMethod)
~ paramsText(tp)
~ (if tp.resultType.isInstanceOf[MethodType] then ")" else "): ")
~ ")"
~ (Str(": ") provided !tp.resultType.isInstanceOf[MethodOrPoly])
~ toText(tp.resultType)
}
case tp: ExprType =>
Expand All @@ -223,7 +224,7 @@ class PlainPrinter(_ctx: Context) extends Printer {
case tp: PolyType =>
changePrec(GlobalPrec) {
"[" ~ paramsText(tp) ~ "]" ~ lambdaHash(tp) ~
(Str(" => ") provided !tp.resultType.isInstanceOf[MethodType]) ~
(Str(": ") provided !tp.resultType.isInstanceOf[MethodOrPoly]) ~
toTextGlobal(tp.resultType)
}
case AnnotatedType(tpe, annot) =>
Expand Down Expand Up @@ -418,7 +419,7 @@ class PlainPrinter(_ctx: Context) extends Printer {
(if (isParameter) ": => " else ": ") ~ toTextGlobal(tp.widenExpr)
case tp: PolyType =>
"[" ~ paramsText(tp) ~ "]"
~ (Str(": ") provided !tp.resultType.isInstanceOf[MethodType])
~ (Str(": ") provided !tp.resultType.isInstanceOf[MethodOrPoly])
~ toTextGlobal(tp.resultType)
case tp =>
": " ~ toTextGlobal(tp)
Expand Down
2 changes: 1 addition & 1 deletion compiler/test-resources/repl/i5345
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
scala> def x[A, B]: Conversion[A, B] = _ => ???
def x[A, B] => Conversion[A, B]
def x[A, B]: Conversion[A, B]
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ class CompletionTest {
code"""object Foo
|extension (foo: Foo.type) def xxxx[A]: Int = 1
|object Main { Foo.xx${m1} }"""
.completion(("xxxx", Method, "[A] => Int"))
.completion(("xxxx", Method, "[A]: Int"))
}

@Test def completeExtensionMethodWithParameterAndTypeParameter: Unit = {
Expand Down Expand Up @@ -762,7 +762,7 @@ class CompletionTest {
|given Baz with {}
|extension [A](using bar: Bar)(a: A)(using baz: Baz) def xxxx[B]: Either[A, B] = Left(a)
|object Main { 123.xx${m1} }"""
.completion(("xxxx", Method, "(using baz: Baz): [B] => Either[Int, B]"))
.completion(("xxxx", Method, "(using baz: Baz)[B]: Either[Int, B]"))
}

@Test def completeExtensionMethodWithTypeBounds: Unit = {
Expand All @@ -772,7 +772,7 @@ class CompletionTest {
|extension [A >: Bar](a: A) def xxxx[B <: a.type]: Either[A, B] = Left(a)
|val foo = new Foo {}
|object Main { foo.xx${m1} }"""
.completion(("xxxx", Method, "[B <: (foo : Foo)] => Either[Foo, B]"))
.completion(("xxxx", Method, "[B <: (foo : Foo)]: Either[Foo, B]"))
}

@Test def completeInheritedExtensionMethod: Unit = {
Expand Down Expand Up @@ -1034,15 +1034,15 @@ class CompletionTest {
("→", Method, "[B](y: B): (A, B)"),
("!=", Method, "(x$0: Any): Boolean"),
("fromOrdinal", Method, "(ordinal: Int): Foo.Bar"),
("asInstanceOf", Method, "[X0] => X0"),
("asInstanceOf", Method, "[X0]: X0"),
("->", Method, "[B](y: B): (A, B)"),
("wait", Method, "(x$0: Long, x$1: Int): Unit"),
("`back-tick`", Field, "Foo.Bar"),
("notify", Method, "(): Unit"),
("formatted", Method, "(fmtstr: String): String"),
("ensuring", Method, "(cond: A => Boolean, msg: => Any): A"),
("wait", Method, "(): Unit"),
("isInstanceOf", Method, "[X0] => Boolean"),
("isInstanceOf", Method, "[X0]: Boolean"),
("`match`", Field, "Foo.Bar"),
("toString", Method, "(): String"),
("ensuring", Method, "(cond: A => Boolean): A"),
Expand Down
4 changes: 2 additions & 2 deletions tests/neg-custom-args/fatal-warnings/i9408a.check
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
-- Error: tests/neg-custom-args/fatal-warnings/i9408a.scala:26:20 ------------------------------------------------------
26 | val length: Int = "qwerty" // error
| ^^^^^^^^
|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.
|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.
-- Error: tests/neg-custom-args/fatal-warnings/i9408a.scala:31:20 ------------------------------------------------------
31 | val length: Int = "qwerty" // error
| ^^^^^^^^
Expand All @@ -21,4 +21,4 @@
-- Error: tests/neg-custom-args/fatal-warnings/i9408a.scala:59:2 -------------------------------------------------------
59 | 123.foo // error
| ^^^
|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.
|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.