Skip to content

Commit 9baaddd

Browse files
committed
Merge branch 'main' into scaladoc-types-rendering-fixes
2 parents 5e280e0 + d0b790e commit 9baaddd

File tree

681 files changed

+11374
-7048
lines changed

Some content is hidden

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

681 files changed

+11374
-7048
lines changed

.github/workflows/ci.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ jobs:
253253

254254
- name: MiMa
255255
run: |
256-
./project/scripts/sbt ";scala3-interfaces/mimaReportBinaryIssues ;scala3-library-bootstrapped/mimaReportBinaryIssues ;scala3-library-bootstrappedJS/mimaReportBinaryIssues; tasty-core-bootstrapped/mimaReportBinaryIssues"
256+
./project/scripts/sbt ";scala3-interfaces/mimaReportBinaryIssues ;scala3-library-bootstrapped/mimaReportBinaryIssues ;scala3-library-bootstrappedJS/mimaReportBinaryIssues; tasty-core-bootstrapped/mimaReportBinaryIssues; stdlib-bootstrapped/mimaReportBinaryIssues"
257257
258258
community_build_a:
259259
runs-on: [self-hosted, Linux]

.github/workflows/scaladoc.yaml

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ on:
44
push:
55
branches-ignore:
66
- 'language-reference-stable'
7+
- 'gh-readonly-queue/**'
78
pull_request:
89
branches-ignore:
910
- 'language-reference-stable'
11+
merge_group:
1012
permissions:
1113
contents: read
1214

