diff options
author | Guillaume Martres <smarter@ubuntu.com> | 2016-11-27 17:19:57 +0100 |
---|---|---|
committer | Guillaume Martres <smarter@ubuntu.com> | 2017-01-28 19:12:19 +0100 |
commit | 779c96bef04d81048f91135b386bd7f37fcf1f20 (patch) | |
tree | f2fe3165a4ffc99c863edca6f4470f05707c22a8 | |
parent | cb2c2a0ff1631df91f84a85b0db814b24a4d6d62 (diff) | |
download | dotty-779c96bef04d81048f91135b386bd7f37fcf1f20.tar.gz dotty-779c96bef04d81048f91135b386bd7f37fcf1f20.tar.bz2 dotty-779c96bef04d81048f91135b386bd7f37fcf1f20.zip |
Fix bug in partest.DPConsoleRunner
The bug was that we declared case classes like:
case class CompFailed() extends NegTestState
but we used their companion objects like in:
case _ => CompFailed
Interestingly, this bug was caught by compiling this code with dotty,
instead of `failureStates` getting inferred to be of type `AnyRef`, it
ended up being a union of object types, this allows dotty to realize our
subsequent pattern match on `failureStates` cannot possibly succeed:
-- Error: /home/smarter/opt/dotty/compiler/test/dotty/partest/DPConsoleRunner.scala
353 | case CompFailedButWrongDiff() =>
| ^
| missing parameter type for parameter x$1 of expanded function x$1 =>
| x$1 @unchecked match
| {
| case CompFailedButWrongDiff() =>
| nextTestActionFailing(s"output differs")
| true
| case _ =>
| false
| }, expected = ?
-- Error: /home/smarter/opt/dotty/compiler/test/dotty/partest/DPConsoleRunner.scala
353 | case CompFailedButWrongDiff() =>
| ^^^^^^^^^^^^^^^^^^^^^^^^
|Pattern type CompFailedButWrongDiff is neither a subtype nor a supertype of selector type CompSucceeded | CompFailedButWrongNErr | CompFailed | CompFailedButWrongDiff'where: CompFailedButWrongDiff is a class in method runNegTest
| CompFailedButWrongDiff' is a object in method runNegTest
-rw-r--r-- | compiler/test/dotty/partest/DPConsoleRunner.scala | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/compiler/test/dotty/partest/DPConsoleRunner.scala b/compiler/test/dotty/partest/DPConsoleRunner.scala index 0ad573792..7a25af6b7 100644 --- a/compiler/test/dotty/partest/DPConsoleRunner.scala +++ b/compiler/test/dotty/partest/DPConsoleRunner.scala @@ -300,11 +300,11 @@ class DPTestRunner(testFile: File, suiteRunner: DPSuiteRunner) extends nest.Runn // Don't get confused, the neg test passes when compilation fails for at // least one round (optionally checking the number of compiler errors and // compiler console output) - case class CompFailed() extends NegTestState + case object CompFailed extends NegTestState // the neg test fails when all rounds return either of these: case class CompFailedButWrongNErr(expected: String, found: String) extends NegTestState - case class CompFailedButWrongDiff() extends NegTestState - case class CompSucceeded() extends NegTestState + case object CompFailedButWrongDiff extends NegTestState + case object CompSucceeded extends NegTestState def nerrIsOk(reason: String) = { val nerrFinder = """compilation failed with (\d+) errors""".r @@ -350,7 +350,7 @@ class DPTestRunner(testFile: File, suiteRunner: DPSuiteRunner) extends nest.Runn if (existsNerr) false else { val existsDiff = failureStates.exists({ - case CompFailedButWrongDiff() => + case CompFailedButWrongDiff => nextTestActionFailing(s"output differs") true case _ => |