Skip to content

Commit 7acd730

Browse files
authored
Merge branch 'scala:main' into capture-subtyping
2 parents 4c76323 + d50973b commit 7acd730

File tree

90 files changed

+765
-324
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+765
-324
lines changed

Diff for: .github/PULL_REQUEST_TEMPLATE/fix-issue.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ assignees: ''
88

99
<!--
1010
TODO first sign the CLA
11-
https://www.lightbend.com/contribute/cla/scala
11+
https://contribute.akka.io/cla/scala
1212
-->
1313

1414
## Fix #XYZ

Diff for: .github/PULL_REQUEST_TEMPLATE/other-pr.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ assignees: ''
88

99
<!--
1010
TODO first sign the CLA
11-
https://www.lightbend.com/contribute/cla/scala
11+
https://contribute.akka.io/cla/scala
1212
-->
1313

1414
## Description

Diff for: .github/workflows/build-sdk.yml

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ jobs:
6161
distribution: temurin
6262
java-version: ${{ inputs.java-version }}
6363
cache : sbt
64+
- uses: sbt/setup-sbt@v1
6465
- name: Build and pack the SDK (universal)
6566
run : ./project/scripts/sbt dist/Universal/stage
6667
- name: Build and pack the SDK (linux x86-64)

Diff for: .github/workflows/ci.yaml

+3-9
Original file line numberDiff line numberDiff line change
@@ -801,19 +801,13 @@ jobs:
801801
distDir="$3"
802802
803803
# Build binaries
804-
./project/scripts/sbt "${sbtProject}/Universal/stage"
804+
./project/scripts/sbt "all ${sbtProject}/Universal/packageBin ${sbtProject}/Universal/packageZipTarball"
805805
806-
outputPath="${distDir}/target/universal/stage"
807806
artifactName="scala3-${{ env.RELEASE_TAG }}${distroSuffix}"
808-
zipArchive="${artifactName}.zip"
809-
tarGzArchive="${artifactName}.tar.gz"
810-
811-
cwd=$(pwd)
812-
(cd $outputPath && zip -r ${zipArchive} . && mv ${zipArchive} "${cwd}/")
813-
tar -czf ${tarGzArchive} -C "$outputPath" .
814807
815808
# Caluclate SHA for each of archive files
816-
for file in "${zipArchive}" "${tarGzArchive}"; do
809+
for file in "${artifactName}.zip" "${artifactName}.tar.gz"; do
810+
mv ${distDir}/target/universal/$file $file
817811
sha256sum "${file}" > "${file}.sha256"
818812
done
819813
}

Diff for: .github/workflows/cla.yml

+4-13
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,11 @@ on:
33
pull_request:
44
branches-ignore:
55
- 'language-reference-stable'
6-
push:
7-
branches:
8-
- 'language-reference-stable'
9-
merge_group:
10-
permissions:
11-
contents: write
12-
pull-requests: write
13-
146
jobs:
157
check:
168
runs-on: ubuntu-latest
179
steps:
18-
- uses: actions/checkout@v4
19-
- run: ./project/scripts/check-cla.sh
20-
if: github.event_name == 'pull_request'
21-
env:
22-
AUTHOR: ${{ github.event.pull_request.user.login }}
10+
- name: Verify CLA
11+
uses: scala/cla-checker@v1
12+
with:
13+
author: ${{ github.event.pull_request.user.login }}

Diff for: .github/workflows/dependency-graph.yml

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v4
12+
- uses: sbt/setup-sbt@v1
1213
- uses: scalacenter/sbt-dependency-submission@v3
1314
env:
1415
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}

Diff for: .github/workflows/language-reference.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ jobs:
3636
distribution: 'temurin'
3737
java-version: 17
3838
cache: 'sbt'
39+
- uses: sbt/setup-sbt@v1
3940

4041
- name: Generate reference documentation and test links
4142
run: |

Diff for: .github/workflows/launchers.yml

