Turning the comment into an answer, the spec says both extensions are translated to def extension_doit
.
Calling the extension method explicitly:
-- [E044] Cyclic Error: so.scala:7:45 -----------------------
7 | extension(a: A) def doit() = a.bs.map(b => extension_doit(b)())
| ^
| Overloaded or recursive method extension_doit needs return type
This is the same error seen with debug of the original example:
>>>> StoredError: Overloaded or recursive method extension_doit needs return type
[snip]
-- [E008] Not Found Error: so.scala:7:42 --------------------
7 | extension(a: A) def doit() = a.bs.map(_.doit())
| ^^^^^^
| value doit is not a member of B.
| An extension method was tried, but could not be fully constructed:
|
| _$1
Overload resolution was explicitly improved or extended to handle this normal case of overloads which may be differentiated only in later parameter lists. So apparently we are supposed to be aware that the desugared form is overloaded.
Scala 2 also complains:
scala> object X { def f(i: Int) = f("") ; def f(s: String) = f(42) }
^
error: overloaded method f needs result type
^
error: overloaded method f needs result type