You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
objectOne:deff():Int=1deff()(usingBoolean):Int=2valx1= f()
objectTwo:givenf():Int=1givenf()(usingBoolean):Int=2valx2= f()
objectThree:givenf:Int=1givenf(usingBoolean):Int=2valx3= f
objectFour:givenUnit= ()
givenf(usingUnit):Int=1givenf(usingUnit, Boolean):Int=2valx4= f
Output
Compiling with scala-cli, the compiler reports ambiguous overloads in the calls to One.f, Two.f, and Four.f.
Compiling with scalac, the compiler reports ambiguous overloads in the calls to One.f and Four.f, and a missing given instance in Two.f.
Expectation
While the ambiguity in One may be expected, those in Two and Four aren't. Further, the errors reported by the compiler should be consistent across scala-cli and scalac.
I also find it puzzling that the call to Four.f is reported ambiguous.
In Two, note that printing the output of the typer reveals that the parameter list of the first definition of f has been (possibly incorrectly) erased. That explains the error reported by scalac because now calling f with parentheses excludes the first definition.
final module class Two() extends Object() { this: Two.type =>
final given def f: Int = 1
final given def f()(using x$1: Boolean): Int = 2
val x2: <error no implicit values were found that match type Boolean> =
Two.f()(/* missing */summon[Boolean])
}
Compiler version
Scala compiler version 3.6.1
Minimized code
Consider the following:
Output
Compiling with
scala-cli
, the compiler reports ambiguous overloads in the calls toOne.f
,Two.f
, andFour.f
.Compiling with
scalac
, the compiler reports ambiguous overloads in the calls toOne.f
andFour.f
, and a missing given instance inTwo.f
.Expectation
While the ambiguity in
One
may be expected, those inTwo
andFour
aren't. Further, the errors reported by the compiler should be consistent acrossscala-cli
andscalac
.I also find it puzzling that the call to
Four.f
is reported ambiguous.In
Two
, note that printing the output of the typer reveals that the parameter list of the first definition off
has been (possibly incorrectly) erased. That explains the error reported byscalac
because now callingf
with parentheses excludes the first definition.Relevant link to the specification: https://docs.scala-lang.org/scala3/reference/changed-features/implicit-resolution.html
The text was updated successfully, but these errors were encountered: