I found a strange behavior of compiler. The minimal code snippet that I was able to create is
trait Accessor:
def get[T](using parser: Parser[T]): T = parser(this)
type Parser[T] = Accessor => T
trait Configurable
given ParserString: Parser[String] = ???
given ParserConfigurable[T <: Configurable]: Parser[T] = ???
given ParserInt: Parser[Int] = accessor => Integer.parseInt(accessor.get[String])
The error is
[error] 12 |given ParserInt: Parser[Int] = accessor => Integer.parseInt(accessor.get[String])
[error] | ^
[error] |ambiguous implicit arguments: both given instance ParserString and given instance ParserConfigurable match type Parser[String] of parameter parser of method get in trait Accessor
[error] one error found
[error] one error found
[error] (Compile / compileIncremental) Compilation failed
Probably it is my misunderstanding how generic generic given instances should work, but for me this piece of code should be compiled because string does not implement Configurable, and therefore ParserConfigurable should not match type Parser[String].
Could you please kindly tell me if I met a compiler bug or it is an expected behavior and I need to change my code?