Skip to content

Commit 91c8949

Browse files
committed
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
1 parent 0431c8b commit 91c8949

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

compiler/test/dotty/partest/DPConsoleRunner.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,11 @@ class DPTestRunner(testFile: File, suiteRunner: DPSuiteRunner) extends nest.Runn
300300
// Don't get confused, the neg test passes when compilation fails for at
301301
// least one round (optionally checking the number of compiler errors and
302302
// compiler console output)
303-
case class CompFailed() extends NegTestState
303+
case object CompFailed extends NegTestState
304304
// the neg test fails when all rounds return either of these:
305305
case class CompFailedButWrongNErr(expected: String, found: String) extends NegTestState
306-
case class CompFailedButWrongDiff() extends NegTestState
307-
case class CompSucceeded() extends NegTestState
306+
case object CompFailedButWrongDiff extends NegTestState
307+
case object CompSucceeded extends NegTestState
308308

309309
def nerrIsOk(reason: String) = {
310310
val nerrFinder = """compilation failed with (\d+) errors""".r
@@ -350,7 +350,7 @@ class DPTestRunner(testFile: File, suiteRunner: DPSuiteRunner) extends nest.Runn
350350
if (existsNerr) false
351351
else {
352352
val existsDiff = failureStates.exists({
353-
case CompFailedButWrongDiff() =>
353+
case CompFailedButWrongDiff =>
354354
nextTestActionFailing(s"output differs")
355355
true
356356
case _ =>

0 commit comments

Comments
 (0)