Skip to content

Commit bdd991c

Browse files
authored
Merge branch 'scala:main' into hr/trigger-cc-tests
2 parents 4ef2a6d + 300043e commit bdd991c

File tree

91 files changed

+539
-232
lines changed

Some content is hidden

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

91 files changed

+539
-232
lines changed

MAINTENANCE.md

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -63,39 +63,48 @@ At the end of their supervision period, the supervisor reports to the team durin
6363

6464
## Maintenance List
6565

66-
The following is the list of all the principal areas of the compiler and the core team members who are responsible for their maintenance:
66+
The following is the list of all the principal areas of the compiler and the internal team members who are responsible for their maintenance:
6767

6868
### Compiler
69-
- Parser: @odersky, @hamzaremmal
70-
- Typer: @odersky, @smarter, (@dwijnand), @noti0nal
69+
- Parser: @odersky, @hamzaremmal, @KacperFKorban
70+
- Typer: @odersky, @smarter, (@dwijnand), @noti0nal, @EugeneFlesselle, @KacperFKorban, @bracevac
7171
- Erasure: @smarter, @odersky
72-
- Enums: @bishabosha
73-
- Derivation & Mirrors: @bishabosha, (@dwijnand), @EugeneFlesselle
74-
- Export: @bishabosha, @odersky
75-
- Pattern Matching: @dwijnand, (@liufengyun), @sjrd
76-
- Inline: @nicolasstucki, @odersky, @hamzaremmal
77-
- Metaprogramming (Quotes, Reflect, Staging): @nicolasstucki, @jchyb, @hamzaremmal
78-
- Match types: @sjrd, @dwijnand, @Decel, @Linyxus
72+
- Enums:
73+
- Derivation & Mirrors: (@dwijnand), @EugeneFlesselle
74+
- Export: @odersky
75+
- Pattern Matching: @dwijnand, @sjrd, @noti0na1
76+
- Inline: @odersky, @jchyb, @hamzaremmal, @EugeneFlesselle
77+
- Metaprogramming (Quotes, Reflect, Staging): @jchyb, @hamzaremmal
78+
- Match types: @sjrd, @dwijnand, @Linyxus, @EugeneFlesselle
7979
- GADT: @dwijnand, @Linyxus
80-
- Initialization checker: @olhotak, @liufengyun
81-
- Safe nulls: @noti0na1, @olhotak
82-
- Transforms: @szymon-rd, @sjrd, @odersky, @smarter
83-
- tailrec: @sjrd, @mbovel
80+
- Initialization checker:
81+
- Transforms: @sjrd, @odersky, @smarter
82+
- Tailrec: @sjrd, @mbovel
8483
- JS backend: @sjrd
85-
- JVM backend: @sjrd
86-
- Java-compat: @smarter, @dwijnand
87-
- Capture checker: @odersky, @Linyxus
84+
- JVM backend: @sjrd, @hamzaremmal
85+
- Java-compat: @smarter, @dwijnand, @hamzaremmal
86+
- Extension Methods: @odersky, @dwijnand
87+
- Safe nulls (experimental): @noti0na1
88+
- Capture checker (experimental): @odersky, @Linyxus, @bracevac, @noti0na1
89+
- Modularity (experimental): @KacperFKorban
90+
- Named Tuples (experimental): @odersky
8891

8992
### Tooling
90-
- REPL: @dwijnand, @prolativ
93+
- REPL: @dwijnand
94+
- Runner/CLI: @Gedochao, (@tgodzik)
95+
- IDE: @tgodzik, (@kasiaMarek)
9196
- Scaladoc: @Florian3k
92-
- SemanticDB: @tanishiking
93-
- Coverage: @TheElectronWill
94-
- Linting (especially unused warnings) / Reporting UX: @szymon-rd
97+
- SemanticDB: @natsukagami, (@tanishiking)
98+
- Coverage: @KacperFKorban
99+
- Linting (especially unused warnings) / Reporting UX: @KacperFKorban
100+
- Presentation Compiler: @rochala, @tgodzik, @kasiaMarek, @natsukagami
101+
- Debug Adapter: @adpi2, (@tgodzik)
102+
- Scastie: @rochala
95103

