Created
March 8, 2019 21:43
-
-
Save satorg/db931672501bf9291f12e99b881af97e to your computer and use it in GitHub Desktop.
Demonstrates a regression bug introduced by Scala 2.12.7 update
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.scalatest.Matchers._ | |
object SampleApp extends scala.App { | |
implicit class IterableOps[A](private val self: Iterable[A]) extends AnyVal { | |
def countUniqueItems: Map[A, Int] = ??? // implementation doesn't matter | |
} | |
// Fails to compile on Scala 2.12.7 and 2.12.8 with the following error: | |
// [error] <CUT>/scalatest-issue/src/main/scala/SampleApp.scala:13:24: could not find implicit value for parameter emptiness: org.scalatest.enablers.Emptiness[Map[A,Int]] | |
// [error] Nil.countUniqueItems shouldBe empty | |
// [error] ^ | |
Nil.countUniqueItems should have size 0 | |
// Compiles successfully | |
(Nil.countUniqueItems: Map[Nothing, Int]) shouldBe empty | |
//new IterableOps(Nil).countUniqueItems shouldBe empty | |
// Compiles as well | |
val ops = new IterableOps(Nil) | |
ops.countUniqueItems shouldBe empty | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment