Skip to content

Sync with the stable documentation branch #23120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 517 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
517 commits
Select commit Hold shift + click to select a range
76cd2dc
Add changelog for 3.4.2-RC1
Kordyjan Mar 28, 2024
4029577
Release 3.4.2-RC1
Kordyjan Mar 28, 2024
1205601
Merge branch 'release-3.4.1' into language-reference-stable
Kordyjan Mar 29, 2024
cbd8408
Improve documentation of implicit conversions
rjolly Apr 5, 2024
56b276f
Implement match type amendment: extractors follow aliases and singletons
smarter Apr 10, 2024
bfa1852
Move logic under feature.experimental.betterMatchTypesExtractors
Kordyjan May 9, 2024
3e1c4de
DropSkolemMap: simplify logic
smarter May 7, 2024
11f01d2
Deprecate `StandardPlugin.init` in favor of `initialize` method takin…
WojciechMazur May 8, 2024
5fdfb97
New modularity language import
odersky Jan 7, 2024
813af69
Allow vals in using clauses of givens
odersky Nov 18, 2023
b5d48fd
A relaxation concerning exported type aliases
Kordyjan May 9, 2024
48e2aa7
Allow class parents to be refined types.
odersky Dec 13, 2023
96c76e9
Introduce tracked class parameters
odersky Apr 1, 2024
70fb91c
Make explicit arguments for context bounds an error from 3.5
odersky Apr 1, 2024
90e84b9
Drop restriction against typedefs at level * only
odersky Apr 1, 2024
62eed87
Allow types in given definitions to be infix types
odersky Apr 1, 2024
305dd2e
New syntax for given defs
odersky Apr 1, 2024
22b681c
Allow multiple context bounds in `{...}`
odersky Apr 1, 2024
a57a512
Allow renamings `as N` in context bounds
odersky Apr 2, 2024
9a96cf0
Implement `deferred` givens
odersky Apr 2, 2024
6016ce9
FIX: Allow ContextBoundParamNames to be unmangled.
odersky Apr 2, 2024
81679fa
Change rules for given prioritization
odersky Dec 21, 2023
555f67c
Allow context bounds in type declarations
odersky Apr 2, 2024
3437526
Make some context bound evidence params tracked
odersky Apr 2, 2024
d856e50
FIX: Fix typing of RefinedTypes with watching parents
odersky Apr 2, 2024
5fe6b5b
Also reduce term projections
odersky Jan 6, 2024
becdf88
Implement context bound companions
odersky Apr 2, 2024
5f3ff9f
Allow contecxt bounds with abstract `Self` types
odersky Apr 2, 2024
9d299d6
Add a doc page
odersky Apr 3, 2024
a6f918b
Fix Singleton
odersky Apr 5, 2024
0c941e2
Tweaks to doc pages
odersky Apr 6, 2024
09a6a26
Add Precise type class for precise type inference
odersky Apr 6, 2024
e82cfbe
Fix rebase breakage
odersky Apr 14, 2024
3b814bb
Delay roll-out of new prioritization scheme:
odersky Apr 17, 2024
a8f7585
Fix rebase breakage again
odersky Apr 28, 2024
dd8061f
Make best effort compilation work with context bound companions
odersky Apr 28, 2024
04d4023
Tweaks after review
odersky Apr 30, 2024
ff98f01
Fix rebase breakage
odersky May 6, 2024
0bcf69c
Make Singleton an erased class only under modularity import
odersky May 6, 2024
42de370
Address review comments
odersky May 6, 2024
6521822
Adress review comments with changed docs and new tests
odersky May 6, 2024
46c3eca
Update warn check files
odersky May 7, 2024
97afac0
Update InlayHints
odersky May 7, 2024
8482eb1
Fix typo
odersky May 7, 2024
cb37a1f
step 1: basic script that forwards to prebuilt launcher and overrides…
bishabosha Apr 22, 2024
1784e67
Resolve artefacts to a local repo:
bishabosha Apr 25, 2024
10bd87f
use scala-cli jar launcher (TODO: download automatically)
bishabosha Apr 26, 2024
237a592
refactor republishing to a plugin
bishabosha Apr 26, 2024
34e8fc5
download and cache launcher, add scalajs library
bishabosha Apr 29, 2024
4682b52
fix project/scripts/bootstrappedOnlyCmdTests for new scala launcher
bishabosha Apr 30, 2024
c6cc0a3
fix bash script tests
bishabosha May 3, 2024
eee90b4
escape % in java executable path in batch commands.
bishabosha May 6, 2024
eb3083b
Add a warning message when launching from scala.
bishabosha May 6, 2024
8daca0c
Windows - extract scala version from VERSION file
bishabosha May 6, 2024
b3d9aee
Windows - forward to scala-cli jar launcher
bishabosha May 6, 2024
230a078
properly convert path of repo to uri
bishabosha May 6, 2024
20009db
fix windows command tests
bishabosha May 7, 2024
cfbee38
adjust to new launcher scala cli 1.3.1
bishabosha May 7, 2024
205d045
remove scala-js from local caching
bishabosha May 7, 2024
fd672eb
escape error message in test
bishabosha May 7, 2024
95e53df
Disable windows tests for RC1
Kordyjan May 10, 2024
d08d71b
Filter out the dot directories form tests
Kordyjan May 10, 2024
638d15a
Add changelog for 3.4.2
Kordyjan May 13, 2024
0f7f990
Release 3.4.2
Kordyjan May 13, 2024
4ebe8f4
Take into account the version when releasing in the CI
hamzaremmal May 14, 2024
782d1f6
Add changelog for 3.5.0-RC1
Kordyjan May 14, 2024
a15fc7d
Release 3.5.0-RC1
Kordyjan May 14, 2024
473897c
Merge branch 'release-3.4.2' into language-reference-stable
Kordyjan May 16, 2024
4992e37
Backport: Avoid forcing whole package when using `-experimental`
smarter May 14, 2024
7885c24
This reverts one part of #20261. When we fail with both an ambiguity …
WojciechMazur Jun 17, 2024
f913d89
Treat 3.5-migration the same as 3.5 for a warning about implicit prio…
WojciechMazur Jun 17, 2024
0626b97
Set default source version to 3.5
WojciechMazur Jun 17, 2024
6c75005
Disable ClasspathTests.unglobClasspathVerifyTest (#20551)
hamzaremmal Jun 11, 2024
aac98c9
Adapt the release workflow to SIP-46 (#20565)
hamzaremmal Jun 14, 2024
edbb7c4
Adapts the workflow to the changes in #20351
WojciechMazur Jun 17, 2024
e005369
Avoid stacked thisCall contexts
odersky May 28, 2024
665bd20
Bundle scala cli in scala command (#20351)
bishabosha Jun 11, 2024
6fd3950
Backport "Bundle scala cli in scala command" to 3.5.0 (#20706)
WojciechMazur Jun 21, 2024
3d18e98
Revert "Disable windows tests for RC1"
WojciechMazur Jun 21, 2024
278559f
Revert "Disable windows tests for RC1" (#20708)
WojciechMazur Jun 21, 2024
df91f07
Fix incorrect paths to sha256 check sum files in release workflow
WojciechMazur Jun 21, 2024
1520e88
Add changelog for 3.5.0-RC2
WojciechMazur Jun 21, 2024
828c03e
Release 3.5.0-RC2
WojciechMazur Jun 21, 2024
ecf5a2e
Release .zip instead of .tar.gz for windows in sdkman
hamzaremmal Jun 19, 2024
3ecd982
Do not release to the UNIVERSAL platform in sdkman
hamzaremmal Jun 19, 2024
0a7b7fe
Upload zip files to sdkman instead of .tar.gz
hamzaremmal Jun 21, 2024
a9af5cc
replace pack command, do not produce lib directory, write classpath t…
bishabosha Jun 19, 2024
f7e72af
add back in copy of mapped sequence
bishabosha Jun 21, 2024
81e3cc4
read last line, split-off with-compiler classpath
bishabosha Jun 21, 2024
e74d681
Bump scala-cli to 1.4.0 (#20859)
hamzaremmal Jul 1, 2024
3f8e3f5
Backport "Release .zip instead of .tar.gz for windows in sdkman" to 3…
WojciechMazur Jul 2, 2024
e2674a8
Backport "SIP 46 - read classpath from file, remove lib directory in …
WojciechMazur Jul 2, 2024
c48b224
Backport "Bump scala-cli to 1.4.0" to 3.5.0 (#20909)
WojciechMazur Jul 2, 2024
d470b77
Fix failing CompletionScalaCliSuite tests due to circe releasing Scal…
WojciechMazur Jul 1, 2024
edc8cbc
Ignore failing tests instead of expecting for completions for both 0.…
WojciechMazur Jul 2, 2024
1591ac9
fix issue 20901: etaCollapse context bound type
bishabosha Jul 1, 2024
f8a2e56
update semanticdb test (restore references)
bishabosha Jul 1, 2024
a5c74e7
use Scala 2.13.13 stdlib (was .12)
SethTisue Feb 26, 2024
b357bc9
Upgrade Scala 2 to 2.13.14
WojciechMazur Jul 1, 2024
dcf708c
Phiscally remove the ignored Scala 2 library-aux files instead of fil…
WojciechMazur Jul 1, 2024
c042e57
Add --skip-cli-updates by default to the scala command
hamzaremmal Jul 1, 2024
91b8abd
Avoid useless warnings about priority change in implicit search
odersky May 25, 2024
9354ad5
Re-enable semanticdb test
odersky May 27, 2024
7ac5417
Update semanticDB expect files
odersky May 27, 2024
0b812bd
Drop priority change warnings that don't qualify
odersky May 28, 2024
1d993a7
Add test for #20484
odersky May 28, 2024
b4f3a7b
Backport "Priority warning fix alternative" to 3.5.0 (#20953)
WojciechMazur Jul 3, 2024
dea855f
Backport "Add --skip-cli-updates by default to the scala command" to …
WojciechMazur Jul 3, 2024
7560c46
Backport "Upgrade Scala 2 to 2.13.14 (was 2.13.12)" to 3.5.0 (#20955)
WojciechMazur Jul 3, 2024
9ca1d0a
Backport "fix issue 20901: etaCollapse context bound type" to 3.5.0 (…
WojciechMazur Jul 3, 2024
3677eaf
Use final result type to check selector bound
som-snytt Jul 3, 2024
f4bde0b
Backport "Use final result type to check selector bound" to 3.5.0 (#2…
WojciechMazur Jul 4, 2024
876b648
Add changelog for 3.5.0-RC3
WojciechMazur Jul 3, 2024
6abb51a
Release 3.5.0-RC3
WojciechMazur Jul 4, 2024
7a19b32
Fix symbol reference retrivial of `scala.caps.Caps` - it was changed …
WojciechMazur May 29, 2024
ec87e7d
Refine implicit priority change warnings
odersky Jul 5, 2024
3e1ed72
Fix -source for neg test
odersky Jul 5, 2024
450d233
Filter out more false positives in priority change warnings
odersky Jul 5, 2024
acffad6
Fix priority change logic for ranking
odersky Jul 8, 2024
dc9246a
Fix -source for neg test (2)
odersky Jul 5, 2024
22d9df0
Use pathing jars in cli commands
hamzaremmal Jul 8, 2024
1910ea9
Add support for Class-Path entries in Manifest
hamzaremmal Jul 8, 2024
1a1a77f
expand classpath in scala_legacy
bishabosha Jul 10, 2024
2084ccf
Backport "Fix symbol reference retrivial of `scala.caps.Caps`" to 3.5…
WojciechMazur Jul 11, 2024
744b1b7
Backport "Refine implicit priority change warnings" to 3.5.0 (#21171)
WojciechMazur Jul 11, 2024
a578242
Backport "Use pathing jars in cli commands" to 3.5.0 (#21172)
WojciechMazur Jul 11, 2024
32fd2ba
Backport "expand classpath of pathing jars in scala_legacy command " …
WojciechMazur Jul 11, 2024
fad86e3
Add changelog for 3.5.0-RC4
WojciechMazur Jul 11, 2024
97fc22c
Release 3.5.0-RC4
WojciechMazur Jul 11, 2024
a5514c5
emit generatedNonLocalClass in backend when callback is not enabled
bishabosha Jul 12, 2024
7342816
add test to assert classes are still reported
bishabosha Jul 16, 2024
137be13
Backport "emit generatedNonLocalClass in backend when callback is not…
WojciechMazur Jul 17, 2024
1e20d47
Add changelog for 3.5.0-RC5
WojciechMazur Jul 17, 2024
8e6b582
Release 3.5.0-RC5
WojciechMazur Jul 17, 2024
3c29355
Improve documentation of implicit conversions (#20336)
sjrd Jul 22, 2024
318054e
Revert "Approximate MatchTypes with lub of case bodies, if non-recurs…
WojciechMazur Jul 24, 2024
51629a2
Fix failing run-macros/type-show test
WojciechMazur Jul 24, 2024
6eac278
Revert "Approximate MatchTypes with lub of case bodies, if non-recurs…
WojciechMazur Jul 29, 2024
6a5e6e6
Add changelog for 3.5.0-RC6
WojciechMazur Jul 29, 2024
1fb613f
Release 3.5.0-RC6
WojciechMazur Jul 29, 2024
b079b11
Prefer extensions over conversions and implicits for member selection
EugeneFlesselle Jul 18, 2024
07ccc8d
A left-biased variant for implicit/given pairs
odersky Aug 5, 2024
8a41389
Compensate loss of transitivity
odersky Aug 5, 2024
0f0c20d
Delay priority change until 3.7
odersky Aug 5, 2024
f683458
Fix ranking logic
odersky Aug 6, 2024
33d7da8
Make priority change warning messages stable
odersky Aug 6, 2024
d439b58
Fix `healAmbiguous` to `compareAlternatives` with `disambiguate = true`
EugeneFlesselle Aug 6, 2024
73c6e88
Adjust compilation tests to backported changes
WojciechMazur Aug 7, 2024
a1882e1
Revert "Compensate loss of transitivity"
WojciechMazur Aug 7, 2024
95caecb
Backport "Fix healAmbiguous to compareAlternatives with disambiguate …
WojciechMazur Aug 8, 2024
d72e8e0
Add changelog for 3.5.0-RC7
WojciechMazur Aug 8, 2024
19534db
Release 3.5.0-RC7
WojciechMazur Aug 8, 2024
180deab
Add changelog for 3.5.0
Kordyjan Aug 12, 2024
834c973
Release 3.5.0
Kordyjan Aug 12, 2024
7590f91
Update hamzaremmal/sdkman-release-action action
hamzaremmal Aug 21, 2024
9da1ae8
Update hamzaremmal/sdkman-release-action & hamzaremmal/sdkman-default…
hamzaremmal Aug 21, 2024
7513ab5
Merge branch 'release-3.5.0' into language-reference-stable
WojciechMazur Aug 21, 2024
8dcaed1
Sync with 3.5.0 release
WojciechMazur Aug 21, 2024
80e09f7
Regenerate reference-expected-links after 3.5.0 merge
WojciechMazur Aug 21, 2024
b43f630
Backport "Make context bounds for poly functions a standard feature" …
WojciechMazur Dec 9, 2024
e07cab5
Backport "Update Scala CLI to 1.5.4 (was 1.5.1) & `coursier` to 2.1.1…
WojciechMazur Dec 9, 2024
9fd972d
Backport "Make named tuples an experimental feature again" to 3.6 (#2…
WojciechMazur Dec 9, 2024
de83e56
Backport "Fix CLA checks after domain change of CLA check server" to …
WojciechMazur Dec 9, 2024
954fd34
Replace deprecated actions/create-release and `actions/upload-release…
WojciechMazur Dec 9, 2024
6b8d86f
Add changelog for 3.6.3-RC1
WojciechMazur Dec 9, 2024
0bcc325
Release 3.6.3-RC1
WojciechMazur Dec 9, 2024
beb40d8
REPL: JLine: follow recommendation to use JNI, not JNA
SethTisue Dec 13, 2024
484c29e
JLine 3.27.1 (was 3.27.0)
SethTisue Dec 13, 2024
eeba529
Fix layout of released SDK archives, restore intermiediete top-level …
WojciechMazur Dec 12, 2024
ddef799
refactor: improve Given search preference warning
eed3si9n Dec 11, 2024
4210110
fix: update `scala-cli.jar` path
chenrui333 Dec 10, 2024
ff78d08
Limit exposure to ConcurrentModificationException when sys props are …
jtjeferreira Dec 10, 2024
87d6ed9
improve javaBootClassPath lazy evaluation
jtjeferreira Dec 10, 2024
09a8ff1
Nowarn extension matching nonpublic member
som-snytt Oct 22, 2024
b6bc62c
Prefer isPublic in RefChecks
som-snytt Oct 22, 2024
9530960
chore: use sbt/setup-sbt when using ubuntu-latest image
WojciechMazur Dec 30, 2024
376fc17
fix: add sbt/setup-sbt for the dependency graph workflow
hamzaremmal Dec 17, 2024
38f82bf
Backport "REPL: JLine: follow recommendation to use JNI, not JNA; als…
WojciechMazur Dec 30, 2024
1e17f4d
Backport "Fix layout of released SDK archives, restore intermiediete …
WojciechMazur Dec 30, 2024
c3cff52
Backport "refactor: improve Given search preference warning" to 3.6 (…
WojciechMazur Dec 30, 2024
5771b9b
Backport "Limit exposure to ConcurrentModificationException when sys …
WojciechMazur Dec 30, 2024
d31b1b2
Backport "Nowarn extension matching nonpublic member" to 3.6 (#22276)
WojciechMazur Dec 30, 2024
556e916
Backport "fix: update `scala-cli.jar` path" to 3.6 (#22274)
WojciechMazur Dec 30, 2024
35dff76
Backport "chore: use sbt/setup-sbt when using ubuntu-latest image" to…
WojciechMazur Dec 30, 2024
efefe01
Backport "fix: add sbt/setup-sbt for the dependency graph workflow" t…
WojciechMazur Dec 30, 2024
a05de1c
Add changelog for 3.6.3-RC2
WojciechMazur Dec 30, 2024
b89886b
Release 3.6.3-RC2
WojciechMazur Dec 30, 2024
7457b16
copyright 2025
SethTisue Jan 8, 2025
4773332
[CI]: Replace deprecated `actions/create-release` and `actions/upload…
WojciechMazur Jan 15, 2025
1f8842f
fix: drop jackson-module-scala from CB
hamzaremmal Jan 12, 2025
cdd72a0
Add changelog for 3.6.3
WojciechMazur Jan 15, 2025
c33db50
Release 3.6.3
WojciechMazur Jan 15, 2025
b455651
Add changelog for 3.6.4-RC1
WojciechMazur Jan 16, 2025
bc3e415
Release 3.6.4-RC1
WojciechMazur Jan 16, 2025
78730ff
Merge branch 'release-3.6.3' into language-reference-stable
WojciechMazur Jan 17, 2025
838add9
Generate reference expected links
WojciechMazur Jan 17, 2025
383d19a
Remove and adjust tests based on release-3.6.3 branch
WojciechMazur Jan 17, 2025
cda99d0
Synchronize language-reference-stable with Scala 3.6.3 (#22398)
WojciechMazur Jan 20, 2025
c4a1896
Revert "Drop phase.isTyper use in isLegalPrefix/asf"
WojciechMazur Feb 24, 2025
e25316c
Adjust captures/lazylist test
WojciechMazur Feb 24, 2025
b3a3738
Revert "Drop phase.isTyper use in isLegalPrefix/asf" from Scala 3.6.4…
WojciechMazur Feb 26, 2025
27a73e9
Fix chocolatey-test when used in stable releases
WojciechMazur Jan 20, 2025
e3b2838
Add changelog for 3.6.4-RC2
WojciechMazur Feb 26, 2025
9d7f439
Release 3.6.4-RC2
WojciechMazur Feb 26, 2025
4377e99
Add changelog for 3.6.4
WojciechMazur Mar 5, 2025
6b2b881
Release 3.6.4
WojciechMazur Mar 5, 2025
cb2e21a
Merge branch 'release-3.6.4' into language-reference-stable
WojciechMazur Mar 7, 2025
18fe436
Synchronize language-reference-stable with 3.6.4 (#22738)
WojciechMazur Mar 7, 2025
3d06843
Make better-fors a preview feature in 3.7 (#22776)
WojciechMazur Mar 12, 2025
c7032bd
Add class parameters, flags, and privateWithin and annotations to new…
jchyb Mar 11, 2025
3ac58cf
Add changelog for 3.7.0-RC1
WojciechMazur Mar 12, 2025
4283deb
Release 3.7.0
WojciechMazur Mar 12, 2025
6967338
Add missing contributors section in 3.7.0-RC1 changelog
WojciechMazur Mar 12, 2025
4e75ac7
Fix #22794: Emit the definition of `Arrays.newArray` even though it's…
sjrd Mar 13, 2025
d97c30a
Backport "Fix #22794: Emit the definition of Arrays.newArray even tho…
WojciechMazur Mar 14, 2025
5507bcd
Bump Scala CLI to v1.7.1 (was v1.7.0)
Gedochao Mar 20, 2025
815cdf3
Retire untried tests
som-snytt Mar 14, 2025
545f172
Move untried tests to tried and true
som-snytt Mar 15, 2025
b201df0
Revert unconditional lint of Inlined
som-snytt Mar 15, 2025
ed5a8b7
Deprecate `Yno-kind-polymorphism` (#22814)
Linyxus Mar 18, 2025
958e896
Fail compilation if multiple conflicting top-level private defs/vals …
jchyb Mar 17, 2025
a76dc30
Backport "Bump Scala CLI to v1.7.1 (was v1.7.0)" to 3.7 (#22929)
WojciechMazur Apr 8, 2025
6494755
Backport "Revert unconditional lint of Inlined expansion" to 3.7 (#22…
WojciechMazur Apr 8, 2025
a5bf751
Backport "Deprecate `Yno-kind-polymorphism`" to 3.7 (#22931)
WojciechMazur Apr 8, 2025
6089e02
Backport "Fail compilation if multiple conflicting top-level private …
WojciechMazur Apr 8, 2025
a07aacf
Revert "Make overload pruning based on result types less aggressive (…
WojciechMazur Apr 8, 2025
2c38464
Revert "Make overload pruning based on result types less aggressive" …
WojciechMazur Apr 8, 2025
bee65d9
Improve dentation at EOF
som-snytt Apr 8, 2025
c9bf402
Backport "Check trailing blank line at EOF for OUTDENT" to 3.7.0 (#22…
WojciechMazur Apr 9, 2025
d29f2a5
Add changelog for 3.7.0-RC2
WojciechMazur Apr 9, 2025
d112546
Release 3.7.0-RC2
WojciechMazur Apr 9, 2025
b989a7b
Changes in preparation to make `caps.Capability` stable (#22849)
natsukagami Mar 24, 2025
2ee0c7e
Mitigate change in status of scala.caps
odersky Apr 9, 2025
5517193
Backport "changes to scala.caps in preparation to make Capability sta…
WojciechMazur Apr 11, 2025
842c13b
Two fixes to NamedTuple pattern matching
odersky Apr 9, 2025
3f184c6
Adapt refutability warning in Space engine to named tuples
odersky Apr 10, 2025
13204d0
Add check files
odersky Apr 10, 2025
1c80c61
Backport "Two fixes to NamedTuple pattern matching" to 3.7.0 (#22995)
WojciechMazur Apr 14, 2025
eb3931e
Add changelog for 3.7.0-RC3
WojciechMazur Apr 14, 2025
9254654
Release 3.7.0-RC3
WojciechMazur Apr 14, 2025
c43afb9
Cherry-pick upgrade to Scala.js 1.9.0 in the scalatest CB project.
sjrd Apr 23, 2025
84cbf45
Upgrade to Scala.js 1.19.0.
sjrd Apr 22, 2025
325ae78
Upgrade to Scala.js 1.19.0.
tgodzik Apr 23, 2025
9bdd736
Backport "Upgrade to Scala.js 1.19.0." to 3.7 (#23035)
tgodzik Apr 24, 2025
dd0867f
chore: Add changelog and bump version
tgodzik Apr 24, 2025
5a5bed9
Add changelog for 3.7.0
WojciechMazur May 5, 2025
c92e20e
Release 3.7.0
WojciechMazur May 5, 2025
3e9162d
Merge tag '3.7.0' into language-reference-stable
WojciechMazur May 7, 2025
b730a5e
Sync TASTY version, set 28.7
WojciechMazur May 7, 2025
d53b097
[chore]: Synchronize `language-reference-stable` with release 3.7.0 (…
WojciechMazur May 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make better-fors a preview feature in 3.7 (#22776)
Makes the SIP-62 better fors a preview feature in Scala 3.7. Shall be
stabilised no earlier then Scala 3.8
  • Loading branch information
WojciechMazur committed Mar 12, 2025
commit 3d068435c80d625f19cda34c5d75feead222fc39
20 changes: 10 additions & 10 deletions compiler/src/dotty/tools/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1953,9 +1953,9 @@ object desugar {
/** Create tree for for-comprehension `<for (enums) do body>` or
* `<for (enums) yield body>` where mapName and flatMapName are chosen
* corresponding to whether this is a for-do or a for-yield.
* If sourceVersion >= 3.7 are enabled, the creation performs the following rewrite rules:
* If betterFors are enabled, the creation performs the following rewrite rules:
*
* 1. if sourceVersion >= 3.7:
* 1. if betterFors is enabled:
*
* for () do E ==> E
* or
Expand Down Expand Up @@ -1986,13 +1986,13 @@ object desugar {
* ==>
* for (P <- G.withFilter (P => E); ...) ...
*
* 6. For any N, if sourceVersion >= 3.7:
* 6. For any N, if betterFors is enabled:
*
* for (P <- G; P_1 = E_1; ... P_N = E_N; P1 <- G1; ...) ...
* ==>
* G.flatMap (P => for (P_1 = E_1; ... P_N = E_N; ...))
*
* 7. For any N, if sourceVersion >= 3.7:
* 7. For any N, if betterFors is enabled:
*
* for (P <- G; P_1 = E_1; ... P_N = E_N) ...
* ==>
Expand All @@ -2013,7 +2013,7 @@ object desugar {
* If any of the P_i are variable patterns, the corresponding `x_i @ P_i` is not generated
* and the variable constituting P_i is used instead of x_i
*
* 9. For any N, if sourceVersion >= 3.7:
* 9. For any N, if betterFors is enabled:
*
* for (P_1 = E_1; ... P_N = E_N; ...)
* ==>
Expand Down Expand Up @@ -2157,15 +2157,15 @@ object desugar {
case _ => false

def markTrailingMap(aply: Apply, gen: GenFrom, selectName: TermName): Unit =
if sourceVersion.isAtLeast(`3.7`)
if sourceVersion.enablesBetterFors
&& selectName == mapName
&& gen.checkMode != GenCheckMode.Filtered // results of withFilter have the wrong type
&& (deepEquals(gen.pat, body) || deepEquals(body, Tuple(Nil)))
then
aply.putAttachment(TrailingForMap, ())

enums match {
case Nil if sourceVersion.isAtLeast(`3.7`) => body
case Nil if sourceVersion.enablesBetterFors => body
case (gen: GenFrom) :: Nil =>
val aply = Apply(rhsSelect(gen, mapName), makeLambda(gen, body))
markTrailingMap(aply, gen, mapName)
Expand All @@ -2174,7 +2174,7 @@ object desugar {
val cont = makeFor(mapName, flatMapName, rest, body)
Apply(rhsSelect(gen, flatMapName), makeLambda(gen, cont))
case (gen: GenFrom) :: rest
if sourceVersion.isAtLeast(`3.7`)
if sourceVersion.enablesBetterFors
&& rest.dropWhile(_.isInstanceOf[GenAlias]).headOption.forall(e => e.isInstanceOf[GenFrom]) // possible aliases followed by a generator or end of for
&& !rest.takeWhile(_.isInstanceOf[GenAlias]).exists(a => isNestedGivenPattern(a.asInstanceOf[GenAlias].pat)) =>
val cont = makeFor(mapName, flatMapName, rest, body)
Expand Down Expand Up @@ -2202,9 +2202,9 @@ object desugar {
makeFor(mapName, flatMapName, vfrom1 :: rest1, body)
case (gen: GenFrom) :: test :: rest =>
val filtered = Apply(rhsSelect(gen, nme.withFilter), makeLambda(gen, test))
val genFrom = GenFrom(gen.pat, filtered, if sourceVersion.isAtLeast(`3.7`) then GenCheckMode.Filtered else GenCheckMode.Ignore)
val genFrom = GenFrom(gen.pat, filtered, if sourceVersion.enablesBetterFors then GenCheckMode.Filtered else GenCheckMode.Ignore)
makeFor(mapName, flatMapName, genFrom :: rest, body)
case GenAlias(_, _) :: _ if sourceVersion.isAtLeast(`3.7`) =>
case GenAlias(_, _) :: _ if sourceVersion.enablesBetterFors =>
val (valeqs, rest) = enums.span(_.isInstanceOf[GenAlias])
val pats = valeqs.map { case GenAlias(pat, _) => pat }
val rhss = valeqs.map { case GenAlias(_, rhs) => rhs }
Expand Down
3 changes: 3 additions & 0 deletions compiler/src/dotty/tools/dotc/config/SourceVersion.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package dotc
package config

import core.Decorators.*
import core.Contexts.*
import Feature.isPreviewEnabled
import util.Property

enum SourceVersion:
Expand Down Expand Up @@ -35,6 +37,7 @@ enum SourceVersion:
def enablesClauseInterleaving = isAtLeast(`3.6`)
def enablesNewGivens = isAtLeast(`3.6`)
def enablesNamedTuples = isAtLeast(`3.7`)
def enablesBetterFors(using Context) = isAtLeast(`3.7`) && isPreviewEnabled

object SourceVersion extends Property.Key[SourceVersion]:
def defaultSourceVersion = `3.7`
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2956,7 +2956,7 @@ object Parsers {
/** Enumerators ::= Generator {semi Enumerator | Guard}
*/
def enumerators(): List[Tree] =
if sourceVersion.isAtLeast(`3.7`) then
if sourceVersion.enablesBetterFors then
aliasesUntilGenerator() ++ enumeratorsRest()
else
generator() :: enumeratorsRest()
Expand Down
3 changes: 2 additions & 1 deletion compiler/test/dotty/tools/debug/DebugTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class DebugTests:
implicit val testGroup: TestGroup = TestGroup("debug")
CompilationTest.aggregateTests(
compileFile("tests/debug-custom-args/eval-explicit-nulls.scala", TestConfiguration.explicitNullsOptions),
compileFilesInDir("tests/debug", TestConfiguration.defaultOptions)
compileFilesInDir("tests/debug", TestConfiguration.defaultOptions),
compileFilesInDir("tests/debug-preview", TestConfiguration.defaultOptions.and("-preview"))
).checkDebug()

object DebugTests extends ParallelTesting:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
layout: doc-page
title: "Better fors"
nightlyOf: https://docs.scala-lang.org/scala3/reference/changed-features/better-fors.html
nightlyOf: https://docs.scala-lang.org/scala3/reference/preview/better-fors.html
---

Starting in Scala `3.7`, the usability of `for`-comprehensions is improved.
Starting in Scala `3.7` under `-preview` mode, the usability of `for`-comprehensions is improved.

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:

Expand Down
24 changes: 24 additions & 0 deletions docs/_docs/reference/preview/overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
layout: doc-page
title: "Preview"
nightlyOf: https://docs.scala-lang.org/scala3/reference/preview/overview.html
---

## Preview language features

New Scala language features or standard library APIs are initially introduced as experimental, but once they become fully implemented and accepted by the [SIP](https://docs.scala-lang.org/sips/) these can become a preview features.

Preview language features and APIs are guaranteed to be standardized in some next Scala minor release, but allow the compiler team to introduce small, possibly binary incompatible, changes based on the community feedback.
These can be used by early adopters who can accept the possibility of binary compatibility breakage. For instance, preview features could be used in some internal tool or application. On the other hand, preview features are discouraged in publicly available libraries.

More information about preview featues can be found in [preview defintions guide](../other-new-features/preview-defs.md)

### `-preview` compiler flag

This flag enables the use of all preview language feature in the project.


## List of available preview features

* [`better-fors`](./better-fors.md): Enables new for-comprehension behaviour under SIP-62 under `-source:3.7` or later

6 changes: 5 additions & 1 deletion docs/sidebar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ subsection:
- page: reference/changed-features/lazy-vals-init.md
- page: reference/changed-features/main-functions.md
- page: reference/changed-features/interpolation-escapes.md
- page: reference/changed-features/better-fors.md
- title: Dropped Features
index: reference/dropped-features/dropped-features.md
subsection:
Expand All @@ -140,6 +139,11 @@ subsection:
- page: reference/dropped-features/nonlocal-returns.md
- page: reference/dropped-features/this-qualifier.md
- page: reference/dropped-features/wildcard-init.md
- title: Preview Features
directory: preview
index: reference/preview/overview.md
subsection:
- page: reference/preview/better-fors.md
- title: Experimental Features
directory: experimental
index: reference/experimental/overview.md
Expand Down
2 changes: 1 addition & 1 deletion library/src/scala/runtime/stdLibPatches/language.scala
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ object language:
* @see [[https://github.com/scala/improvement-proposals/pull/79]]
*/
@compileTimeOnly("`betterFors` can only be used at compile time in import statements")
@deprecated("The `experimental.betterFors` language import is no longer needed since the feature is now standard", since = "3.7")
@deprecated("The `experimental.betterFors` language import no longer has any effect, the feature is being stablised and can be enabled using `-preview` flag", since = "3.7")
object betterFors

/** Experimental support for package object values
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package dotty.tools.pc.tests.tokens

import dotty.tools.pc.base.BaseSemanticTokensSuite
import java.nio.file.Path

import org.junit.Test

class SemanticTokensSuite extends BaseSemanticTokensSuite:
// -preview required for `for-comprehension` test
override protected def scalacOptions(classpath: Seq[Path]): Seq[String] =
super.scalacOptions(classpath) ++ Seq("-preview")

@Test def `class, object, var, val(readonly), method, type, parameter, String(single-line)` =
check(
Expand Down
27 changes: 27 additions & 0 deletions tests/debug-preview/eval-in-for-comprehension.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
break Test$ 5 // in main
eval list(0)
result 1
// TODO can we remove debug line in adapted methods?
break Test$ 5 // in main$$anonfun$adapted$1
break Test$ 6 // in main$$anonfun$1
eval list(0)
result 1
eval x
result 1
break Test$ 7 // in main$$anonfun$1$$anonfun$1
eval x + y
result 2

break Test$ 11 // in main$$anonfun$2
eval x
result 1

break Test$ 13 // in main
eval list(0)
result 1
break Test$ 13 // in main$$anonfun$4

break Test$ 14 // in main
eval list(0)
result 1
break Test$ 14 // in main$$anonfun$5
14 changes: 14 additions & 0 deletions tests/debug-preview/eval-in-for-comprehension.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
object Test:
def main(args: Array[String]): Unit =
val list = List(1)
for
x <- list
y <- list
z = x + y
yield x
for
x <- list
if x == 1
yield x
for x <- list yield x
for x <- list do println(x)
7 changes: 7 additions & 0 deletions tests/debug/eval-in-for-comprehension.check
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,16 @@ eval list(0)
result 1
eval x
result 1
break Test$ 6 // in main$$anonfun$1$$anonfun$adapted$1
break Test$ 7 // in main$$anonfun$1$$anonfun$1
eval x + y
result 2
// TODO this line position does not make any sense
break Test$ 6 // in main$$anonfun$1$$anonfun$1
break Test$ 7 // in main$$anonfun$1$$anonfun$1
break Test$ 6 // in main$$anonfun$1$$anonfun$2
break Test$ 6 // in main$$anonfun$1$$anonfun$2
break Test$ 7 // in main$$anonfun$1$$anonfun$2

break Test$ 11 // in main$$anonfun$2
eval x
Expand Down
2 changes: 2 additions & 0 deletions tests/pos/better-fors-given.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//> using options -preview

@main def Test: Unit =
for
x <- Option(23 -> "abc")
Expand Down
3 changes: 2 additions & 1 deletion tests/pos/better-fors-i21804.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import scala.language.experimental.betterFors
//> using options -preview
// import scala.language.experimental.betterFors

case class Container[A](val value: A) {
def map[B](f: A => B): Container[B] = Container(f(value))
Expand Down
3 changes: 2 additions & 1 deletion tests/run/better-fors-map-elim.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import scala.language.experimental.betterFors
//> using options -preview
// import scala.language.experimental.betterFors

class myOptionModule(doOnMap: => Unit) {
sealed trait MyOption[+A] {
Expand Down
3 changes: 3 additions & 0 deletions tests/run/better-fors.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//> using options -preview
// import scala.language.experimental.betterFors

def for1 =
for {
a = 1
Expand Down
1 change: 1 addition & 0 deletions tests/run/fors.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//> using options -preview
//############################################################################
// for-comprehensions (old and new syntax)
//############################################################################
Expand Down
52 changes: 26 additions & 26 deletions tests/semanticdb/expect/ForComprehension.expect.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,43 @@ package example
class ForComprehension/*<-example::ForComprehension#*/ {
for {
a/*<-local0*/ <- List/*->scala::package.List.*/(1)
b/*<-local1*/ <- List/*->scala::package.List.*/(1)
b/*<-local1*//*->local1*/ <- List/*->scala::package.List.*/(1)
if b/*->local1*/ >/*->scala::Int#`>`(+3).*/ 1
c/*<-local2*/ = a/*->local0*/ +/*->scala::Int#`+`(+4).*/ b/*->local1*/
c/*<-local2*//*->local2*/ = a/*->local0*/ +/*->scala::Int#`+`(+4).*/ b/*->local1*/
} yield (a/*->local0*/, b/*->local1*/, c/*->local2*/)
for {
a/*<-local3*/ <- List/*->scala::package.List.*/(1)
b/*<-local4*/ <- List/*->scala::package.List.*/(a/*->local3*/)
a/*<-local4*/ <- List/*->scala::package.List.*/(1)
b/*<-local5*/ <- List/*->scala::package.List.*/(a/*->local4*/)
if (
a/*->local3*/,
b/*->local4*/
a/*->local4*/,
b/*->local5*/
) ==/*->scala::Any#`==`().*/ (1, 2)
(
c/*<-local6*/,
d/*<-local7*/
) <- List/*->scala::package.List.*/((a/*->local3*/, b/*->local4*/))
c/*<-local7*/,
d/*<-local8*/
) <- List/*->scala::package.List.*/((a/*->local4*/, b/*->local5*/))
if (
a/*->local3*/,
b/*->local4*/,
c/*->local6*/,
d/*->local7*/
a/*->local4*/,
b/*->local5*/,
c/*->local7*/,
d/*->local8*/
) ==/*->scala::Any#`==`().*/ (1, 2, 3, 4)
e/*<-local8*//*->local8*/ = (
a/*->local3*/,
b/*->local4*/,
c/*->local6*/,
d/*->local7*/
e/*<-local9*//*->local9*/ = (
a/*->local4*/,
b/*->local5*/,
c/*->local7*/,
d/*->local8*/
)
if e/*->local8*/ ==/*->scala::Any#`==`().*/ (1, 2, 3, 4)
f/*<-local9*/ <- List/*->scala::package.List.*/(e/*->local8*/)
if e/*->local9*/ ==/*->scala::Any#`==`().*/ (1, 2, 3, 4)
f/*<-local10*/ <- List/*->scala::package.List.*/(e/*->local9*/)
} yield {
(
a/*->local3*/,
b/*->local4*/,
c/*->local6*/,
d/*->local7*/,
e/*->local8*/,
f/*->local9*/
a/*->local4*/,
b/*->local5*/,
c/*->local7*/,
d/*->local8*/,
e/*->local9*/,
f/*->local10*/
)
}
}
Loading