Open
Description
In Scala 3.5, assertEquals
doesn't enable to compareSet
of different types:
//> using dep org.scalameta::munit::1.0.1
class FooTest extends munit.FunSuite {
test("foo") {
assertEquals(Set(2: Any), Set(2))
}
}
Compiling project (test, Scala 3.5.0, JVM (17))
[error] ./foo.test.scala:5:5
[error] Can't compare these two types:
[error] First type: Set[Any]
[error] Second type: Set[Int]
[error] Possible ways to fix this error:
[error] Alternative 1: provide an implicit instance for Compare[Set[Any], Set[Int]]
[error] Alternative 2: upcast either type into `Any` or a shared supertype.
[error] I found:
[error]
[error] munit.Compare.compareSubtypeWithSupertype[Set[Any], Set[Int]](
[error] /* missing */summon[Set[Any] <:< Set[Int]])
[error]
[error] But no implicit values were found that match type Set[Any] <:< Set[Int].
[error] assertEquals(Set(2: Any), Set(2))
[error] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[[syntax trees at end of typer]] // /Users/mbovel/munit-bug/foo.test.scala
package <empty> {
class FooTest() extends munit.FunSuite() {
this.test("foo")(
{
{
val obtained$1: Set[Any] = Set.apply[Any]([2:Any : Any]*)
val expected$1: Set[Int] = Set.apply[Int]([2 : Int]*)
def clue$1: String = this.assertEquals$default$3[Set[Any], Set[Int]]
this.assertEquals[Set[Any], Set[Int]](obtained$1, expected$1, clue$1)(
loc = munit.Location.generate,
munit.Compare.compareSubtypeWithSupertype[Set[Any], Set[Int]](
/* missing */summon[Set[Any] <:< Set[Int]])
)
}
}
)
}
}
Error compiling project (test, Scala 3.5.0, JVM (17))
Compilation failed
This is because in 3.5, the B
type parameter of assertEquals
is inferred to be Set[Int]
instead of Set[Any]
as in 3.3
assertEquals
's signature:
munit/munit/shared/src/main/scala/munit/Assertions.scala
Lines 91 to 95 in b02ef31
Instances of Compare
are defined as:
munit/munit/shared/src/main/scala/munit/Compare.scala
Lines 104 to 108 in b02ef31
munit/munit/shared/src/main/scala/munit/Compare.scala
Lines 116 to 120 in b02ef31
Metadata
Assignees
Labels
No labels