Skip to content

Commit

Permalink
Merge branch 'scala:main' into capture-subtyping
Browse files Browse the repository at this point in the history
  • Loading branch information
bracevac authored Dec 22, 2024
2 parents 4c76323 + d50973b commit 7acd730
Show file tree
Hide file tree
Showing 90 changed files with 765 additions and 324 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE/fix-issue.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ assignees: ''

<!--
TODO first sign the CLA
https://www.lightbend.com/contribute/cla/scala
https://contribute.akka.io/cla/scala
-->

## Fix #XYZ
Expand Down
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE/other-pr.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ assignees: ''

<!--
TODO first sign the CLA
https://www.lightbend.com/contribute/cla/scala
https://contribute.akka.io/cla/scala
-->

## Description
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ jobs:
distribution: temurin
java-version: ${{ inputs.java-version }}
cache : sbt
- uses: sbt/setup-sbt@v1
- name: Build and pack the SDK (universal)
run : ./project/scripts/sbt dist/Universal/stage
- name: Build and pack the SDK (linux x86-64)
Expand Down
12 changes: 3 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -801,19 +801,13 @@ jobs:
distDir="$3"
# Build binaries
./project/scripts/sbt "${sbtProject}/Universal/stage"
./project/scripts/sbt "all ${sbtProject}/Universal/packageBin ${sbtProject}/Universal/packageZipTarball"
outputPath="${distDir}/target/universal/stage"
artifactName="scala3-${{ env.RELEASE_TAG }}${distroSuffix}"
zipArchive="${artifactName}.zip"
tarGzArchive="${artifactName}.tar.gz"
cwd=$(pwd)
(cd $outputPath && zip -r ${zipArchive} . && mv ${zipArchive} "${cwd}/")
tar -czf ${tarGzArchive} -C "$outputPath" .
# Caluclate SHA for each of archive files
for file in "${zipArchive}" "${tarGzArchive}"; do
for file in "${artifactName}.zip" "${artifactName}.tar.gz"; do
mv ${distDir}/target/universal/$file $file
sha256sum "${file}" > "${file}.sha256"
done
}
Expand Down
17 changes: 4 additions & 13 deletions .github/workflows/cla.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,11 @@ on:
pull_request:
branches-ignore:
- 'language-reference-stable'
push:
branches:
- 'language-reference-stable'
merge_group:
permissions:
contents: write
pull-requests: write

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: ./project/scripts/check-cla.sh
if: github.event_name == 'pull_request'
env:
AUTHOR: ${{ github.event.pull_request.user.login }}
- name: Verify CLA
uses: scala/cla-checker@v1
with:
author: ${{ github.event.pull_request.user.login }}
1 change: 1 addition & 0 deletions .github/workflows/dependency-graph.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: sbt/setup-sbt@v1
- uses: scalacenter/sbt-dependency-submission@v3
env:
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
1 change: 1 addition & 0 deletions .github/workflows/language-reference.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
distribution: 'temurin'
java-version: 17
cache: 'sbt'
- uses: sbt/setup-sbt@v1

