Skip to content

Commit 164eea5

Browse files
committed
Make SIP 54 a standard feature
- Drop experimental language import - Change note in docs to say that this relaxation only applies to extension method calls, not extension methods called as normal methods. I tried to also reflect the second point in error messages but it turned out too hard. At the point where we generate the error message we do not know how the method was called and it would be unsystematic to create that side channel. In fact, information flows the other way: When we resolve an extension method name, we buffer the error messages and fix selected AmbiguityErrors.
1 parent d02ecd0 commit 164eea5

File tree

4 files changed

+3
-11
lines changed

4 files changed

+3
-11
lines changed

compiler/src/dotty/tools/dotc/config/Feature.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ object Feature:
2929
val fewerBraces = experimental("fewerBraces")
3030
val saferExceptions = experimental("saferExceptions")
3131
val clauseInterleaving = experimental("clauseInterleaving")
32-
val relaxedExtensionImports = experimental("relaxedExtensionImports")
3332
val pureFunctions = experimental("pureFunctions")
3433
val captureChecking = experimental("captureChecking")
3534
val into = experimental("into")

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
260260
then
261261
altImports.uncheckedNN += altImp
262262

263-
if Feature.enabled(Feature.relaxedExtensionImports) && altImports != null && ctx.isImportContext then
263+
if altImports != null && ctx.isImportContext then
264264
val curImport = ctx.importInfo.uncheckedNN
265265
namedImportRef(curImport) match
266266
case altImp: TermRef =>

docs/_docs/reference/contextual/extension-methods.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,8 @@ The following two rewritings are tried in order:
254254
not a wildcard import, pick the expansion from that import. Otherwise, report
255255
an ambiguous reference error.
256256

257-
**Note**: This relaxation is currently enabled only under the `experimental.relaxedExtensionImports` language import.
257+
**Note**: This relaxation of the import rules applies only if the method `m` is used as an extension method. If it is used as a normal method in prefix form, the usual import rules apply, which means that importing `m` from
258+
multiple places can lead to an ambiguity error.
258259

259260
2. If the first rewriting does not typecheck with expected type `T`,
260261
and there is an extension method `m` in some eligible object `o`, the selection is rewritten to `o.m[Ts](e)`. An object `o` is _eligible_ if

library/src/scala/runtime/stdLibPatches/language.scala

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,6 @@ object language:
6969
@compileTimeOnly("`clauseInterleaving` can only be used at compile time in import statements")
7070
object clauseInterleaving
7171

72-
/** Adds support for relaxed imports of extension methods.
73-
* Extension methods with the same name can be imported from several places.
74-
*
75-
* @see [[http://dotty.epfl.ch/docs/reference/contextual/extension-methods]]
76-
*/
77-
@compileTimeOnly("`relaxedExtensionImports` can only be used at compile time in import statements")
78-
object relaxedExtensionImports
79-
8072
/** Experimental support for pure function type syntax
8173
*
8274
* @see [[https://dotty.epfl.ch/docs/reference/experimental/purefuns]]

0 commit comments

Comments
 (0)