4 ms·
Scala's compiler used to widen prematurely and apply implicit conversions similarly to what you described. Scala 3 doesn't do that [1]. The new inference algor
by jackcviers3 4y ago
Scala's compiler used to widen prematurely and apply implicit conversions similarly to what you described.
Scala 3 doesn't do that [1]. The new inference algorithm will, however, prefer a generic method over the same named method without a generic argument in scope when no typing hints are present in the source code when there are two possible matches for an inference completion. This can then cause problems when the generic expects some kind of given parameter:
def foo: String = ...
def foo[A:SomeRequiredThing]:A = ...
//in some other place
foo shouldBe("hello") // foo[String](using SomeRequiredThing[String])
// gets preferentially selected by the scala 3
// inference algorithm, which can lead to surprising
// though not "incorrect" results [also 1]
[1] https://www.youtube.com/watch?v=lMvOykNQ4zs https://www.youtube.com/watch?v=lMvOykNQ4zs