- name: Generate reference documentation and test links
run: |
Expand Down
14 changes: 5 additions & 9 deletions .github/workflows/launchers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
java-version: '17'
distribution: 'temurin'
cache: 'sbt'
- uses: sbt/setup-sbt@v1
- name: Build and test launcher command
run: ./project/scripts/native-integration/bashTests
env:
Expand All @@ -37,9 +38,7 @@ jobs:
java-version: '17'
distribution: 'temurin'
cache: 'sbt'
# https://github.com/actions/runner-images/issues/9369
- name: Install sbt
run: brew install sbt
- uses: sbt/setup-sbt@v1
- name: Build and test launcher command
run: ./project/scripts/native-integration/bashTests
env:
Expand All @@ -58,9 +57,7 @@ jobs:
java-version: '17'
distribution: 'temurin'
cache: 'sbt'
# https://github.com/actions/runner-images/issues/9369
- name: Install sbt
run: brew install sbt
- uses: sbt/setup-sbt@v1
- name: Build and test launcher command
run: ./project/scripts/native-integration/bashTests
env:
Expand All @@ -79,9 +76,7 @@ jobs:
java-version: '17'
distribution: 'temurin'
cache: 'sbt'
# https://github.com/actions/runner-images/issues/9369
- name: Install sbt
run: brew install sbt
- uses: sbt/setup-sbt@v1
- name: Build and test launcher command
run: ./project/scripts/native-integration/bashTests
env:
Expand All @@ -100,6 +95,7 @@ jobs:
java-version: '17'
distribution: 'temurin'
cache: 'sbt'
- uses: sbt/setup-sbt@v1
- name: Build the launcher command
run: sbt "dist-win-x86_64/Universal/stage"
- name: Run the launcher command tests
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-chocolatey.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ jobs:
with:
name: scala.nupkg
- name: Publish the package to Chocolatey
run: choco push scala.nupkg --source https://push.chocolatey.org/ --api-key ${{ secrets.API-KEY }}
run: choco push scala.${{inputs.version}}.nupkg --source https://push.chocolatey.org/ --api-key ${{ secrets.API-KEY }}

1 change: 1 addition & 0 deletions .github/workflows/scaladoc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
java-version: 17
cache: 'sbt'

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

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-cc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ jobs:
steps:
- name: Git Checkout
uses: actions/checkout@v4
- uses: sbt/setup-sbt@v1
- name: Test with Scala 2 library with CC TASTy
run: ./project/scripts/sbt ";set ThisBuild/Build.scala2Library := Build.Scala2LibraryCCTasty ;scala3-bootstrapped/test"
3 changes: 1 addition & 2 deletions .vscode-template/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"**/*.class": true,
"**/*.tasty": true,
"**/target/": true,
"community-build/community-projects": true,
"tests/pos-with-compiler-cc/dotc/**/*.scala": true
"community-build/community-projects": true
}
}
10 changes: 5 additions & 5 deletions MAINTENANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ The following is the list of all the principal areas of the compiler and the int
- Parser: @odersky, @hamzaremmal, @KacperFKorban
- Typer: @odersky, @smarter, (@dwijnand), @noti0nal, @EugeneFlesselle, @KacperFKorban, @bracevac
- Erasure: @smarter, @odersky
- Enums:
- Enums:
- Derivation & Mirrors: (@dwijnand), @EugeneFlesselle
- Export: @odersky
- Pattern Matching: @dwijnand, @sjrd, @noti0na1
- Inline: @odersky, @jchyb, @hamzaremmal, @EugeneFlesselle
- Metaprogramming (Quotes, Reflect, Staging): @jchyb, @hamzaremmal
- Match types: @sjrd, @dwijnand, @Linyxus, @EugeneFlesselle
- GADT: @dwijnand, @Linyxus
- Initialization checker:
- Initialization checker:
- Transforms: @sjrd, @odersky, @smarter
- Tailrec: @sjrd, @mbovel
- JS backend: @sjrd
Expand All @@ -87,17 +87,17 @@ The following is the list of all the principal areas of the compiler and the int
- Safe nulls (experimental): @noti0na1
- Capture checker (experimental): @odersky, @Linyxus, @bracevac, @noti0na1
- Modularity (experimental): @KacperFKorban
- Named Tuples (experimental): @odersky
- Named Tuples (experimental): @odersky, @aherlihy

