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
Make SIP-62 - betterFors a standard feature (#22652)
- Deprecate experimental language import
- Make betterFors conditional on `-source >= 3.7` instead
- Drop the `experimental.betterFors` import from tests
&& rest.dropWhile(_.isInstanceOf[GenAlias]).headOption.forall(e => e.isInstanceOf[GenFrom]) =>// possible aliases followed by a generator or end of for
2177
+
if sourceVersion.isAtLeast(`3.7`)
2178
+
&& rest.dropWhile(_.isInstanceOf[GenAlias]).headOption.forall(e => e.isInstanceOf[GenFrom]) // possible aliases followed by a generator or end of for
The `betterFors` language extension improves the usability of `for`-comprehensions.
8
-
9
-
The extension is enabled by the language import `import scala.language.experimental.betterFors` or by setting the command line option `-language:experimental.betterFors`.
7
+
Starting in Scala `3.7`, the usability of `for`-comprehensions is improved.
10
8
11
9
The biggest user facing change is the new ability to start `for`-comprehensions with aliases. This means that the following previously invalid code is now valid:
12
10
@@ -30,11 +28,11 @@ for
30
28
yield a + b
31
29
```
32
30
33
-
Additionally this extension changes the way `for`-comprehensions are desugared. The desugaring is now done in a more intuitive way and the desugared code can be more efficient, because it avoids some unnecessary method calls. There are two main changes in the desugaring:
31
+
Additionally, this extension changes the way `for`-comprehensions are desugared. The desugaring is now done in a more intuitive way and the desugared code can be more efficient, because it avoids some unnecessary method calls. There are two main changes in the desugaring:
34
32
35
33
1.**Simpler Desugaring for Pure Aliases**:
36
34
When an alias is not followed by a guard, the desugaring is simplified. The last generator and the aliases don't have to be wrapped in a tuple, and instead the aliases are simply introduced as local variables in a block with the next generator.
0 commit comments