Skip to content

Commit 10c9af0

Browse files
committed
Merge branch 'main' into implement/Xlint/shadow_warnings
2 parents 07f6581 + 6087911 commit 10c9af0

File tree

323 files changed

+11154
-4595
lines changed

Some content is hidden

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

323 files changed

+11154
-4595
lines changed

.github/ISSUE_TEMPLATE/feature.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
name: "\U0001F389 Suggest a feature"
3-
about: Please create a feature request here https://github.com/lampepfl/dotty-feature-requests
3+
about: Please create a feature request here https://github.com/lampepfl/dotty/discussions/new?category=feature-requests
44
title: ''
55
labels: ''
66
assignees: ''
77

88
---
99

10-
Please create a feature request here: [lampepfl/dotty-feature-requests](https://github.com/lampepfl/dotty-feature-requests).
10+
Please create a feature request in the [Dotty Discussions](https://github.com/lampepfl/dotty/discussions/new?category=feature-requests).

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,7 @@ contributors.js
9595
content-contributors.css
9696
docs/_spec/_site/
9797
docs/_spec/.jekyll-metadata
98+
99+
# scaladoc related
100+
scaladoc/output/
101+

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
url = https://github.com/dotty-staging/fastparse
2222
[submodule "community-build/community-projects/stdLib213"]
2323
path = community-build/community-projects/stdLib213
24-
url = https://github.com/dotty-staging/scala
24+
url = https://github.com/dotty-staging/scala213
2525
[submodule "community-build/community-projects/sourcecode"]
2626
path = community-build/community-projects/sourcecode
2727
url = https://github.com/dotty-staging/sourcecode

.vscode-template/settings.json

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

MAINTENANCE.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ The issue supervisor is responsible for:
1616
- Attempting to reproduce the issue (or label “stat:cannot reproduce”)
1717
- Further minimizing the issue or asking the reporter of the issue to minimize it correctly (or label “stat:needs minimization”)
1818
- Identifying which issues are of considerable importance and bringing them to the attention of the team during the Dotty meeting, where they can be filtered and added to the [Future Versions](https://github.com/lampepfl/dotty/milestone/46) milestone.
19+
- Identifying if a report is really a feature request and if so, converting it to
20+
a [feature request discussion](https://github.com/lampepfl/dotty/discussions/categories/feature-requests).
21+
- Keeping an eye on new
22+
[discussions](https://github.com/lampepfl/dotty/discussions), making sure they
23+
don't go unanswered and also correctly labeling new feature requests.
1924

2025
Other core teammates are responsible for providing information to the issue supervisor in a timely manner when it is requested if they have that information.
2126

@@ -32,7 +37,6 @@ The issue supervisor schedule is maintained in the [Issue Supervisor Statistics
3237
An issue supervisor needs to have all the accesses and privileges required to get their job done. This might include:
3338

3439
- Admin rights in lampepfl/dotty repository
35-
- Admin rights in lampepfl/dotty-feature-requests repository
3640
- Permission to create new repositories in lampepfl organization (needed to fork repositories for the community build)
3741
- Access to the LAMP slack to be able to ask for help with the infrastructure, triaging and such
3842

community-build/README.md

Lines changed: 3 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,5 @@
11
# Scala 3 Community Build
22

3-
This project contains tests to build and test a corpus of open sources Scala
4-
projects against the latest version of Scala 3.
5-
6-
## Running it locally
7-
8-
To run the community build on a local machine, first fetch all the git
9-
submodules with `git submodule update --init` and run `sbt community-build/test`
10-
from the root of the dotty repo.
11-
12-
To run a single project, you can use the usual syntax for running a single JUnit
13-
test, for example `community-build/testOnly -- *shapeless`
14-
15-
In CI the community build is split up into 3 seperate groups: A, B, and C. To
16-
run one specific build you can also use the same JUnit syntax as above targeting
17-
the individual group. For example:
18-
19-
```
20-
sbt "community-build/testOnly dotty.communitybuild.CommunityBuildTestA"
21-
```
22-
23-
## Adding your project
24-
25-
The community build is able to handle both Mill and sbt projects. To add your
26-
project to the community build you can follow these steps:
27-
28-
1. Ensure your project is compiling with Scala 3. If you need help make sure to
29-
check out the [Scala 3 Migration
30-
Guide](https://docs.scala-lang.org/scala3/guides/migration/compatibility-intro.html).
31-
You can see the submodules in
32-
[community-projects](https://github.com/lampepfl/dotty/tree/main/community-build/community-projects/)
33-
for examples of projects that compile with Scala 3.
34-
35-
2. Open a PR against this repo that:
36-
- Adds your project as a new git submodule
37-
- `git submodule add https://github.com/dotty-staging/XYZ.git community-build/community-projects/XYZ`
38-
- Add the project to [projects.scala](https://github.com/lampepfl/dotty/blob/main/community-build/src/scala/dotty/communitybuild/projects.scala)
39-
- Adds a test in [CommunityBuildTest.scala](https://github.com/lampepfl/dotty/blob/main/community-build/test/scala/dotty/communitybuild/CommunityBuildTest.scala)
40-
41-
3. Once the CI is green, someone from the Dotty team will fork your repo and add
42-
it to [dotty-staging](https://github.com/dotty-staging). This enables us to
43-
make changes to your fork if necessary to keep the community build running
44-
smoothly.
45-
46-
4. Once the fork is created, please update your PR to point to this new fork
47-
instead of your repo.
48-
49-
## Updating a project
50-
51-
The projects included in the community build are all forked and located in
52-
[dotty-staging](https://github.com/dotty-staging). When something needs to be
53-
bumped the process is as follows:
54-
55-
1. Fork the dotty staging repo and sync it with the upstream project.
56-
57-
2. Once you've verified that the tests are all passing you can then either
58-
request in your PR that the dotty-staging fork be synced or in the
59-
[scala-contributors](https://discord.com/channels/632150470000902164/632628489719382036)
60-
discord channel.
61-
62-
### Some helpful tips
63-
64-
- If you're unfamiliar with Git Submodules you can find a nice guide to get
65-
familiar with them [here](https://git-scm.com/book/en/v2/Git-Tools-Submodules).
66-
- Keep in mind that many projects are interrelated. So when you bump one that
67-
change may cascade through multiple different projects causing you to have
68-
to bump multiple. Plan accordingly and at times it's best to pin it to a
69-
stable release version, especially if it's a root library that many others
70-
in the community build are relying on.
71-
72-
## Looking for the "unmanaged" Scala 3 community build?
73-
74-
You can find this [here](https://github.com/VirtusLab/community-build3).
75-
3+
For information on the community build check out the [Community Build section of
4+
the Contributing
5+
Docs](https://dotty.epfl.ch/docs/contributing/community-build.html).
Submodule specs2 updated 44 files
Submodule stdLib213 updated 653 files

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,12 +811,13 @@ object desugar {
811811
// TODO: drop this once we do not silently insert empty class parameters anymore
812812
case paramss => paramss
813813
}
814+
val finalFlag = if ctx.settings.Yscala2Stdlib.value then EmptyFlags else Final
814815
// implicit wrapper is typechecked in same scope as constructor, so
815816
// we can reuse the constructor parameters; no derived params are needed.
816817
DefDef(
817818
className.toTermName, joinParams(constrTparams, defParamss),
818819
classTypeRef, creatorExpr)
819-
.withMods(companionMods | mods.flags.toTermFlags & (GivenOrImplicit | Inline) | Final)
820+
.withMods(companionMods | mods.flags.toTermFlags & (GivenOrImplicit | Inline) | finalFlag)
820821
.withSpan(cdef.span) :: Nil
821822
}
822823

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,9 @@ trait TreeInfo[T <: Untyped] { self: Trees.Instance[T] =>
330330
case _ => p(tree)
331331
}
332332

333+
/** The tree stripped of the possibly nested applications (term and type).
334+
* The original tree if it's not an application.
335+
*/
333336
def appliedCore(tree: Tree): Tree = tree match {
334337
case Apply(fn, _) => appliedCore(fn)
335338
case TypeApply(fn, _) => appliedCore(fn)

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

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,21 @@ object Feature:
136136
if !isExperimentalEnabled then
137137
report.error(em"Experimental $which may only be used with a nightly or snapshot version of the compiler$note", srcPos)
138138

139+
private def ccException(sym: Symbol)(using Context): Boolean =
140+
ccEnabled && defn.ccExperimental.contains(sym)
141+
139142
def checkExperimentalDef(sym: Symbol, srcPos: SrcPos)(using Context) =
140143
if !isExperimentalEnabled then
141-
val symMsg =
142-
if sym.hasAnnotation(defn.ExperimentalAnnot) then
143-
i"$sym is marked @experimental"
144-
else if sym.owner.hasAnnotation(defn.ExperimentalAnnot) then
145-
i"${sym.owner} is marked @experimental"
146-
else
147-
i"$sym inherits @experimental"
148-
report.error(em"$symMsg and therefore may only be used in an experimental scope.", srcPos)
144+
val experimentalSym =
145+
if sym.hasAnnotation(defn.ExperimentalAnnot) then sym
146+
else if sym.owner.hasAnnotation(defn.ExperimentalAnnot) then sym.owner
147+
else NoSymbol
148+
if !ccException(experimentalSym) then
149+
val symMsg =
150+
if experimentalSym.exists
151+
then i"$experimentalSym is marked @experimental"
152+
else i"$sym inherits @experimental"
153+
report.error(em"$symMsg and therefore may only be used in an experimental scope.", srcPos)
149154

150155
/** Check that experimental compiler options are only set for snapshot or nightly compiler versions. */
151156
def checkExperimentalSettings(using Context): Unit =

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ private sealed trait YSettings:
402402
val YnoKindPolymorphism: Setting[Boolean] = BooleanSetting("-Yno-kind-polymorphism", "Disable kind polymorphism.")
403403
val YexplicitNulls: Setting[Boolean] = BooleanSetting("-Yexplicit-nulls", "Make reference types non-nullable. Nullable types can be expressed with unions: e.g. String|Null.")
404404
val YcheckInit: Setting[Boolean] = BooleanSetting("-Ysafe-init", "Ensure safe initialization of objects")
405+
val YcheckInitGlobal: Setting[Boolean] = BooleanSetting("-Ysafe-init-global", "Check safe initialization of global objects")
405406
val YrequireTargetName: Setting[Boolean] = BooleanSetting("-Yrequire-targetName", "Warn if an operator is defined without a @targetName annotation")
406407
val YrecheckTest: Setting[Boolean] = BooleanSetting("-Yrecheck-test", "Run basic rechecking (internal test only)")
407408
val YccDebug: Setting[Boolean] = BooleanSetting("-Ycc-debug", "Used in conjunction with captureChecking language import, debug info for captured references")
@@ -419,4 +420,3 @@ private sealed trait YSettings:
419420

420421
val YforceInlineWhileTyping: Setting[Boolean] = BooleanSetting("-Yforce-inline-while-typing", "Make non-transparent inline methods inline when typing. Emulates the old inlining behavior of 3.0.0-M3.")
421422
end YSettings
422-

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ trait ConstraintHandling {
6464
*/
6565
protected var canWidenAbstract: Boolean = true
6666

67+
/**
68+
* Used for match type reduction.
69+
* When an abstract type may not be widened, according to `widenAbstractOKFor`,
70+
* we record it in this set, so that we can ultimately fail the reduction, but
71+
* with all the information that comes out from continuing to widen the abstract type.
72+
*/
73+
protected var poisoned: Set[TypeParamRef] = Set.empty
74+
6775
protected var myNecessaryConstraintsOnly = false
6876
/** When collecting the constraints needed for a particular subtyping
6977
* judgment to be true, we sometimes need to approximate the constraint

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

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,8 @@ class Definitions {
976976
@tu lazy val Caps_unsafeBoxFunArg: Symbol = CapsUnsafeModule.requiredMethod("unsafeBoxFunArg")
977977
@tu lazy val Caps_SealedAnnot: ClassSymbol = requiredClass("scala.caps.Sealed")
978978

979+
@tu lazy val PureClass: Symbol = requiredClass("scala.Pure")
980+
979981
// Annotation base classes
980982
@tu lazy val AnnotationClass: ClassSymbol = requiredClass("scala.annotation.Annotation")
981983
@tu lazy val StaticAnnotationClass: ClassSymbol = requiredClass("scala.annotation.StaticAnnotation")
@@ -1045,6 +1047,11 @@ class Definitions {
10451047

10461048
@tu lazy val JavaRepeatableAnnot: ClassSymbol = requiredClass("java.lang.annotation.Repeatable")
10471049

1050+
// Initialization annotations
1051+
@tu lazy val InitModule: Symbol = requiredModule("scala.annotation.init")
1052+
@tu lazy val InitWidenAnnot: ClassSymbol = InitModule.requiredClass("widen")
1053+
@tu lazy val InitRegionMethod: Symbol = InitModule.requiredMethod("region")
1054+
10481055
// A list of meta-annotations that are relevant for fields and accessors
10491056
@tu lazy val NonBeanMetaAnnots: Set[Symbol] =
10501057
Set(FieldMetaAnnot, GetterMetaAnnot, ParamMetaAnnot, SetterMetaAnnot, CompanionClassMetaAnnot, CompanionMethodMetaAnnot)
@@ -1944,6 +1951,14 @@ class Definitions {
19441951
case Some(pkgs) => pkgs.contains(sym.owner)
19451952
case none => false
19461953

1954+
/** Experimental definitions that can nevertheless be accessed from a stable
1955+
* compiler if capture checking is enabled.
1956+
*/
1957+
@tu lazy val ccExperimental: Set[Symbol] = Set(
1958+
CapsModule, CapsModule.moduleClass, PureClass,
1959+
CapabilityAnnot, RequiresCapabilityAnnot,
1960+
RetainsAnnot, RetainsByNameAnnot, WithPureFunsAnnot)
1961+
19471962
// ----- primitive value class machinery ------------------------------------------
19481963

19491964
class PerRun[T](generate: Context ?=> T) {
@@ -2041,15 +2056,17 @@ class Definitions {
20412056
def isValueSubClass(sym1: Symbol, sym2: Symbol): Boolean =
20422057
valueTypeEnc(sym2.asClass.name) % valueTypeEnc(sym1.asClass.name) == 0
20432058

2044-
@tu lazy val specialErasure: SimpleIdentityMap[Symbol, ClassSymbol] =
2045-
SimpleIdentityMap.empty[Symbol]
2046-
.updated(AnyClass, ObjectClass)
2047-
.updated(MatchableClass, ObjectClass)
2048-
.updated(AnyValClass, ObjectClass)
2049-
.updated(SingletonClass, ObjectClass)
2050-
.updated(TupleClass, ProductClass)
2051-
.updated(NonEmptyTupleClass, ProductClass)
2052-
.updated(PairClass, ObjectClass)
2059+
@tu lazy val specialErasure: collection.Map[Symbol, ClassSymbol] =
2060+
val m = mutable.Map[Symbol, ClassSymbol]()
2061+
m(AnyClass) = ObjectClass
2062+
m(MatchableClass) = ObjectClass
2063+
m(PureClass) = ObjectClass
2064+
m(AnyValClass) = ObjectClass
2065+
m(SingletonClass) = ObjectClass
2066+
m(TupleClass) = ProductClass
2067+
m(NonEmptyTupleClass) = ProductClass
2068+
m(PairClass) = ObjectClass
2069+
m
20532070

20542071
// ----- Initialization ---------------------------------------------------
20552072

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ object Symbols {
8383
ctx.settings.YretainTrees.value ||
8484
denot.owner.isTerm || // no risk of leaking memory after a run for these
8585
denot.isOneOf(InlineOrProxy) || // need to keep inline info
86-
ctx.settings.YcheckInit.value // initialization check
86+
ctx.settings.YcheckInit.value || // initialization check
87+
ctx.settings.YcheckInitGlobal.value
8788

8889
/** The last denotation of this symbol */
8990
private var lastDenot: SymDenotation = _

0 commit comments

Comments
 (0)