Closed
Description
Minimized code
import scala.reflect.Selectable.reflectiveSelectable
object Test {
def main(args: Array[String]): Unit = {
def fCompareToBoolean(x: { def compareTo(y: java.lang.Boolean): Int }, y: Boolean): Int =
x.compareTo(y)
assert(fCompareToBoolean(false, true) < 0)
}
}
Output
-- Error: tests/run/hello.scala:7:29 -------------------------------------------
7 | assert(fCompareToBoolean(false, true) < 0)
| ^^^^^
|the result of an implicit conversion must be more specific than Object{compareTo(y: Boolean): Int}
1 error found
Expectation
The code compiles and runs successfully, as it does on Scala 2.
Notes
Implicit conversions to Any/AnyVal/AnyRef
were disallowed in #8453 to fix the issue #6336. Apparently the introduced check was too strict, as it also disallows implicit conversions to refinements, which Scala 2 doesn't do.
This was discovered while trying to enable the Scala.js test ReflectiveCallsTest.scala
, but the issue arises on the JVM as well.