Skip to content

Commit 1be7624

Browse files
authored
Fix the first example under "Parameter Types of Function Values"
The example had two issues: 1. It used `f` both as the name of the method and the argument. While it compiled, it seemed unnecessarily confusing to overload that name. So I changed the name of the function argument to +f2+. 2. The example failed to compile because it passed +String+ and +String => Int+ arguments. I fixed the example and added another one example for +Int+ and +Int => Int+ arguments.
1 parent dfcc0b1 commit 1be7624

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

docs/docs/reference/changed-features/overload-resolution.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ that the remaining parameters suffice for picking a variant of the overloaded fu
5252
For example, the following code compiles in Dotty, while it results in an
5353
missing parameter type error in Scala2:
5454
```scala
55-
def f(x: Int, f: Int => Int) = f(x)
56-
def f(x: String, f: String => String) = f(x)
57-
f("a", _.length)
55+
def f(x: Int, f2: Int => Int) = f2(x)
56+
def f(x: String, f2: String => String) = f2(x)
57+
f("a", _.toUpperCase)
58+
f(2, _ * 2)
5859
```
5960
To make this work, the rules for overloading resolution in section 6.23.3 of the SLS are modified
6061
as follows:

0 commit comments

Comments
 (0)