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
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/printing/Texts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ object Texts {

def mkString(width: Int, withLineNumbers: Boolean): String = {
val sb = new StringBuilder
val numberWidth = if (withLineNumbers) (2 * maxLine.toString.length) + 2 else 0
// width display can be upto a range "n-n" where 1 <= n <= maxLine+1
val numberWidth = if (withLineNumbers) (2 * (maxLine + 1).toString.length) + 2 else 0
layout(width - numberWidth).print(sb, numberWidth)
sb.toString
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/reporting/messages.scala
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ class TypeMismatch(val found: Type, expected: Type, val inTree: Option[untpd.Tre
++ addenda.dropWhile(_.isEmpty).headOption.getOrElse(importSuggestions)

override def explain(using Context) =
val treeStr = inTree.map(x => s"\nTree: ${x.show}").getOrElse("")
val treeStr = inTree.map(x => s"\nTree:\n\n${x.show}\n").getOrElse("")
treeStr + "\n" + super.explain

end TypeMismatch
Expand Down
5 changes: 4 additions & 1 deletion tests/neg/19680.check
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
| Explanation (enabled by `-explain`)
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
| Tree: new Config()
| Tree:
|
| new Config()
|
| I tried to show that
| Config
| conforms to
Expand Down
5 changes: 4 additions & 1 deletion tests/neg/19680b.check
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
| Explanation (enabled by `-explain`)
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
| Tree: "hello"
| Tree:
|
| "hello"
|
| I tried to show that
| ("hello" : String)
| conforms to
Expand Down
5 changes: 4 additions & 1 deletion tests/neg/hidden-type-errors.check
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
| Explanation (enabled by `-explain`)
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
| Tree: t12717.A.bar("XXX")
| Tree:
|
| t12717.A.bar("XXX")
|
| I tried to show that
| String
| conforms to
Expand Down
10 changes: 8 additions & 2 deletions tests/neg/i18737.check
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
| Explanation (enabled by `-explain`)
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
| Tree: v
| Tree:
|
| v
|
| I tried to show that
| (v : String & Long)
| conforms to
Expand All @@ -32,7 +35,10 @@
| Explanation (enabled by `-explain`)
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
| Tree: v
| Tree:
|
| v
|
| I tried to show that
| (v : String | Long)
| conforms to
Expand Down