96104
### Infrastructure
97-
- CI: @hamzaremmal
105+
- CI: @hamzaremmal, (@WojciechMazur)
98106
- Community Build: @hamzaremmal
99107
- Open Community Build: @WojciechMazur
100-
- Vulpix: @dwijnand, @prolativ
108+
- Vulpix: @dwijnand, @prolativ, @hamzaremmal
101109
- Benchmarks: @mbovel
110+
- Releases: @WojciechMazur, @prolativ

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,15 @@ trait TreeInfo[T <: Untyped] { self: Trees.Instance[T] =>
144144
def allTermArguments(tree: Tree): List[Tree] = unsplice(tree) match {
145145
case Apply(fn, args) => allTermArguments(fn) ::: args
146146
case TypeApply(fn, args) => allTermArguments(fn)
147-
case Block(_, expr) => allTermArguments(expr)
147+
case Block(Nil, expr) => allTermArguments(expr)
148148
case _ => Nil
149149
}
150150

151151
/** All type and term arguments of an application in a single flattened list */
152152
def allArguments(tree: Tree): List[Tree] = unsplice(tree) match {
153153
case Apply(fn, args) => allArguments(fn) ::: args
154154
case TypeApply(fn, args) => allArguments(fn) ::: args
155-
case Block(_, expr) => allArguments(expr)
155+
case Block(Nil, expr) => allArguments(expr)
156156
case _ => Nil
157157
}
158158

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -527,10 +527,13 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
527527
def makeCapsOf(tp: RefTree)(using Context): Tree =
528528
TypeApply(Select(scalaDot(nme.caps), nme.capsOf), tp :: Nil)
529529

530-
def makeCapsBound()(using Context): Tree =
531-
makeRetaining(
530+
// Capture set variable `[C^]` becomes: `[C >: CapSet <: CapSet^{cap}]`
531+
def makeCapsBound()(using Context): TypeBoundsTree =
532+
TypeBoundsTree(
532533
Select(scalaDot(nme.caps), tpnme.CapSet),
533-
Nil, tpnme.retainsCap)
534+
makeRetaining(
535+
Select(scalaDot(nme.caps), tpnme.CapSet),
536+
Nil, tpnme.retainsCap))
534537

535538
def makeConstructor(tparams: List[TypeDef], vparamss: List[List[ValDef]], rhs: Tree = EmptyTree)(using Context): DefDef =
536539
DefDef(nme.CONSTRUCTOR, joinParams(tparams, vparamss), TypeTree(), rhs)

compiler/src/dotty/tools/dotc/cc/CaptureAnnotation.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ case class CaptureAnnotation(refs: CaptureSet, boxed: Boolean)(cls: Symbol) exte
4444
case cr: TermRef => ref(cr)
4545
case cr: TermParamRef => untpd.Ident(cr.paramName).withType(cr)
4646
case cr: ThisType => This(cr.cls)
47+
// TODO: Will crash if the type is an annotated type, for example `cap?`
4748
}
4849
val arg = repeated(elems, TypeTree(defn.AnyType))
4950
New(symbol.typeRef, arg :: Nil)

compiler/src/dotty/tools/dotc/cc/CaptureRef.scala

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,19 @@ trait CaptureRef extends TypeProxy, ValueType:
9393
final def invalidateCaches() =
9494
myCaptureSetRunId = NoRunId
9595

96-
/** x subsumes x
97-
* this subsumes this.f
96+
/** x subsumes x
97+
* x =:= y ==> x subsumes y
98+
* x subsumes y ==> x subsumes y.f
9899
* x subsumes y ==> x* subsumes y, x subsumes y?
99100
* x subsumes y ==> x* subsumes y*, x? subsumes y?
100101
* x: x1.type /\ x1 subsumes y ==> x subsumes y
101-
* TODO: Document path cases
102+
* X = CapSet^cx, exists rx in cx, rx subsumes y ==> X subsumes y
103+
* Y = CapSet^cy, forall ry in cy, x subsumes ry ==> x subsumes Y
104+
* X: CapSet^c1...CapSet^c2, (CapSet^c1) subsumes y ==> X subsumes y
105+
* Y: CapSet^c1...CapSet^c2, x subsumes (CapSet^c2) ==> x subsumes Y
106+
* Contains[X, y] ==> X subsumes y
107+
*
108+
* TODO: Document cases with more comments.
102109
*/
103110
final def subsumes(y: CaptureRef)(using Context): Boolean =
104111

@@ -135,14 +142,29 @@ trait CaptureRef extends TypeProxy, ValueType:
135142
case _ => false
136143
|| viaInfo(y.info)(subsumingRefs(this, _))
137144
case MaybeCapability(y1) => this.stripMaybe.subsumes(y1)
145+
case y: TypeRef if y.derivesFrom(defn.Caps_CapSet) =>
146+
// The upper and lower bounds don't have to be in the form of `CapSet^{...}`.
147+
// They can be other capture set variables, which are bounded by `CapSet`,
148+
// like `def test[X^, Y^, Z >: X <: Y]`.
149+
y.info match
150+
case TypeBounds(_, hi: CaptureRef) => this.subsumes(hi)
151+
case _ => y.captureSetOfInfo.elems.forall(this.subsumes)
152+
case CapturingType(parent, refs) if parent.derivesFrom(defn.Caps_CapSet) =>
153+
refs.elems.forall(this.subsumes)
138154
case _ => false
139155
|| this.match
140156
case ReachCapability(x1) => x1.subsumes(y.stripReach)
141157
case x: TermRef => viaInfo(x.info)(subsumingRefs(_, y))
142158
case x: TermParamRef => subsumesExistentially(x, y)
143-
case x: TypeRef if x.symbol.info.derivesFrom(defn.Caps_CapSet) =>
144-
x.captureSetOfInfo.elems.exists(_.subsumes(y))
145-
case x: TypeRef => assumedContainsOf(x).contains(y)
159+
case x: TypeRef if assumedContainsOf(x).contains(y) => true
160+
case x: TypeRef if x.derivesFrom(defn.Caps_CapSet) =>
161+
x.info match
162+
case TypeBounds(lo: CaptureRef, _) =>
163+
lo.subsumes(y)
164+
case _ =>
165+
x.captureSetOfInfo.elems.exists(_.subsumes(y))
166+
case CapturingType(parent, refs) if parent.derivesFrom(defn.Caps_CapSet) =>
167+
refs.elems.exists(_.subsumes(y))
146168
case _ => false
147169
end subsumes
148170

