File tree Expand file tree Collapse file tree 3 files changed +47
-0
lines changed
docs/reference/changed-features Expand file tree Collapse file tree 3 files changed +47
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ layout : doc-page
3+ title : " Changes in Overload Resolution"
4+ ---
5+
6+ Overload resolution in Dotty takes all argument blocks into account instead of
7+ just the first argument block.
8+
9+ For example, the following code compiles in Dotty, while it results in an
10+ ambiguous overload error in Scala2:
11+
12+ ``` Scala
13+ def f (x : Int )(y : String ): Int = 0
14+ def f (x : Int )(y : Int ): Int = 0
15+
16+ f(3 )(" " ) // ok
17+ ```
18+
19+ The following code compiles as well:
20+
21+ ``` Scala
22+ def g (x : Int )(y : Int )(z : Int ): Int = 0
23+ def g (x : Int )(y : Int )(z : String ): Int = 0
24+
25+ g(2 )(3 )(4 ) // ok
26+ g(2 )(3 )(" " ) // ok
27+ ```
28+
29+ This change is motivated by the new language feature [ extension
30+ methods] ( ../contextual/extension-methods.html ) , where emerges the need to do
31+ overload resolution based on additional argument blocks.
Original file line number Diff line number Diff line change @@ -99,6 +99,8 @@ sidebar:
9999 url : docs/reference/changed-features/implicit-resolution.html
100100 - title : Implicit Conversions
101101 url : docs/reference/changed-features/implicit-conversions.html
102+ - title : Overload Resolution
103+ url : docs/reference/changed-features/overload-resolution.html
102104 - title : Vararg Patterns
103105 url : docs/reference/changed-features/vararg-patterns.html
104106 - title : Pattern matching
Original file line number Diff line number Diff line change 1+ class Test {
2+ def f (x : Int )(y : String ): Int = ???
3+ def f (x : Int )(y : Int ): Int = ???
4+
5+ f(3 )(" " ) // ok
6+ f(3 )(4 ) // ok
7+
8+ def g (x : Int )(y : Int )(z : Int ): Int = ???
9+ def g (x : Int )(y : Int )(z : String ): Int = ???
10+
11+ g(2 )(3 )(4 ) // ok
12+ g(2 )(3 )(" " ) // ok
13+ }
14+
You can’t perform that action at this time.
0 commit comments