Open
Description
Compiler version
3.3.0-RC1-bin-20221224-6f5bb34-NIGHTLY
Minimized code
//> using scala "3.3.0-RC1-bin-20221224-6f5bb34-NIGHTLY"
trait Ctx
def bar(f1: Ctx => Int) = ???
def bar(f1: Ctx => Int, f2: Ctx => Int) = ???
def baz(f1: Ctx ?=> Int) = ???
def baz(f1: Ctx ?=> Int, f2: Ctx ?=> Int) = ???
def qux(f1: Ctx => Int) = ???
def qux(fs: (Ctx => Int)*) = ???
def quz(f1: Ctx ?=> Int) = ???
def quz(fs: (Ctx ?=> Int)*) = ???
val a1 = bar(_ => 1)
val a2 = bar(_ => 1, _ => 2)
val b1 = baz(_ ?=> 1)
val b2 = baz(_ ?=> 1, _ ?=> 2)
val c1 = baz(1)
val c2 = baz(1, 2)
val d1 = qux(_ => 1)
val d2 = qux(_ => 1, _ => 2)
val e1 = quz(_ ?=> 1)
val e2 = quz(_ ?=> 1, _ ?=> 2)
val f1 = quz(1)
val f2 = quz(1, 2)
Output
[error] ./Overload.scala:29:10: None of the overloaded alternatives of method quz with types
[error] (fs: ((Ctx) ?=> Int)*): Nothing
[error] (f1: (Ctx) ?=> Int): Nothing
[error] match arguments (<?> => <?>)
[error] val e1 = quz(_ ?=> 1)
[error] ^^^
[error] ./Overload.scala:32:10: None of the overloaded alternatives of method quz with types
[error] (fs: ((Ctx) ?=> Int)*): Nothing
[error] (f1: (Ctx) ?=> Int): Nothing
[error] match arguments ((1 : Int))
[error] val f1 = quz(1)
[error] ^^^
Expectation
The snippet should compile.
Following the discussion in #16511 I understand that in case of method overloading we cannot rely on the actual type of method parameters to distinguish between two variants of the same method when context functions are involved. However we should be able to use the number of parameters instead and normally the compiler has no problem with that unless it has to deal with context functions and varargs vs a single argument at the same time.
I would also expect the PR linked above to have fixed case e1
as an explicit context lambda is used there but unfortunately it didn't solve the problem.