compiler/src/dotty/tools/dotc/cc/CaptureSet.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,9 @@ sealed abstract class CaptureSet extends Showable:
161161
def debugInfo(using Context) = i"$this accountsFor $x, which has capture set ${x.captureSetOfInfo}"
162162
def test(using Context) = reporting.trace(debugInfo):
163163
elems.exists(_.subsumes(x))
164-
|| !x.isMaxCapability && x.captureSetOfInfo.subCaptures(this, frozen = true).isOK
164+
|| !x.isMaxCapability
165+
&& !x.derivesFrom(defn.Caps_CapSet)
166+
&& x.captureSetOfInfo.subCaptures(this, frozen = true).isOK
165167
comparer match
166168
case comparer: ExplainingTypeComparer => comparer.traceIndented(debugInfo)(test)
167169
case _ => test

compiler/src/dotty/tools/dotc/cc/Setup.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,9 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
866866
if others.accountsFor(ref) then
867867
report.warning(em"redundant capture: $dom already accounts for $ref", pos)
868868

869-
if ref.captureSetOfInfo.elems.isEmpty && !ref.derivesFrom(defn.Caps_Capability) then
869+
if ref.captureSetOfInfo.elems.isEmpty
870+
&& !ref.derivesFrom(defn.Caps_Capability)
871+
&& !ref.derivesFrom(defn.Caps_CapSet) then
870872
val deepStr = if ref.isReach then " deep" else ""
871873
report.error(em"$ref cannot be tracked since its$deepStr capture set is empty", pos)
872874
check(parent.captureSet, parent)

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ object Feature:
3434
val pureFunctions = experimental("pureFunctions")
3535
val captureChecking = experimental("captureChecking")
3636
val into = experimental("into")
37+
val namedTuples = experimental("namedTuples")
3738
val modularity = experimental("modularity")
3839
val betterMatchTypeExtractors = experimental("betterMatchTypeExtractors")
3940
val quotedPatternsWithPolymorphicFunctions = experimental("quotedPatternsWithPolymorphicFunctions")
@@ -65,6 +66,7 @@ object Feature:
6566
(pureFunctions, "Enable pure functions for capture checking"),
6667
(captureChecking, "Enable experimental capture checking"),
6768
(into, "Allow into modifier on parameter types"),
69+
(namedTuples, "Allow named tuples"),
6870
(modularity, "Enable experimental modularity features"),
6971
(betterMatchTypeExtractors, "Enable better match type extractors"),
7072
(betterFors, "Enable improvements in `for` comprehensions")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ enum MigrationVersion(val warnFrom: SourceVersion, val errorFrom: SourceVersion)
2626
case WithOperator extends MigrationVersion(`3.4`, future)
2727
case FunctionUnderscore extends MigrationVersion(`3.4`, future)
2828
case NonNamedArgumentInJavaAnnotation extends MigrationVersion(`3.6`, `3.6`)
29-
case AmbiguousNamedTupleInfixApply extends MigrationVersion(`3.6`, never)
29+
case AmbiguousNamedTupleSyntax extends MigrationVersion(`3.6`, future)
3030
case ImportWildcard extends MigrationVersion(future, future)
3131
case ImportRename extends MigrationVersion(future, future)
3232
case ParameterEnclosedByParenthesis extends MigrationVersion(future, future)

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,15 @@ class TypeUtils:
145145
case defn.NamedTuple(_, _) => true
146146
case _ => false
147147

148+
def derivesFromNamedTuple(using Context): Boolean = self match
149+
case defn.NamedTuple(_, _) => true
150+
case tp: MatchType =>
151+
tp.bound.derivesFromNamedTuple || tp.reduced.derivesFromNamedTuple
152+
case tp: TypeProxy => tp.superType.derivesFromNamedTuple
153+
case tp: AndType => tp.tp1.derivesFromNamedTuple || tp.tp2.derivesFromNamedTuple
154+
case tp: OrType => tp.tp1.derivesFromNamedTuple && tp.tp2.derivesFromNamedTuple
155+
case _ => false
156+
148157
/** Drop all named elements in tuple type */
149158
def stripNamedTuple(using Context): Type = self.normalized.dealias match
150159
case defn.NamedTuple(_, vals) =>

0 commit comments

Comments
 (0)