Hi,
not sure if this is a scala bug or is legit behaviour, just posting here hoping for somebody to shed a bit of light on this.
The following code compiles fine
Welcome to Scala 2.12.7 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_191).
Type in expressions for evaluation. Or try :help.
scala> import scala.language.implicitConversions
import scala.language.implicitConversions
scala>
scala> object Testing {
|
| implicit class FoableOps1(i: Int) { def foo(fooParam: String): String = "???" }
|
| implicit class FoableOps2(i: Int) { def foo(param1: String, param2: String): String = "!!!" }
|
| val t = 10.foo("")
|
| }
defined object Testing
But seems that when I call foo with the parameter name, the compiler complains with the following
scala> object Testing {
|
| implicit class FoableOps1(i: Int) { def foo(fooParam: String): String = "???" }
|
| implicit class FoableOps2(i: Int) { def foo(param1: String, param2: String): String = "!!!" }
|
| val t = 10.foo(fooParam = "")
|
| }
<console>:18: error: type mismatch;
found : Int(10)
required: ?{def foo: ?}
Note that implicit conversions are not applicable because they are ambiguous:
both method FoableOps2 in object Testing of type (i: Int)Testing.FoableOps2
and method FoableOps1 in object Testing of type (i: Int)Testing.FoableOps1
are possible conversion functions from Int(10) to ?{def foo: ?}
val t = 10.foo(fooParam = "")
^
<console>:18: error: not found: value fooParam
val t = 10.foo(fooParam = "")
^
Thanks!