From 779c96bef04d81048f91135b386bd7f37fcf1f20 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Sun, 27 Nov 2016 17:19:57 +0100 Subject: 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 --- compiler/test/dotty/partest/DPConsoleRunner.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'compiler/test/dotty/partest') 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 _ => -- cgit v1.2.3