Support when only 1 overload has contextual parameters

A use case for contextual parameters mixed with overloads is currently not possible.

def f(x: Int) = "a"
def f(x: (n: Int) ?=> Int) = "b"

f(10) // "a" - selects the first overload
f(n * 3) // error - Not found 'n'

I didn’t expect this result. I expected f(n * 3) = "b". I think it would be reasonable for the compiler to assume the first overload in the absence of any occurence of n, but select the second overload when n is in the expression.

They must be overloads, because in my use cases it is important that the base function has different behavior.

Usually static overload resolution doesn’t consider the argument that was applied.

scala> object X { def f(x: (n: Int) ?=> Int) = x(using 42); def f(x: Int) = (x * 2).toString }
// defined object X

scala> X.f(3)
val res0: String = 6

scala> X.f((x: Int) ?=> x+1)
-- [E051] Reference Error: -----------------------------------------------------
1 |X.f((x: Int) ?=> x+1)
  |^^^
  |Ambiguous overload. The overloaded alternatives of method f in object X with types
  | (x: Int): String
  | (x: (n: Int) ?=> Int): Int
  |both match arguments ((Int) ?=> Int)
  |
  | longer explanation available when compiling with `-explain`
1 error found

It works for functions

scala> object X { def f(x: (n: Int) => Int) = x(42); def f(x: Int) = (x * 2).toString }
// defined object X

scala> X.f(_ + 1)
val res1: Int = 43

Maybe the “shape test” could be made to work for context functions.

I’d be surprised if testing for a ref could work well. Consider

def f(g: Int ?=> Int) = ???

where the contextual parameter is not named.