+5-9
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
java-version: '17'
2121
distribution: 'temurin'
2222
cache: 'sbt'
23+
- uses: sbt/setup-sbt@v1
2324
- name: Build and test launcher command
2425
run: ./project/scripts/native-integration/bashTests
2526
env:
@@ -37,9 +38,7 @@ jobs:
3738
java-version: '17'
3839
distribution: 'temurin'
3940
cache: 'sbt'
40-
# https://github.com/actions/runner-images/issues/9369
41-
- name: Install sbt
42-
run: brew install sbt
41+
- uses: sbt/setup-sbt@v1
4342
- name: Build and test launcher command
4443
run: ./project/scripts/native-integration/bashTests
4544
env:
@@ -58,9 +57,7 @@ jobs:
5857
java-version: '17'
5958
distribution: 'temurin'
6059
cache: 'sbt'
61-
# https://github.com/actions/runner-images/issues/9369
62-
- name: Install sbt
63-
run: brew install sbt
60+
- uses: sbt/setup-sbt@v1
6461
- name: Build and test launcher command
6562
run: ./project/scripts/native-integration/bashTests
6663
env:
@@ -79,9 +76,7 @@ jobs:
7976
java-version: '17'
8077
distribution: 'temurin'
8178
cache: 'sbt'
82-
# https://github.com/actions/runner-images/issues/9369
83-
- name: Install sbt
84-
run: brew install sbt
79+
- uses: sbt/setup-sbt@v1
8580
- name: Build and test launcher command
8681
run: ./project/scripts/native-integration/bashTests
8782
env:
@@ -100,6 +95,7 @@ jobs:
10095
java-version: '17'
10196
distribution: 'temurin'
10297
cache: 'sbt'
98+
- uses: sbt/setup-sbt@v1
10399
- name: Build the launcher command
104100
run: sbt "dist-win-x86_64/Universal/stage"
105101
- name: Run the launcher command tests

Diff for: .github/workflows/publish-chocolatey.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ jobs:
3535
with:
3636
name: scala.nupkg
3737
- name: Publish the package to Chocolatey
38-
run: choco push scala.nupkg --source https://push.chocolatey.org/ --api-key ${{ secrets.API-KEY }}
38+
run: choco push scala.${{inputs.version}}.nupkg --source https://push.chocolatey.org/ --api-key ${{ secrets.API-KEY }}
3939

Diff for: .github/workflows/scaladoc.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
java-version: 17
3838
cache: 'sbt'
3939

40+
- uses: sbt/setup-sbt@v1
4041
- name: Compile and test scala3doc-js
4142
run: ./project/scripts/sbt scaladoc-js-main/test
4243

Diff for: .github/workflows/test-cc.yml

+1
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@ jobs:
2626
steps:
2727
- name: Git Checkout
2828
uses: actions/checkout@v4
29+
- uses: sbt/setup-sbt@v1
2930
- name: Test with Scala 2 library with CC TASTy
3031
run: ./project/scripts/sbt ";set ThisBuild/Build.scala2Library := Build.Scala2LibraryCCTasty ;scala3-bootstrapped/test"

Diff for: .vscode-template/settings.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"**/*.class": true,
1010
"**/*.tasty": true,
1111
"**/target/": true,
12-
"community-build/community-projects": true,
13-
"tests/pos-with-compiler-cc/dotc/**/*.scala": true
12+
"community-build/community-projects": true
1413
}
1514
}

Diff for: MAINTENANCE.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ The following is the list of all the principal areas of the compiler and the int
6969
- Parser: @odersky, @hamzaremmal, @KacperFKorban
7070
- Typer: @odersky, @smarter, (@dwijnand), @noti0nal, @EugeneFlesselle, @KacperFKorban, @bracevac
7171
- Erasure: @smarter, @odersky
72-
- Enums:
72+
- Enums:
7373
- Derivation & Mirrors: (@dwijnand), @EugeneFlesselle
7474
- Export: @odersky
7575
- Pattern Matching: @dwijnand, @sjrd, @noti0na1
7676
- Inline: @odersky, @jchyb, @hamzaremmal, @EugeneFlesselle
7777
- Metaprogramming (Quotes, Reflect, Staging): @jchyb, @hamzaremmal
7878
- Match types: @sjrd, @dwijnand, @Linyxus, @EugeneFlesselle
7979
- GADT: @dwijnand, @Linyxus
80-
- Initialization checker:
80+
- Initialization checker:
8181
- Transforms: @sjrd, @odersky, @smarter
8282
- Tailrec: @sjrd, @mbovel
8383
- JS backend: @sjrd
@@ -87,17 +87,17 @@ The following is the list of all the principal areas of the compiler and the int
8787
- Safe nulls (experimental): @noti0na1
8888
- Capture checker (experimental): @odersky, @Linyxus, @bracevac, @noti0na1
8989
- Modularity (experimental): @KacperFKorban
90-
- Named Tuples (experimental): @odersky
90+
- Named Tuples (experimental): @odersky, @aherlihy
9191

