You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/multi-source-extension-overloads.md
+39-4Lines changed: 39 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -157,7 +157,37 @@ For the same reason, we do not propose to change regular calls of methods that h
157
157
158
158
### Specification
159
159
160
-
From the [specification of extension methods](https://docs.scala-lang.org/scala3/reference/contextual/extension-methods.html#translation-of-calls-to-extension-methods), we amend step 1. of "The precise rules for resolving a selection to an extension method are as follows."
160
+
We make two changes to the [specification of extension methods](https://docs.scala-lang.org/scala3/reference/contextual/extension-methods.html).
161
+
162
+
In the section [Translation of Extension Methods](https://docs.scala-lang.org/scala3/reference/contextual/extension-methods.html#translation-of-extension-methods), we make it clearer that the "desugared" version of the call site may require an explicit qualifier.
163
+
This is not strictly a novelty of this SIP, since it could already happen with `given`s and implicit scopes, but this SIP adds one more case where this can happen.
164
+
165
+
Previously:
166
+
167
+
> So, the definition of circumference above translates to the following method, and can also be invoked as such:
> for some `qualifierPath` in which `circumference` is actually declared.
186
+
> Explicit qualifiers may be required when the extension method is resolved through `given` instances, implicit scopes, or disambiguated from several imports.
187
+
188
+
---
189
+
190
+
In the section [Translation of Calls to Extension Methods](https://docs.scala-lang.org/scala3/reference/contextual/extension-methods.html#translation-of-calls-to-extension-methods), we amend step 1. of "The precise rules for resolving a selection to an extension method are as follows."
161
191
162
192
Previously:
163
193
@@ -180,16 +210,21 @@ With this SIP:
180
210
The proposal only alters situations where the previous specification would reject the program with an ambiguous import.
181
211
Therefore, we expect it to be backward source compatible.
182
212
183
-
The resolved calls could previously be spelled out by hand (with fully-qualified names), so binary and TASTy compatibility are not affected.
213
+
The resolved calls could previously be spelled out by hand (with fully-qualified names), so binary compatibility and TASTy compatibility are not affected.
214
+
215
+
### Other concerns
216
+
217
+
With this SIP, some calls that would be reported as *ambiguous* in their "normal" form can actually be written without ambiguity if used as extensions.
218
+
That may be confusing to some users.
219
+
Although specific error messages are not specified and therefore outside the SIP scope, we encourage the compiler implementation to enhance the "ambiguous" error message to address this confusion.
220
+
If some or all of the involved ambiguous targets are `extension` methods, the compiler should point out that the call might be resolved unambiguously if used as an extension.
184
221
185
222
## Alternatives
186
223
187
224
A number of alternatives were mentioned in [the Contributors thread](https://contributors.scala-lang.org/t/change-shadowing-mechanism-of-extension-methods-for-on-par-implicit-class-behavior/5831), but none that passed the bar of "we think this is actually implementable".
188
225
189
226
## Related work
190
227
191
-
This section should list prior work related to the proposal, notably:
192
-
193
228
-[Contributors thread acting as de facto Pre-SIP](https://contributors.scala-lang.org/t/change-shadowing-mechanism-of-extension-methods-for-on-par-implicit-class-behavior/5831)
194
229
-[Pull Request in dotty](https://github.com/lampepfl/dotty/pull/17050) to support it under an experimental import
0 commit comments