scala3
scala3 copied to clipboard
Regression as side-effect of mapping context bounds to using arguments
Based on OpenCB failure in paulbutcher/scalamock
It seems like a side effect of changing mapping for context bounds is a different behaviour when using overloaded functions. Previously compiler seemed to try apply non-implicit arguments whenever implicit ones were not applicable. Now only the first overload is chosen.
Behaves the same under Scala 3.5 with -source:future which is expected.
Compiler version
3.6 nightly Bisect points to b8f9c2c2cc17abc1caf14199dfd67ca28130aef2
Minimized code
import scala.language.implicitConversions
trait MockFunctions:
protected case class FunctionName(name: String)
protected implicit def functionName(name: String): FunctionName = ???
protected def mockFunction[T1, R: Defaultable](name: FunctionName): MockFunction1[T1, R] = ???
protected def mockFunction[T1, R: Defaultable]: MockFunction1[T1, R] = ???
trait Defaultable[T]
object Defaultable:
given Defaultable[Unit] = ???
class MockFunction1[T1, R](name: Symbol):
def apply(v1: T1): R = ???
@main def Test = new MockFunctions {
val infer = mockFunction[String, Unit]("mockFun")
val fails: MockFunction1[String, Unit] = infer
}
Output
[error] ./test.scala:17:46
[error] Found: (infer : Unit)
[error] Required: MockFunction1[String, Unit]
[error] val fails: MockFunction1[String, Unit] = infer