diff options
author | Felix Mulder <felix.mulder@gmail.com> | 2017-04-02 00:35:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-02 00:35:31 +0200 |
commit | 710e700b2285738bc0700ed548517efc1f368bb0 (patch) | |
tree | 79f7fd243efeffdc4843311651734d709c115d79 /compiler/src/dotty/tools/dotc | |
parent | aa2522c880d78d172b3af6cc4d336f2ebe447b18 (diff) | |
parent | d73c8e42ca526ff2c53a17ddd1fa87044dd5bbca (diff) | |
download | dotty-710e700b2285738bc0700ed548517efc1f368bb0.tar.gz dotty-710e700b2285738bc0700ed548517efc1f368bb0.tar.bz2 dotty-710e700b2285738bc0700ed548517efc1f368bb0.zip |
Merge branch 'master' into fix-hashcode
Diffstat (limited to 'compiler/src/dotty/tools/dotc')
5 files changed, 27 insertions, 15 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/core/classfile/ClassfileParser.scala b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala index bc140c26b..e0b233ce8 100644 --- a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala +++ b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala @@ -661,7 +661,7 @@ class ClassfileParser( for (entry <- innerClasses.values) { // create a new class member for immediate inner classes if (entry.outerName == currentClassName) { - val file = ctx.platform.classPath.findSourceFile(entry.externalName.toString) getOrElse { + val file = ctx.platform.classPath.findBinaryFile(entry.externalName.toString) getOrElse { throw new AssertionError(entry.externalName) } enterClassAndModule(entry, file, entry.jflags) 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/transform/PatternMatcher.scala b/compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala index 7576ccc05..b0ae36612 100644 --- a/compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala +++ b/compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala @@ -848,13 +848,14 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer { val nextBinder = afterTest.asTerm - def needsOuterTest(patType: Type, selType: Type, currentOwner: Symbol): Boolean = { + def outerTestNeeded(implicit ctx: Context): Boolean = { // See the test for SI-7214 for motivation for dealias. Later `treeCondStrategy#outerTest` // generates an outer test based on `patType.prefix` with automatically dealises. - patType.dealias match { - case tref @ TypeRef(pre, name) => - (pre ne NoPrefix) && tref.symbol.isClass && - ExplicitOuter.needsOuterIfReferenced(tref.symbol.asClass) + expectedTp.dealias match { + case tref @ TypeRef(pre: SingletonType, name) => + val s = tref + s.symbol.isClass && + ExplicitOuter.needsOuterIfReferenced(s.symbol.asClass) case _ => false } @@ -862,12 +863,6 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer { override lazy val introducedRebindings = NoRebindings - def outerTestNeeded = { - val np = expectedTp.normalizedPrefix - val ts = np.termSymbol - (ts ne NoSymbol) && needsOuterTest(expectedTp, testedBinder.info, ctx.owner) - } - // the logic to generate the run-time test that follows from the fact that // a `prevBinder` is expected to have type `expectedTp` // the actual tree-generation logic is factored out, since the analyses generate Cond(ition)s rather than Trees 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 |