9292
### Tooling
9393
- REPL: @dwijnand
9494
- Runner/CLI: @Gedochao, (@tgodzik)
9595
- IDE: @tgodzik, (@kasiaMarek)
9696
- Scaladoc: @Florian3k
9797
- SemanticDB: @natsukagami, (@tanishiking)
98-
- Coverage: @KacperFKorban
98+
- Coverage: @KacperFKorban
9999
- Linting (especially unused warnings) / Reporting UX: @KacperFKorban
100-
- Presentation Compiler: @rochala, @tgodzik, @kasiaMarek, @natsukagami
100+
- Presentation Compiler: @rochala, @tgodzik, @kasiaMarek, @natsukagami
101101
- Debug Adapter: @adpi2, (@tgodzik)
102102
- Scastie: @rochala
103103

Diff for: compiler/src/dotty/tools/backend/jvm/BCodeSkelBuilder.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ trait BCodeSkelBuilder extends BCodeHelpers {
515515
*/
516516
object locals {
517517

518-
private val slots = mutable.AnyRefMap.empty[Symbol, Local] // (local-or-param-sym -> Local(BType, name, idx, isSynth))
518+
private val slots = mutable.HashMap.empty[Symbol, Local] // (local-or-param-sym -> Local(BType, name, idx, isSynth))
519519

520520
private var nxtIdx = -1 // next available index for local-var
521521

Diff for: compiler/src/dotty/tools/backend/jvm/BackendUtils.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ object BackendUtils {
185185
20 -> asm.Opcodes.V20,
186186
21 -> asm.Opcodes.V21,
187187
22 -> asm.Opcodes.V22,
188-
23 -> asm.Opcodes.V23
188+
23 -> asm.Opcodes.V23,
189+
24 -> asm.Opcodes.V24
189190
)
190191
}

Diff for: compiler/src/dotty/tools/dotc/ast/Desugar.scala

+22-9
Original file line numberDiff line numberDiff line change
@@ -694,15 +694,15 @@ object desugar {
694694
val originalTparams = constr1.leadingTypeParams
695695
val originalVparamss = asTermOnly(constr1.trailingParamss)
696696
lazy val derivedEnumParams = enumClass.typeParams.map(derivedTypeParamWithVariance)
697-
val impliedTparams =
698-
if (isEnumCase) {
697+
val enumTParams =
698+
if isEnumCase then
699699
val tparamReferenced = typeParamIsReferenced(
700-
enumClass.typeParams, originalTparams, originalVparamss, parents)
701-
if (originalTparams.isEmpty && (parents.isEmpty || tparamReferenced))
700+
enumClass.typeParams, originalTparams, originalVparamss, parents)
701+
if originalTparams.isEmpty && (parents.isEmpty || tparamReferenced) then
702702
derivedEnumParams.map(tdef => tdef.withFlags(tdef.mods.flags | PrivateLocal))
703-
else originalTparams
704-
}
705-
else originalTparams
703+
else Nil
704+
else Nil
705+
val impliedTparams = enumTParams ++ originalTparams
706706

707707
if mods.is(Trait) then
708708
for vparams <- originalVparamss; vparam <- vparams do
@@ -735,6 +735,11 @@ object desugar {
735735
derived.withAnnotations(Nil)
736736

737737
val constr = cpy.DefDef(constr1)(paramss = joinParams(constrTparams, constrVparamss))
738+
if enumTParams.nonEmpty then
739+
defaultGetters = defaultGetters.map:
740+
case ddef: DefDef =>
741+
val tParams = enumTParams.map(tparam => toMethParam(tparam, KeepAnnotations.All))
742+
cpy.DefDef(ddef)(paramss = joinParams(tParams, ddef.trailingParamss))
738743

739744
val (normalizedBody, enumCases, enumCompanionRef) = {
740745
// Add constructor type parameters and evidence implicit parameters
@@ -1081,12 +1086,13 @@ object desugar {
10811086
if mods.isAllOf(Given | Inline | Transparent) then
10821087
report.error("inline given instances cannot be trasparent", cdef)
10831088
var classMods = if mods.is(Given) then mods &~ (Inline | Transparent) | Synthetic else mods
1084-
if vparamAccessors.exists(_.mods.is(Tracked)) then
1089+
val newBody = tparamAccessors ::: vparamAccessors ::: normalizedBody ::: caseClassMeths
1090+
if newBody.collect { case d: ValOrDefDef => d }.exists(_.mods.is(Tracked)) then
10851091
classMods |= Dependent
10861092
cpy.TypeDef(cdef: TypeDef)(
10871093
name = className,
10881094
rhs = cpy.Template(impl)(constr, parents1, clsDerived, self1,
1089-
tparamAccessors ::: vparamAccessors ::: normalizedBody ::: caseClassMeths)
1095+
newBody)
10901096
).withMods(classMods)
10911097
}
10921098

@@ -1556,6 +1562,12 @@ object desugar {
15561562
rhsOK(rhs)
15571563
}
15581564

1565+
val legalTracked: Context ?=> MemberDefTest = {
1566+
case valdef @ ValDef(_, _, _) =>
1567+
val sym = valdef.symbol
1568+
!ctx.owner.exists || ctx.owner.isClass || ctx.owner.is(Case) || ctx.owner.isConstructor || valdef.mods.is(Param) || valdef.mods.is(ParamAccessor)
1569+
}
1570+
15591571
def checkOpaqueAlias(tree: MemberDef)(using Context): MemberDef =
15601572
def check(rhs: Tree): MemberDef = rhs match
15611573
case bounds: TypeBoundsTree if bounds.alias.isEmpty =>
@@ -1581,6 +1593,7 @@ object desugar {
15811593
} else tested
15821594
tested = checkOpaqueAlias(tested)
15831595
tested = checkApplicable(Opaque, legalOpaque)
1596+
tested = checkApplicable(Tracked, legalTracked)
15841597
tested
15851598
case _ =>
15861599
tree

Diff for: compiler/src/dotty/tools/dotc/classpath/DirectoryClassPath.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ final class CtSymClassPath(ctSym: java.nio.file.Path, release: Int) extends Clas
229229

230230
// e.g. "java.lang" -> Seq(/876/java/lang, /87/java/lang, /8/java/lang))
231231
private val packageIndex: scala.collection.Map[String, scala.collection.Seq[Path]] = {
232-
val index = collection.mutable.AnyRefMap[String, collection.mutable.ListBuffer[Path]]()
232+
val index = collection.mutable.HashMap[String, collection.mutable.ListBuffer[Path]]()
233233
val isJava12OrHigher = scala.util.Properties.isJavaAtLeast("12")
234234
rootsForRelease.foreach(root => Files.walk(root).iterator().asScala.filter(Files.isDirectory(_)).foreach { p =>
235235
val moduleNamePathElementCount = if (isJava12OrHigher) 1 else 0

Diff for: compiler/src/dotty/tools/dotc/config/PathResolver.scala

+12-4
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,25 @@ object PathResolver {
3636
/** Values found solely by inspecting environment or property variables.
3737
*/
3838
object Environment {
39-
private def searchForBootClasspath = (
40-
systemProperties find (_._1 endsWith ".boot.class.path") map (_._2) getOrElse ""
41-
)
39+
private def searchForBootClasspath = {
40+
import scala.jdk.CollectionConverters.*
41+
val props = System.getProperties
42+
// This formulation should be immune to ConcurrentModificationExceptions when system properties
43+
// we're unlucky enough to witness a partially published result of System.setProperty or direct
44+
// mutation of the System property map. stringPropertyNames internally uses the Enumeration interface,
45+
// rather than Iterator, and this disables the fail-fast ConcurrentModificationException.
46+
val propNames = props.stringPropertyNames()
47+
propNames.asScala collectFirst { case k if k endsWith ".boot.class.path" => props.getProperty(k) } getOrElse ""
48+
}
4249

4350
/** Environment variables which java pays attention to so it
4451
* seems we do as well.
4552
*/
4653
def classPathEnv: String = envOrElse("CLASSPATH", "")
4754
def sourcePathEnv: String = envOrElse("SOURCEPATH", "")
4855

49-
def javaBootClassPath: String = propOrElse("sun.boot.class.path", searchForBootClasspath)
56+
//using propOrNone/getOrElse instead of propOrElse so that searchForBootClasspath is lazy evaluated
57+
def javaBootClassPath: String = propOrNone("sun.boot.class.path") getOrElse searchForBootClasspath
5058

5159
def javaExtDirs: String = propOrEmpty("java.ext.dirs")
5260
def scalaHome: String = propOrEmpty("scala.home")

Diff for: compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

+2-3
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,7 @@ private sealed trait XSettings:
353353
val XreadComments: Setting[Boolean] = BooleanSetting(AdvancedSetting, "Xread-docs", "Read documentation from tasty.")
354354

355355
/** Area-specific debug output */
356-
val XnoDecodeStacktraces: Setting[Boolean] = BooleanSetting(AdvancedSetting, "Xno-decode-stacktraces", "Show raw StackOverflow stacktraces, instead of decoding them into triggering operations.")
357-
val XnoEnrichErrorMessages: Setting[Boolean] = BooleanSetting(AdvancedSetting, "Xno-enrich-error-messages", "Show raw error messages, instead of enriching them with contextual information.")
356+
val XnoEnrichErrorMessages: Setting[Boolean] = BooleanSetting(AdvancedSetting, "Xno-enrich-error-messages", "Show raw error messages, instead of enriching them with contextual information.", aliases = List("Xno-decode-stacktraces"))
358357
val XdebugMacros: Setting[Boolean] = BooleanSetting(AdvancedSetting, "Xdebug-macros", "Show debug info when quote pattern match fails")
359358

360359
/** Pipeline compilation options */
@@ -487,7 +486,7 @@ private sealed trait YSettings:
487486
@deprecated(message = "Lifted to -X, Scheduled for removal.", since = "3.5.0")
488487
val YreadComments: Setting[Boolean] = BooleanSetting(ForkSetting, "Yread-docs", "Read documentation from tasty.", deprecation = Deprecation.renamed("-Xread-docs"))
489488
@deprecated(message = "Lifted to -X, Scheduled for removal.", since = "3.5.0")
490-
val YnoDecodeStacktraces: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-decode-stacktraces", "Show raw StackOverflow stacktraces, instead of decoding them into triggering operations.", deprecation = Deprecation.renamed("-Xno-decode-stacktraces"))
489+
val YnoDecodeStacktraces: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-decode-stacktraces", "Show raw StackOverflow stacktraces, instead of decoding them into triggering operations.", deprecation = Deprecation.renamed("-Xno-enrich-error-messages"))
491490
@deprecated(message = "Lifted to -X, Scheduled for removal.", since = "3.5.0")
492491
val YnoEnrichErrorMessages: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-enrich-error-messages", "Show raw error messages, instead of enriching them with contextual information.", deprecation = Deprecation.renamed("-Xno-enrich-error-messages"))
493492
@deprecated(message = "Lifted to -X, Scheduled for removal.", since = "3.5.0")

Diff for: compiler/src/dotty/tools/dotc/core/Flags.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ object Flags {
480480
*/
481481
val AfterLoadFlags: FlagSet = commonFlags(
482482
FromStartFlags, AccessFlags, Final, AccessorOrSealed,
483-
Abstract, LazyOrTrait, SelfName, JavaDefined, JavaAnnotation, Transparent, Tracked)
483+
Abstract, LazyOrTrait, SelfName, JavaDefined, JavaAnnotation, Transparent)
484484

485485
/** A value that's unstable unless complemented with a Stable flag */
486486
val UnstableValueFlags: FlagSet = Mutable | Method

Diff for: compiler/src/dotty/tools/dotc/core/SymDenotations.scala

+3-1
Original file line numberDiff line numberDiff line change
@@ -2539,7 +2539,9 @@ object SymDenotations {
25392539
)
25402540
if compiledNow.exists then compiledNow
25412541
else
2542-
val assocFiles = multi.aggregate(d => Set(d.symbol.associatedFile.nn), _ union _)
2542+
val assocFiles = multi
2543+
.filterWithPredicate(_.symbol.maybeOwner.isPackageObject)
2544+
.aggregate(d => Set(d.symbol.associatedFile.nn), _ union _)
25432545
if assocFiles.size == 1 then
25442546
multi // they are all overloaded variants from the same file
25452547
else

Diff for: compiler/src/dotty/tools/dotc/core/TypeErrors.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ extends TypeError:
117117
em"""Recursion limit exceeded.
118118
|Maybe there is an illegal cyclic reference?
119119
|If that's not the case, you could also try to increase the stacksize using the -Xss JVM option.
120-
|For the unprocessed stack trace, compile with -Xno-decode-stacktraces.
120+
|For the unprocessed stack trace, compile with -Xno-enrich-error-messages.
121121
|A recurring operation is (inner to outer):
122122
|${opsString(mostCommon).stripMargin}"""
123123

@@ -137,7 +137,7 @@ object handleRecursive:
137137
e
138138

139139
def apply(op: String, details: => String, exc: Throwable, weight: Int = 1)(using Context): Nothing =
140-
if ctx.settings.XnoDecodeStacktraces.value then
140+
if ctx.settings.XnoEnrichErrorMessages.value then
141141
throw exc
142142
else exc match
143143
case _: RecursionOverflow =>

0 commit comments

Comments
 (0)