@@ -15,7 +17,8 @@ jobs:
1517
env:
1618
AZURE_STORAGE_SAS_TOKEN: ${{ secrets.AZURE_STORAGE_SAS_TOKEN }}
1719
runs-on: ubuntu-latest
18-
if: "( github.event_name == 'pull_request'
20+
if: "github.event_name == 'merge_group'
21+
|| ( github.event_name == 'pull_request'
1922
&& !contains(github.event.pull_request.body, '[skip ci]')
2023
&& !contains(github.event.pull_request.body, '[skip docs]')
2124
)

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
Firstly, thanks for being willing to contribute to Dotty! Head on over the
44
[Scala 3 Contributing
5-
Guide](https://docs.scala-lang.org/scala3/guides/contribution/contribution-intro.html), which should have all the info you're looking for.
5+
Guide](https://dotty.epfl.ch/docs/contributing/index.html), which should have all the info you're looking for.

MAINTENANCE.md

+20-12
Original file line numberDiff line numberDiff line change
@@ -61,28 +61,36 @@ At the end of their supervision period, the supervisor reports to the team durin
6161

6262
The following is the list of all the principal areas of the compiler and the core team members who are responsible for their maintenance:
6363

64+
### Compiler
6465
- Parser: @odersky
6566
- Typer: @odersky, @smarter, (@dwijnand)
6667
- Erasure: @smarter, @odersky
6768
- Enums: @bishabosha
69+
- Derivation & Mirrors: @bishabosha, (@dwijnand)
6870
- Export: @bishabosha, @odersky
6971
- Pattern Matching: @dwijnand, (@liufengyun), @sjrd
7072
- Inline: @nicolasstucki, @odersky
71-
- Metaprogramming (Quotes, Reflect, Staging): @nicolasstucki, @aherlihy
72-
- Match types: @OlivierBlanvillain, @dwijnand
73-
- GADT: @abgruszecki, @dwijnand
74-
- Scaladoc: @KacperFKorban, @BarkingBad, @pikinier20
75-
- Initialization checker: @olhotak, @liufengyun, @anatoliykmetyuk
73+
- Metaprogramming (Quotes, Reflect, Staging): @nicolasstucki, @jchyb
74+
- Match types: @sjrd, @dwijnand, @Decel
75+
- GADT: @dwijnand, @Linyxus
76+
- Initialization checker: @olhotak, @liufengyun
7677
- Safe nulls: @noti0na1, @olhotak
78+
- Lazy vals: @szymon-rd, @sjrd
7779
- tailrec: @sjrd, @mbovel
7880
- JS backend: @sjrd
79-
- forward compat (-scala-release): @prolativ, @Kordyjan, (@nicolasstucki)
80-
- Benchmarks: @anatoliykmetyuk, @mbovel
81-
- REPL: @dwijnand, @anatoliykmetyuk, @prolativ
81+
- JVM backend: @sjrd
82+
- Java-compat: @smarter
83+
84+
### Tooling
85+
- REPL: @dwijnand, @prolativ
86+
- Scaladoc: @Florian3k
87+
- SemanticDB: @tanishiking
88+
- Coverage: @TheElectronWill
89+
- Linting (especially unused warnings) / Reporting UX: @szymon-rd
90+
91+
### Infrastructure
8292
- CI: @anatoliykmetyuk
8393
- Community Build: @anatoliykmetyuk
94+
- Open Community Build: @WojciechMazur
8495
- Vulpix: @dwijnand, @prolativ
85-
- JVM backend: @Kordyjan, (@sjrd)
86-
- Derivation & Mirrors: @bishabosha, (@dwijnand)
87-
- Linting (especially unused warnings) / Reporting UX: VirtusLab TBD?
88-
- Java-compat: @Kordyjan
96+
- Benchmarks: @mbovel

community-build/src/scala/dotty/communitybuild/projects.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ final case class SbtCommunityProject(
140140
case Some(ivyHome) => List(s"-Dsbt.ivy.home=$ivyHome")
141141
case _ => Nil
142142
extraSbtArgs ++ sbtProps ++ List(
143-
"-sbt-version", "1.8.0",
143+
"-sbt-version", "1.8.2",
144144
"-Dsbt.supershell=false",
145145
s"-Ddotty.communitybuild.dir=$communitybuildDir",
146146
s"--addPluginSbtFile=$sbtPluginFilePath"

compiler/src/dotty/tools/backend/jvm/BackendUtils.scala

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class BackendUtils(val postProcessor: PostProcessor) {
3535
case "18" => asm.Opcodes.V18
3636
case "19" => asm.Opcodes.V19
3737
case "20" => asm.Opcodes.V20
38+
case "21" => asm.Opcodes.V21
3839
}
3940

4041
lazy val extraProc: Int = {

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,13 @@ object CompilationUnit {
154154
var containsCaptureChecking = false
155155
var containsMacroAnnotation = false
156156
def traverse(tree: Tree)(using Context): Unit = {
157-
if (tree.symbol.isQuote)
158-
containsQuote = true
159157
if tree.symbol.is(Flags.Inline) then
160158
containsInline = true
161159
tree match
160+
case _: tpd.Quote =>
161+
containsQuote = true
162+
case tree: tpd.Apply if tree.symbol == defn.QuotedTypeModule_of =>
163+
containsQuote = true
162164
case Import(qual, selectors) =>
163165
tpd.languageImport(qual) match
164166
case Some(prefix) =>

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

+5-4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Compiler {
3535
protected def frontendPhases: List[List[Phase]] =
3636
List(new Parser) :: // Compiler frontend: scanner, parser
3737
List(new TyperPhase) :: // Compiler frontend: namer, typer
38-
List(new CheckUnused) :: // Check for unused elements
38+
List(new CheckUnused.PostTyper) :: // Check for unused elements
3939
List(new YCheckPositions) :: // YCheck positions
4040
List(new sbt.ExtractDependencies) :: // Sends information on classes' dependencies to sbt via callbacks
4141
List(new semanticdb.ExtractSemanticDB) :: // Extract info into .semanticdb files
@@ -50,6 +50,7 @@ class Compiler {
5050
List(new Pickler) :: // Generate TASTY info
5151
List(new Inlining) :: // Inline and execute macros
5252
List(new PostInlining) :: // Add mirror support for inlined code
53+
List(new CheckUnused.PostInlining) :: // Check for unused elements
5354
List(new Staging) :: // Check staging levels and heal staged types
5455
List(new Splicing) :: // Replace level 1 splices with holes
5556
List(new PickleQuotes) :: // Turn quoted trees into explicit run-time data structures
@@ -58,7 +59,8 @@ class Compiler {
5859
/** Phases dealing with the transformation from pickled trees to backend trees */
5960
protected def transformPhases: List[List[Phase]] =
6061
List(new InstrumentCoverage) :: // Perform instrumentation for code coverage (if -coverage-out is set)
61-
List(new FirstTransform, // Some transformations to put trees into a canonical form
62+
List(new CrossVersionChecks, // Check issues related to deprecated and experimental
63+
new FirstTransform, // Some transformations to put trees into a canonical form
6264
new CheckReentrant, // Internal use only: Check that compiled program has no data races involving global vars
6365
new ElimPackagePrefixes, // Eliminate references to package prefixes in Select nodes
6466
new CookComments, // Cook the comments: expand variables, doc, etc.
@@ -70,8 +72,7 @@ class Compiler {
7072
new ElimRepeated, // Rewrite vararg parameters and arguments
7173
new RefChecks) :: // Various checks mostly related to abstract members and overriding
7274
List(new init.Checker) :: // Check initialization of objects
73-
List(new CrossVersionChecks, // Check issues related to deprecated and experimental
74-
new ProtectedAccessors, // Add accessors for protected members
75+
List(new ProtectedAccessors, // Add accessors for protected members
7576
new ExtensionMethods, // Expand methods of value classes with extension methods
7677
new UncacheGivenAliases, // Avoid caching RHS of simple parameterless given aliases
7778
new ElimByName, // Map by-name parameters to functions

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

+23-20
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,9 @@ object desugar {
338338
def quotedPattern(tree: untpd.Tree, expectedTpt: untpd.Tree)(using Context): untpd.Tree = {
339339
def adaptToExpectedTpt(tree: untpd.Tree): untpd.Tree = tree match {
340340
// Add the expected type as an ascription
341-
case _: untpd.Splice =>
341+
case _: untpd.SplicePattern =>
342342
untpd.Typed(tree, expectedTpt).withSpan(tree.span)
343-
case Typed(expr: untpd.Splice, tpt) =>
343+
case Typed(expr: untpd.SplicePattern, tpt) =>
344344
cpy.Typed(tree)(expr, untpd.makeAndType(tpt, expectedTpt).withSpan(tpt.span))
345345

346346
// Propagate down the expected type to the leafs of the expression
@@ -637,7 +637,10 @@ object desugar {
637637
// new C[...](p1, ..., pN)(moreParams)
638638
val (caseClassMeths, enumScaffolding) = {
639639
def syntheticProperty(name: TermName, tpt: Tree, rhs: Tree) =
640-
DefDef(name, Nil, tpt, rhs).withMods(synthetic)
640+
val mods =
641+
if ctx.settings.Yscala2Stdlib.value then synthetic | Inline
642+
else synthetic
643+
DefDef(name, Nil, tpt, rhs).withMods(mods)
641644

642645
def productElemMeths =
643646
val caseParams = derivedVparamss.head.toArray
@@ -735,13 +738,25 @@ object desugar {
735738
.withMods(appMods) :: Nil
736739
}
737740
val unapplyMeth = {
741+
def scala2LibCompatUnapplyRhs(unapplyParamName: Name) =
742+
assert(arity <= Definitions.MaxTupleArity, "Unexpected case class with tuple larger than 22: "+ cdef.show)
743+
if arity == 1 then Apply(scalaDot(nme.Option), Select(Ident(unapplyParamName), nme._1))
744+
else
745+
val tupleApply = Select(Ident(nme.scala), s"Tuple$arity".toTermName)
746+
val members = List.tabulate(arity) { n => Select(Ident(unapplyParamName), s"_${n+1}".toTermName) }
747+
Apply(scalaDot(nme.Option), Apply(tupleApply, members))
748+
738749
val hasRepeatedParam = constrVparamss.head.exists {
739750
case ValDef(_, tpt, _) => isRepeated(tpt)
740751
}
741752
val methName = if (hasRepeatedParam) nme.unapplySeq else nme.unapply
742753
val unapplyParam = makeSyntheticParameter(tpt = classTypeRef)
743-
val unapplyRHS = if (arity == 0) Literal(Constant(true)) else Ident(unapplyParam.name)
754+
val unapplyRHS =
755+
if (arity == 0) Literal(Constant(true))
756+
else if ctx.settings.Yscala2Stdlib.value then scala2LibCompatUnapplyRhs(unapplyParam.name)
757+
else Ident(unapplyParam.name)
744758
val unapplyResTp = if (arity == 0) Literal(Constant(true)) else TypeTree()
759+
745760
DefDef(
746761
methName,
747762
joinParams(derivedTparams, (unapplyParam :: Nil) :: Nil),
@@ -1824,16 +1839,6 @@ object desugar {
18241839
flatTree(pats1 map (makePatDef(tree, mods, _, rhs)))
18251840
case ext: ExtMethods =>
18261841
Block(List(ext), Literal(Constant(())).withSpan(ext.span))
1827-
case CapturingTypeTree(refs, parent) =>
1828-
// convert `{refs} T` to `T @retains refs`
1829-
// `{refs}-> T` to `-> (T @retainsByName refs)`
1830-
def annotate(annotName: TypeName, tp: Tree) =
1831-
Annotated(tp, New(scalaAnnotationDot(annotName), List(refs)))
1832-
parent match
1833-
case ByNameTypeTree(restpt) =>
1834-
cpy.ByNameTypeTree(parent)(annotate(tpnme.retainsByName, restpt))
1835-
case _ =>
1836-
annotate(tpnme.retains, parent)
18371842
case f: FunctionWithMods if f.hasErasedParams => makeFunctionWithValDefs(f, pt)
18381843
}
18391844
desugared.withSpan(tree.span)
@@ -1927,7 +1932,7 @@ object desugar {
19271932
}
19281933
tree match
19291934
case tree: FunctionWithMods =>
1930-
untpd.FunctionWithMods(applyVParams, tree.body, tree.mods, tree.erasedParams)
1935+
untpd.FunctionWithMods(applyVParams, result, tree.mods, tree.erasedParams)
19311936
case _ => untpd.Function(applyVParams, result)
19321937
}
19331938
}
@@ -1986,15 +1991,13 @@ object desugar {
19861991
trees foreach collect
19871992
case Block(Nil, expr) =>
19881993
collect(expr)
1989-
case Quote(expr) =>
1994+
case Quote(body, _) =>
19901995
new UntypedTreeTraverser {
19911996
def traverse(tree: untpd.Tree)(using Context): Unit = tree match {
1992-
case Splice(expr) => collect(expr)
1997+
case SplicePattern(body, _) => collect(body)
19931998
case _ => traverseChildren(tree)
19941999
}
1995-
}.traverse(expr)
1996-
case CapturingTypeTree(refs, parent) =>
1997-
collect(parent)
2000+
}.traverse(body)
19982001
case _ =>
19992002
}
20002003
collect(tree)

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

+12-27
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,6 @@ trait TreeInfo[T <: Untyped] { self: Trees.Instance[T] =>
223223
/** Strip `=> T` to `T` and (under pureFunctions) `{refs}-> T` to `T` */
224224
def stripByNameType(tree: Tree)(using Context): Tree = unsplice(tree) match
225225
case ByNameTypeTree(t1) => t1
226-
case untpd.CapturingTypeTree(_, parent) =>
227-
val parent1 = stripByNameType(parent)
228-
if parent1 eq parent then tree else parent1
229226
case _ => tree
230227

231228
/** All type and value parameter symbols of this DefDef */
@@ -467,19 +464,21 @@ trait UntypedTreeInfo extends TreeInfo[Untyped] { self: Trees.Instance[Untyped]
467464
}
468465
}
469466

470-
/** Under pureFunctions: A builder and extractor for `=> T`, which is an alias for `{*}-> T`.
471-
* Only trees of the form `=> T` are matched; trees written directly as `{*}-> T`
467+
/** Under pureFunctions: A builder and extractor for `=> T`, which is an alias for `->{cap} T`.
468+
* Only trees of the form `=> T` are matched; trees written directly as `->{cap} T`
472469
* are ignored by the extractor.
473470
*/
474471
object ImpureByNameTypeTree:
475472

476-
def apply(tp: ByNameTypeTree)(using Context): untpd.CapturingTypeTree =
477-
untpd.CapturingTypeTree(
478-
untpd.captureRoot.withSpan(tp.span.startPos) :: Nil, tp)
473+
def apply(tp: Tree)(using Context): untpd.ByNameTypeTree =
474+
untpd.ByNameTypeTree(
475+
untpd.CapturesAndResult(
476+
untpd.captureRoot.withSpan(tp.span.startPos) :: Nil, tp))
479477

480-
def unapply(tp: Tree)(using Context): Option[ByNameTypeTree] = tp match
481-
case untpd.CapturingTypeTree(id @ Select(_, nme.CAPTURE_ROOT) :: Nil, bntp: ByNameTypeTree)
482-
if id.span == bntp.span.startPos => Some(bntp)
478+
def unapply(tp: Tree)(using Context): Option[Tree] = tp match
479+
case untpd.ByNameTypeTree(
480+
untpd.CapturesAndResult(id @ Select(_, nme.CAPTURE_ROOT) :: Nil, result))
481+
if id.span == result.span.startPos => Some(result)
483482
case _ => None
484483
end ImpureByNameTypeTree
485484
}
@@ -1026,33 +1025,19 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
10261025
case t => assert(t.span.exists, i"$t")
10271026
}
10281027

1029-
/** Extractors for quotes */
1030-
object Quoted {
1028+
object QuotedTypeOf {
10311029
/** Extracts the content of a quoted tree.
10321030
* The result can be the contents of a term or type quote, which
10331031
* will return a term or type tree respectively.
10341032
*/
10351033
def unapply(tree: tpd.Apply)(using Context): Option[tpd.Tree] =
1036-
if tree.symbol == defn.QuotedRuntime_exprQuote then
1037-
// quoted.runtime.Expr.quote[T](<body>)
1038-
Some(tree.args.head)
1039-
else if tree.symbol == defn.QuotedTypeModule_of then
1034+
if tree.symbol == defn.QuotedTypeModule_of then
10401035
// quoted.Type.of[<body>](quotes)
10411036
val TypeApply(_, body :: _) = tree.fun: @unchecked
10421037
Some(body)
10431038
else None
10441039
}
10451040

1046-
/** Extractors for splices */
1047-
object Spliced {
1048-
/** Extracts the content of a spliced expression tree.
1049-
* The result can be the contents of a term splice, which
1050-
* will return a term tree.
1051-
*/
1052-
def unapply(tree: tpd.Apply)(using Context): Option[tpd.Tree] =
1053-
if tree.symbol.isExprSplice then Some(tree.args.head) else None
1054-
}
1055-
10561041
/** Extractors for type splices */
10571042
object SplicedType {
10581043
/** Extracts the content of a spliced type tree.

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

+4-10
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,10 @@ class TreeMapWithImplicits extends tpd.TreeMapWithPreciseStatContexts {
3030

3131
private def patternScopeCtx(pattern: Tree)(using Context): Context = {
3232
val nestedCtx = ctx.fresh.setNewScope
33-
new TreeTraverser {
34-
def traverse(tree: Tree)(using Context): Unit = {
35-
tree match {
36-
case d: DefTree if d.symbol.isOneOf(GivenOrImplicitVal) =>
37-
nestedCtx.enter(d.symbol)
38-
case _ =>
39-
}
40-
traverseChildren(tree)
41-
}
42-
}.traverse(pattern)
33+
pattern.foreachSubTree {
34+
case d: DefTree if d.symbol.isOneOf(GivenOrImplicitVal) => nestedCtx.enter(d.symbol)
35+
case _ =>
36+
}
4337
nestedCtx
4438
}
4539

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

-5
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,6 @@ class TreeTypeMap(
146146
val bind1 = tmap.transformSub(bind)
147147
val expr1 = tmap.transform(expr)
148148
cpy.Labeled(labeled)(bind1, expr1)
149-
case tree @ Hole(_, _, args, content, tpt) =>
150-
val args1 = args.mapConserve(transform)
151-
val content1 = transform(content)
152-
val tpt1 = transform(tpt)
153-
cpy.Hole(tree)(args = args1, content = content1, tpt = tpt1)
154149
case tree1 =>
155150
super.transform(tree1)
156151
}

0 commit comments

Comments
 (0)