Skip to content

Commit f3cf401

Browse files
committed
Remove extra newlines in type mismatch message
1 parent 614265d commit f3cf401

File tree

4 files changed

+2
-12
lines changed

4 files changed

+2
-12
lines changed

compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,11 +291,10 @@ object messages {
291291
val kind: String = "Type Mismatch"
292292
val msg: String = {
293293
val (where, printCtx) = Formatting.disambiguateTypes(found, expected)
294+
val whereSuffix = if (where.isEmpty) where else s"\n\n$where"
294295
val (fnd, exp) = Formatting.typeDiff(found, expected)(printCtx)
295296
s"""|found: $fnd
296-
|required: $exp
297-
|
298-
|$where""".stripMargin + whyNoMatch + implicitFailure
297+
|required: $exp""".stripMargin + whereSuffix + whyNoMatch + implicitFailure
299298
}
300299

301300
val explanation: String = ""

compiler/test-resources/repl/errmsgs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,30 @@ scala> val x: List[String] = List(1)
55
| ^
66
| found: Int(1)
77
| required: String
8-
|
98
scala> val y: List[List[String]] = List(List(1))
109
1 | val y: List[List[String]] = List(List(1))
1110
| ^
1211
| found: Int(1)
1312
| required: String
14-
|
1513
scala> val z: (List[String], List[Int]) = (List(1), List("a"))
1614
1 | val z: (List[String], List[Int]) = (List(1), List("a"))
1715
| ^
1816
| found: Int(1)
1917
| required: String
20-
|
2118
1 | val z: (List[String], List[Int]) = (List(1), List("a"))
2219
| ^^^
2320
| found: String("a")
2421
| required: Int
25-
|
2622
scala> val a: Inv[String] = new Inv(new Inv(1))
2723
1 | val a: Inv[String] = new Inv(new Inv(1))
2824
| ^^^^^^^^^^
2925
| found: Inv[Int]
3026
| required: String
31-
|
3227
scala> val b: Inv[String] = new Inv(1)
3328
1 | val b: Inv[String] = new Inv(1)
3429
| ^
3530
| found: Int(1)
3631
| required: String
37-
|
3832
scala> abstract class C { type T; val x: T; val s: Unit = { type T = String; var y: T = x; locally { def f() = { type T = Int; val z: T = y }; f() } }; }
3933
1 | abstract class C { type T; val x: T; val s: Unit = { type T = String; var y: T = x; locally { def f() = { type T = Int; val z: T = y }; f() } }; }
4034
| ^
@@ -59,7 +53,6 @@ scala> val x: List[Int] = "foo" :: List(1)
5953
| ^^^^^
6054
| found: String("foo")
6155
| required: Int
62-
|
6356
scala> { def f: Int = g; val x: Int = 1; def g: Int = 5; }
6457
1 | { def f: Int = g; val x: Int = 1; def g: Int = 5; }
6558
| ^

compiler/test-resources/repl/importFromObj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ scala> buf += xs
99
| ^^
1010
| found: List[Int](o.xs)
1111
| required: Int
12-
|
1312
scala> buf ++= xs
1413
val res0: scala.collection.mutable.ListBuffer[Int] = ListBuffer(1, 2, 3)
1514
scala> import util.foo

compiler/test-resources/type-printer/type-mismatch

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@ scala> val x: Foo[String] = res0
77
| ^^^^
88
| found: Foo[Int](res0)
99
| required: Foo[String]
10-
|

0 commit comments

Comments
 (0)