Skip to content

Commit 5263feb

Browse files
authored
Merge branch 'scala:main' into patch-1
2 parents 88f62e9 + 64e7aa7 commit 5263feb

File tree

157 files changed

+2233
-723
lines changed

Some content is hidden

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

157 files changed

+2233
-723
lines changed

.github/workflows/ci.yaml

Lines changed: 23 additions & 302 deletions
Large diffs are not rendered by default.

NOTICE.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
Dotty (https://dotty.epfl.ch)
2-
Copyright 2012-2024 EPFL
3-
Copyright 2012-2024 Lightbend, Inc.
1+
Scala 3 (https://www.scala-lang.org)
2+
Copyright 2012-2025 EPFL
3+
Copyright 2012-2025 Lightbend, Inc. dba Akka
44

55
Licensed under the Apache License, Version 2.0 (the "License"):
66
http://www.apache.org/licenses/LICENSE-2.0
@@ -11,12 +11,13 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1111
See the License for the specific language governing permissions and
1212
limitations under the License.
1313

14-
The dotty compiler frontend has been developed since November 2012 by Martin
15-
Odersky. It is expected and hoped for that the list of contributors to the
16-
codebase will grow quickly. Dotty draws inspiration and code from the original
17-
Scala compiler "nsc", which is developed at scala/scala [1].
14+
The Scala 3 compiler is also known as Dotty. The Dotty compiler
15+
frontend has been developed since November 2012 by Martin Odersky. It
16+
is expected and hoped for that the list of contributors to the
17+
codebase will grow quickly. Dotty draws inspiration and code from the
18+
original Scala 2 compiler "nsc", which is still developed at scala/scala [1].
1819

19-
The majority of the dotty codebase is new code, with the exception of the
20+
The majority of the Dotty codebase is new code, with the exception of the
2021
components mentioned below. We have for each component tried to come up with a
2122
list of the original authors in the scala/scala [1] codebase. Apologies if some
2223
major authors were omitted by oversight.
@@ -28,7 +29,7 @@ major authors were omitted by oversight.
2829

2930
* dotty.tools.dotc.classpath: The classpath handling is taken mostly as is
3031
from scala/scala [1]. The original authors were Grzegorz Kossakowski,
31-
Michał Pociecha, Lukas Rytz, Jason Zaugg and others.
32+
Michał Pociecha, Lukas Rytz, Jason Zaugg and others.
3233

3334
* dotty.tools.dotc.config: The configuration components were adapted and
3435
extended from scala/scala [1]. The original sources were authored by Paul

community-build/test/scala/dotty/communitybuild/CommunityBuildTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class CommunityBuildTestC:
6868
@Test def fastparse = projects.fastparse.run()
6969
@Test def geny = projects.geny.run()
7070
@Test def intent = projects.intent.run()
71-
@Test def jacksonModuleScala = projects.jacksonModuleScala.run()
71+
//@Test def jacksonModuleScala = projects.jacksonModuleScala.run()
7272
@Test def libretto = projects.libretto.run()
7373
@Test def minitest = projects.minitest.run()
7474
//@Test def onnxScala = projects.onnxScala.run()

compiler/src/dotty/tools/dotc/CompilationUnit.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,14 @@ object CompilationUnit {
155155
unit1
156156
}
157157

158+
/** Create a compilation unit corresponding to an in-memory String.
159+
* Used for `compiletime.testing.typeChecks`.
160+
*/
161+
def apply(name: String, source: String)(using Context): CompilationUnit = {
162+
val src = SourceFile.virtual(name = name, content = source, maybeIncomplete = false)
163+
new CompilationUnit(src, null)
164+
}
165+
158166
/** Create a compilation unit corresponding to `source`.
159167
* If `mustExist` is true, this will fail if `source` does not exist.
160168
*/

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1667,7 +1667,7 @@ object desugar {
16671667
AppliedTypeTree(
16681668
TypeTree(defn.throwsAlias.typeRef).withSpan(op.span), tpt :: excepts :: Nil)
16691669

1670-
private def checkWellFormedTupleElems(elems: List[Tree])(using Context): List[Tree] =
1670+
def checkWellFormedTupleElems(elems: List[Tree])(using Context): List[Tree] =
16711671
val seen = mutable.Set[Name]()
16721672
for case arg @ NamedArg(name, _) <- elems do
16731673
if seen.contains(name) then
@@ -1744,7 +1744,7 @@ object desugar {
17441744
def adaptPatternArgs(elems: List[Tree], pt: Type)(using Context): List[Tree] =
17451745

17461746
def reorderedNamedArgs(wildcardSpan: Span): List[untpd.Tree] =
1747-
var selNames = pt.namedTupleElementTypes.map(_(0))
1747+
var selNames = pt.namedTupleElementTypes(false).map(_(0))
17481748
if selNames.isEmpty && pt.classSymbol.is(CaseClass) then
17491749
selNames = pt.classSymbol.caseAccessors.map(_.name.asTermName)
17501750
val nameToIdx = selNames.zipWithIndex.toMap

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ trait CommonScalaSettings:
126126
val encoding: Setting[String] = StringSetting(RootSetting, "encoding", "encoding", "Specify character encoding used by source files.", Properties.sourceEncoding, aliases = List("--encoding"))
127127
val usejavacp: Setting[Boolean] = BooleanSetting(RootSetting, "usejavacp", "Utilize the java.class.path in classpath resolution.", aliases = List("--use-java-class-path"))
128128
val scalajs: Setting[Boolean] = BooleanSetting(RootSetting, "scalajs", "Compile in Scala.js mode (requires scalajs-library.jar on the classpath).", aliases = List("--scalajs"))
129+
val replInitScript: Setting[String] = StringSetting(RootSetting, "repl-init-script", "code", "The code will be run on REPL startup.", "", aliases = List("--repl-init-script"))
129130
end CommonScalaSettings
130131

131132
/** -P "plugin" settings. Various tools might support plugins. */

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ enum SourceVersion:
1313
case `3.5-migration`, `3.5`
1414
case `3.6-migration`, `3.6`
1515
case `3.7-migration`, `3.7`
16+
case `3.8-migration`, `3.8`
1617
// !!! Keep in sync with scala.runtime.stdlibPatches.language !!!
1718
case `future-migration`, `future`
1819

@@ -31,7 +32,7 @@ enum SourceVersion:
3132
def isAtMost(v: SourceVersion) = stable.ordinal <= v.ordinal
3233

3334
object SourceVersion extends Property.Key[SourceVersion]:
34-
def defaultSourceVersion = `3.6`
35+
def defaultSourceVersion = `3.7`
3536

3637
/** language versions that may appear in a language import, are deprecated, but not removed from the standard library. */
3738
val illegalSourceVersionNames = List("3.1-migration", "never").map(_.toTermName)

compiler/src/dotty/tools/dotc/core/Contexts.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import util.Store
4141
import plugins.*
4242
import java.util.concurrent.atomic.AtomicInteger
4343
import java.nio.file.InvalidPathException
44+
import dotty.tools.dotc.coverage.Coverage
4445

4546
object Contexts {
4647

@@ -982,6 +983,11 @@ object Contexts {
982983
/** Was best effort file used during compilation? */
983984
private[core] var usedBestEffortTasty = false
984985

986+
/** If coverage option is used, it stores all instrumented statements (for InstrumentCoverage).
987+
* We need this information to be persisted across different runs, so it's stored here.
988+
*/
989+
private[dotc] var coverage: Coverage | Null = null
990+
985991
// Types state
986992
/** A table for hash consing unique types */
987993
private[core] val uniques: Uniques = Uniques()

compiler/src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,10 +1337,25 @@ class Definitions {
13371337
object NamedTuple:
13381338
def apply(nmes: Type, vals: Type)(using Context): Type =
13391339
AppliedType(NamedTupleTypeRef, nmes :: vals :: Nil)
1340-
def unapply(t: Type)(using Context): Option[(Type, Type)] = t match
1341-
case AppliedType(tycon, nmes :: vals :: Nil) if tycon.typeSymbol == NamedTupleTypeRef.symbol =>
1342-
Some((nmes, vals))
1343-
case _ => None
1340+
def unapply(t: Type)(using Context): Option[(Type, Type)] =
1341+
t match
1342+
case AppliedType(tycon, nmes :: vals :: Nil) if tycon.typeSymbol == NamedTupleTypeRef.symbol =>
1343+
Some((nmes, vals))
1344+
case tp: TypeProxy =>
1345+
val t = unapply(tp.superType); t
1346+
case tp: OrType =>
1347+
(unapply(tp.tp1), unapply(tp.tp2)) match
1348+
case (Some(lhsName, lhsVal), Some(rhsName, rhsVal)) if lhsName == rhsName =>
1349+
Some(lhsName, lhsVal | rhsVal)
1350+
case _ => None
1351+
case tp: AndType =>
1352+
(unapply(tp.tp1), unapply(tp.tp2)) match
1353+
case (Some(lhsName, lhsVal), Some(rhsName, rhsVal)) if lhsName == rhsName =>
1354+
Some(lhsName, lhsVal & rhsVal)
1355+
case (lhs, None) => lhs
1356+
case (None, rhs) => rhs
1357+
case _ => None
1358+
case _ => None
13441359

13451360
final def isCompiletime_S(sym: Symbol)(using Context): Boolean =
13461361
sym.name == tpnme.S && sym.owner == CompiletimeOpsIntModuleClass

compiler/src/dotty/tools/dotc/core/Phases.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ object Phases {
222222
private var mySbtExtractDependenciesPhase: Phase = uninitialized
223223
private var mySbtExtractAPIPhase: Phase = uninitialized
224224
private var myPicklerPhase: Phase = uninitialized
225+
private var mySetRootTreePhase: Phase = uninitialized
225226
private var myInliningPhase: Phase = uninitialized
226227
private var myStagingPhase: Phase = uninitialized
227228
private var mySplicingPhase: Phase = uninitialized
@@ -249,6 +250,7 @@ object Phases {
249250
final def sbtExtractDependenciesPhase: Phase = mySbtExtractDependenciesPhase
250251
final def sbtExtractAPIPhase: Phase = mySbtExtractAPIPhase
251252
final def picklerPhase: Phase = myPicklerPhase
253+
final def setRootTreePhase: Phase = mySetRootTreePhase
252254
final def inliningPhase: Phase = myInliningPhase
253255
final def stagingPhase: Phase = myStagingPhase
254256
final def splicingPhase: Phase = mySplicingPhase
@@ -278,6 +280,7 @@ object Phases {
278280
myPostTyperPhase = phaseOfClass(classOf[PostTyper])
279281
mySbtExtractDependenciesPhase = phaseOfClass(classOf[sbt.ExtractDependencies])
280282
mySbtExtractAPIPhase = phaseOfClass(classOf[sbt.ExtractAPI])
283+
mySetRootTreePhase = phaseOfClass(classOf[SetRootTree])
281284
myPicklerPhase = phaseOfClass(classOf[Pickler])
282285
myInliningPhase = phaseOfClass(classOf[Inlining])
283286
myStagingPhase = phaseOfClass(classOf[Staging])

0 commit comments

Comments
 (0)