### Tooling
- REPL: @dwijnand
- Runner/CLI: @Gedochao, (@tgodzik)
- IDE: @tgodzik, (@kasiaMarek)
- Scaladoc: @Florian3k
- SemanticDB: @natsukagami, (@tanishiking)
- Coverage: @KacperFKorban
- Coverage: @KacperFKorban
- Linting (especially unused warnings) / Reporting UX: @KacperFKorban
- Presentation Compiler: @rochala, @tgodzik, @kasiaMarek, @natsukagami
- Presentation Compiler: @rochala, @tgodzik, @kasiaMarek, @natsukagami
- Debug Adapter: @adpi2, (@tgodzik)
- Scastie: @rochala

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ trait BCodeSkelBuilder extends BCodeHelpers {
*/
object locals {

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

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

Expand Down
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/backend/jvm/BackendUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ object BackendUtils {
20 -> asm.Opcodes.V20,
21 -> asm.Opcodes.V21,
22 -> asm.Opcodes.V22,
23 -> asm.Opcodes.V23
23 -> asm.Opcodes.V23,
24 -> asm.Opcodes.V24
)
}
31 changes: 22 additions & 9 deletions compiler/src/dotty/tools/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -694,15 +694,15 @@ object desugar {
val originalTparams = constr1.leadingTypeParams
val originalVparamss = asTermOnly(constr1.trailingParamss)
lazy val derivedEnumParams = enumClass.typeParams.map(derivedTypeParamWithVariance)
val impliedTparams =
if (isEnumCase) {
val enumTParams =
if isEnumCase then
val tparamReferenced = typeParamIsReferenced(
enumClass.typeParams, originalTparams, originalVparamss, parents)
if (originalTparams.isEmpty && (parents.isEmpty || tparamReferenced))
enumClass.typeParams, originalTparams, originalVparamss, parents)
if originalTparams.isEmpty && (parents.isEmpty || tparamReferenced) then
derivedEnumParams.map(tdef => tdef.withFlags(tdef.mods.flags | PrivateLocal))
else originalTparams
}
else originalTparams
else Nil
else Nil
val impliedTparams = enumTParams ++ originalTparams

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

val constr = cpy.DefDef(constr1)(paramss = joinParams(constrTparams, constrVparamss))
if enumTParams.nonEmpty then
defaultGetters = defaultGetters.map:
case ddef: DefDef =>
val tParams = enumTParams.map(tparam => toMethParam(tparam, KeepAnnotations.All))
cpy.DefDef(ddef)(paramss = joinParams(tParams, ddef.trailingParamss))

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

Expand Down Expand Up @@ -1556,6 +1562,12 @@ object desugar {
rhsOK(rhs)
}

val legalTracked: Context ?=> MemberDefTest = {
case valdef @ ValDef(_, _, _) =>
val sym = valdef.symbol
!ctx.owner.exists || ctx.owner.isClass || ctx.owner.is(Case) || ctx.owner.isConstructor || valdef.mods.is(Param) || valdef.mods.is(ParamAccessor)
}

def checkOpaqueAlias(tree: MemberDef)(using Context): MemberDef =
def check(rhs: Tree): MemberDef = rhs match
case bounds: TypeBoundsTree if bounds.alias.isEmpty =>
Expand All @@ -1581,6 +1593,7 @@ object desugar {
} else tested
tested = checkOpaqueAlias(tested)
tested = checkApplicable(Opaque, legalOpaque)
tested = checkApplicable(Tracked, legalTracked)
tested
case _ =>
tree
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ final class CtSymClassPath(ctSym: java.nio.file.Path, release: Int) extends Clas

// e.g. "java.lang" -> Seq(/876/java/lang, /87/java/lang, /8/java/lang))
private val packageIndex: scala.collection.Map[String, scala.collection.Seq[Path]] = {
val index = collection.mutable.AnyRefMap[String, collection.mutable.ListBuffer[Path]]()
val index = collection.mutable.HashMap[String, collection.mutable.ListBuffer[Path]]()
val isJava12OrHigher = scala.util.Properties.isJavaAtLeast("12")
rootsForRelease.foreach(root => Files.walk(root).iterator().asScala.filter(Files.isDirectory(_)).foreach { p =>
val moduleNamePathElementCount = if (isJava12OrHigher) 1 else 0
Expand Down
16 changes: 12 additions & 4 deletions compiler/src/dotty/tools/dotc/config/PathResolver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,25 @@ object PathResolver {
/** Values found solely by inspecting environment or property variables.
*/
object Environment {
private def searchForBootClasspath = (
systemProperties find (_._1 endsWith ".boot.class.path") map (_._2) getOrElse ""
)
private def searchForBootClasspath = {
import scala.jdk.CollectionConverters.*
val props = System.getProperties
// This formulation should be immune to ConcurrentModificationExceptions when system properties
// we're unlucky enough to witness a partially published result of System.setProperty or direct
// mutation of the System property map. stringPropertyNames internally uses the Enumeration interface,
// rather than Iterator, and this disables the fail-fast ConcurrentModificationException.
val propNames = props.stringPropertyNames()
propNames.asScala collectFirst { case k if k endsWith ".boot.class.path" => props.getProperty(k) } getOrElse ""
}

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

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

def javaExtDirs: String = propOrEmpty("java.ext.dirs")
def scalaHome: String = propOrEmpty("scala.home")
Expand Down
5 changes: 2 additions & 3 deletions compiler/src/dotty/tools/dotc/config/ScalaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,7 @@ private sealed trait XSettings:
val XreadComments: Setting[Boolean] = BooleanSetting(AdvancedSetting, "Xread-docs", "Read documentation from tasty.")

/** Area-specific debug output */
val XnoDecodeStacktraces: Setting[Boolean] = BooleanSetting(AdvancedSetting, "Xno-decode-stacktraces", "Show raw StackOverflow stacktraces, instead of decoding them into triggering operations.")
val XnoEnrichErrorMessages: Setting[Boolean] = BooleanSetting(AdvancedSetting, "Xno-enrich-error-messages", "Show raw error messages, instead of enriching them with contextual information.")
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"))
val XdebugMacros: Setting[Boolean] = BooleanSetting(AdvancedSetting, "Xdebug-macros", "Show debug info when quote pattern match fails")

/** Pipeline compilation options */
Expand Down Expand Up @@ -487,7 +486,7 @@ private sealed trait YSettings:
@deprecated(message = "Lifted to -X, Scheduled for removal.", since = "3.5.0")
val YreadComments: Setting[Boolean] = BooleanSetting(ForkSetting, "Yread-docs", "Read documentation from tasty.", deprecation = Deprecation.renamed("-Xread-docs"))
@deprecated(message = "Lifted to -X, Scheduled for removal.", since = "3.5.0")
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"))
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"))
@deprecated(message = "Lifted to -X, Scheduled for removal.", since = "3.5.0")
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"))
@deprecated(message = "Lifted to -X, Scheduled for removal.", since = "3.5.0")
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/Flags.scala
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ object Flags {
*/
val AfterLoadFlags: FlagSet = commonFlags(
FromStartFlags, AccessFlags, Final, AccessorOrSealed,
Abstract, LazyOrTrait, SelfName, JavaDefined, JavaAnnotation, Transparent, Tracked)
Abstract, LazyOrTrait, SelfName, JavaDefined, JavaAnnotation, Transparent)

/** A value that's unstable unless complemented with a Stable flag */
val UnstableValueFlags: FlagSet = Mutable | Method
Expand Down
4 changes: 3 additions & 1 deletion compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2539,7 +2539,9 @@ object SymDenotations {
)
if compiledNow.exists then compiledNow
else
val assocFiles = multi.aggregate(d => Set(d.symbol.associatedFile.nn), _ union _)
val assocFiles = multi
.filterWithPredicate(_.symbol.maybeOwner.isPackageObject)
.aggregate(d => Set(d.symbol.associatedFile.nn), _ union _)
if assocFiles.size == 1 then
multi // they are all overloaded variants from the same file
else
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/core/TypeErrors.scala
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ extends TypeError:
em"""Recursion limit exceeded.
|Maybe there is an illegal cyclic reference?
|If that's not the case, you could also try to increase the stacksize using the -Xss JVM option.
|For the unprocessed stack trace, compile with -Xno-decode-stacktraces.
|For the unprocessed stack trace, compile with -Xno-enrich-error-messages.
|A recurring operation is (inner to outer):
|${opsString(mostCommon).stripMargin}"""

Expand All @@ -137,7 +137,7 @@ object handleRecursive:
e

def apply(op: String, details: => String, exc: Throwable, weight: Int = 1)(using Context): Nothing =
if ctx.settings.XnoDecodeStacktraces.value then
if ctx.settings.XnoEnrichErrorMessages.value then
throw exc
else exc match
case _: RecursionOverflow =>
Expand Down
Loading

0 comments on commit 7acd730

Please sign in to comment.