aboutsummaryrefslogtreecommitdiff
path: root/compiler/src
diff options
context:
space:
mode:
authorFelix Mulder <felix.mulder@gmail.com>2017-03-31 17:46:38 +0200
committerGitHub <noreply@github.com>2017-03-31 17:46:38 +0200
commitd73c8e42ca526ff2c53a17ddd1fa87044dd5bbca (patch)
tree071a4f66c7ec5201e0897ce6b666161f556e2695 /compiler/src
parent2fceb2dcd7280883e6a3c2beec9190148a5d975b (diff)
parented10ef0208f794060b5351cc601a915177e0a1c5 (diff)
downloaddotty-d73c8e42ca526ff2c53a17ddd1fa87044dd5bbca.tar.gz
dotty-d73c8e42ca526ff2c53a17ddd1fa87044dd5bbca.tar.bz2
dotty-d73c8e42ca526ff2c53a17ddd1fa87044dd5bbca.zip
Merge pull request #2154 from dotty-staging/topic/fix-#2151
Fix #2151: don't die for wrong number of typeargs applied
Diffstat (limited to 'compiler/src')
-rw-r--r--compiler/src/dotty/tools/dotc/core/Decorators.scala2
-rw-r--r--compiler/src/dotty/tools/dotc/reporting/MessageRendering.scala2
-rw-r--r--compiler/src/dotty/tools/dotc/util/DiffUtil.scala19
3 files changed, 20 insertions, 3 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/Decorators.scala b/compiler/src/dotty/tools/dotc/core/Decorators.scala
index f8267072e..0e8ae196a 100644
--- a/compiler/src/dotty/tools/dotc/core/Decorators.scala
+++ b/compiler/src/dotty/tools/dotc/core/Decorators.scala
@@ -103,7 +103,7 @@ object Decorators {
* as long as `xs`.
*/
def zipWithConserve[U](ys: List[U])(f: (T, U) => T): List[T] =
- if (xs.isEmpty) xs
+ if (xs.isEmpty || ys.isEmpty) Nil
else {
val x1 = f(xs.head, ys.head)
val xs1 = xs.tail.zipWithConserve(ys.tail)(f)
diff --git a/compiler/src/dotty/tools/dotc/reporting/MessageRendering.scala b/compiler/src/dotty/tools/dotc/reporting/MessageRendering.scala
index 17eb8d39b..91e65ab66 100644
--- a/compiler/src/dotty/tools/dotc/reporting/MessageRendering.scala
+++ b/compiler/src/dotty/tools/dotc/reporting/MessageRendering.scala
@@ -21,7 +21,7 @@ trait MessageRendering {
* @return string stripped of ANSI escape codes
*/
def stripColor(str: String): String =
- str.replaceAll("\u001B\\[[;\\d]*m", "")
+ str.replaceAll("\u001b\\[.*?m", "")
/** When inlining a method call, if there's an error we'd like to get the
* outer context and the `pos` at which the call was inlined.
diff --git a/compiler/src/dotty/tools/dotc/util/DiffUtil.scala b/compiler/src/dotty/tools/dotc/util/DiffUtil.scala
index b55aee719..6f7df13a6 100644
--- a/compiler/src/dotty/tools/dotc/util/DiffUtil.scala
+++ b/compiler/src/dotty/tools/dotc/util/DiffUtil.scala
@@ -58,8 +58,25 @@ object DiffUtil {
(fnd, exp, totalChange.toDouble / (expected.length + found.length))
}
- def mkColoredCodeDiff(code: String, lastCode: String, printDiffDel: Boolean): String = {
+ def mkColoredLineDiff(expected: String, actual: String): String = {
+ val tokens = splitTokens(expected, Nil).toArray
+ val lastTokens = splitTokens(actual, Nil).toArray
+
+ val diff = hirschberg(lastTokens, tokens)
+ " |SOF\n" + diff.collect {
+ case Unmodified(str) =>
+ " |" + str
+ case Inserted(str) =>
+ ADDITION_COLOR + "e |" + str + ANSI_DEFAULT
+ case Modified(old, str) =>
+ DELETION_COLOR + "a |" + old + "\ne |" + ADDITION_COLOR + str + ANSI_DEFAULT
+ case Deleted(str) =>
+ DELETION_COLOR + "\na |" + str + ANSI_DEFAULT
+ }.mkString + "\n |EOF"
+ }
+
+ def mkColoredCodeDiff(code: String, lastCode: String, printDiffDel: Boolean): String = {
val tokens = splitTokens(code, Nil).toArray
val lastTokens = splitTokens(lastCode, Nil).toArray