Skip to content

Commit 51ddf73

Browse files
authored
Merge branch 'release/5.5' into actor-class-descriptor-metadata-5.5
2 parents d7df3d3 + 30e75d8 commit 51ddf73

Some content is hidden

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

47 files changed

+422
-284
lines changed

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,25 @@ CHANGELOG
2929
Swift 5.5
3030
---------
3131

32+
* [SE-0306][]:
33+
34+
Swift 5.5 includes support for actors, a new kind of type that isolates its instance data to protect it from concurrent access. Accesses to an actor's instance declarations from outside the must be asynchronous:
35+
36+
```swift
37+
actor Counter {
38+
var value = 0
39+
40+
func increment() {
41+
value = value + 1
42+
}
43+
}
44+
45+
func useCounter(counter: Counter) async {
46+
print(await counter.value) // interaction must be async
47+
await counter.increment() // interaction must be async
48+
}
49+
```
50+
3251
* The determination of whether a call to a `rethrows` function can throw now considers default arguments of `Optional` type.
3352

3453
In Swift 5.4, such default arguments were ignored entirely by `rethrows` checking. This meant that the following example was accepted:
@@ -8434,6 +8453,7 @@ Swift 1.0
84348453
[SE-0297]: <https://github.com/apple/swift-evolution/blob/main/proposals/0297-concurrency-objc.md>
84358454
[SE-0298]: <https://github.com/apple/swift-evolution/blob/main/proposals/0298-asyncsequence.md>
84368455
[SE-0299]: <https://github.com/apple/swift-evolution/blob/main/proposals/0299-extend-generic-static-member-lookup.md>
8456+
[SE-0306]: <https://github.com/apple/swift-evolution/blob/main/proposals/0306-actors.md>
84378457

84388458
[SR-75]: <https://bugs.swift.org/browse/SR-75>
84398459
[SR-106]: <https://bugs.swift.org/browse/SR-106>

include/swift/ABI/MetadataValues.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2009,6 +2009,7 @@ class JobFlags : public FlagSet<size_t> {
20092009
Task_IsChildTask = 24,
20102010
Task_IsFuture = 25,
20112011
Task_IsGroupChildTask = 26,
2012+
Task_IsContinuingAsyncTask = 27,
20122013
};
20132014

20142015
explicit JobFlags(size_t bits) : FlagSet(bits) {}
@@ -2038,6 +2039,9 @@ class JobFlags : public FlagSet<size_t> {
20382039
FLAGSET_DEFINE_FLAG_ACCESSORS(Task_IsGroupChildTask,
20392040
task_isGroupChildTask,
20402041
task_setIsGroupChildTask)
2042+
FLAGSET_DEFINE_FLAG_ACCESSORS(Task_IsContinuingAsyncTask,
2043+
task_isContinuingAsyncTask,
2044+
task_setIsContinuingAsyncTask)
20412045
};
20422046

20432047
/// Kinds of task status record.

include/swift/AST/Attr.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ SIMPLE_DECL_ATTR(reasync, AtReasync,
625625
110)
626626

627627
DECL_ATTR(completionHandlerAsync, CompletionHandlerAsync,
628-
OnAbstractFunction | ConcurrencyOnly | LongAttribute | UserInaccessible |
628+
OnAbstractFunction | ConcurrencyOnly | LongAttribute |
629629
ABIStableToAdd | ABIStableToRemove |
630630
APIStableToAdd | APIStableToRemove,
631631
111)

include/swift/AST/Attr.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2077,9 +2077,10 @@ class CompletionHandlerAsyncAttr final : public DeclAttribute {
20772077
CompletionHandlerAsyncAttr(AbstractFunctionDecl &asyncFunctionDecl,
20782078
size_t completionHandlerIndex,
20792079
SourceLoc completionHandlerIndexLoc,
2080-
SourceLoc atLoc, SourceRange range)
2080+
SourceLoc atLoc, SourceRange range,
2081+
bool implicit)
20812082
: DeclAttribute(DAK_CompletionHandlerAsync, atLoc, range,
2082-
/*implicit*/ false),
2083+
implicit),
20832084
AsyncFunctionDecl(&asyncFunctionDecl) ,
20842085
CompletionHandlerIndex(completionHandlerIndex),
20852086
CompletionHandlerIndexLoc(completionHandlerIndexLoc) {}

include/swift/AST/DiagnosticsSema.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4351,8 +4351,8 @@ NOTE(objc_ambiguous_async_convention_candidate,none,
43514351
ERROR(async_objc_dynamic_self,none,
43524352
"asynchronous method returning 'Self' cannot be '@objc'", ())
43534353

4354-
ERROR(actor_with_nonactor_superclass,none,
4355-
"actor cannot inherit from non-actor class %0", (DeclName))
4354+
ERROR(actor_inheritance,none,
4355+
"actor types do not support inheritance", ())
43564356

43574357
ERROR(actor_isolated_non_self_reference,none,
43584358
"actor-isolated %0 %1 can only be %select{referenced|mutated|used 'inout'}3 "

include/swift/Basic/Features.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
LANGUAGE_FEATURE(StaticAssert, 0, "#assert", langOpts.EnableExperimentalStaticAssert)
3838
LANGUAGE_FEATURE(AsyncAwait, 296, "async/await", true)
3939
LANGUAGE_FEATURE(MarkerProtocol, 0, "@_marker protocol", true)
40-
LANGUAGE_FEATURE(Actors, 0, "actors", langOpts.EnableExperimentalConcurrency)
40+
LANGUAGE_FEATURE(Actors, 0, "actors", true)
4141
LANGUAGE_FEATURE(ConcurrentFunctions, 0, "@concurrent functions", true)
4242
LANGUAGE_FEATURE(RethrowsProtocol, 0, "@rethrows protocol", true)
4343
LANGUAGE_FEATURE(GlobalActors, 0, "Global actors", langOpts.EnableExperimentalConcurrency)

include/swift/IDE/CodeCompletion.h

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,7 @@ class CodeCompletionResult {
613613
unsigned AssociatedKind : 8;
614614
unsigned KnownOperatorKind : 6;
615615
unsigned SemanticContext : 3;
616+
unsigned IsArgumentLabels : 1;
616617
unsigned NotRecommended : 4;
617618
unsigned IsSystem : 1;
618619

@@ -637,14 +638,15 @@ class CodeCompletionResult {
637638
///
638639
/// \note The caller must ensure \c CodeCompletionString outlives this result.
639640
CodeCompletionResult(ResultKind Kind, SemanticContextKind SemanticContext,
640-
unsigned NumBytesToErase,
641+
bool IsArgumentLabels, unsigned NumBytesToErase,
641642
CodeCompletionString *CompletionString,
642643
ExpectedTypeRelation TypeDistance,
643644
CodeCompletionOperatorKind KnownOperatorKind =
644645
CodeCompletionOperatorKind::None,
645646
StringRef BriefDocComment = StringRef())
646647
: Kind(Kind), KnownOperatorKind(unsigned(KnownOperatorKind)),
647648
SemanticContext(unsigned(SemanticContext)),
649+
IsArgumentLabels(unsigned(IsArgumentLabels)),
648650
NotRecommended(unsigned(NotRecommendedReason::None)),
649651
NumBytesToErase(NumBytesToErase), CompletionString(CompletionString),
650652
BriefDocComment(BriefDocComment), TypeDistance(TypeDistance) {
@@ -664,12 +666,13 @@ class CodeCompletionResult {
664666
/// \note The caller must ensure \c CodeCompletionString outlives this result.
665667
CodeCompletionResult(CodeCompletionKeywordKind Kind,
666668
SemanticContextKind SemanticContext,
667-
unsigned NumBytesToErase,
669+
bool IsArgumentLabels, unsigned NumBytesToErase,
668670
CodeCompletionString *CompletionString,
669671
ExpectedTypeRelation TypeDistance,
670672
StringRef BriefDocComment = StringRef())
671673
: Kind(Keyword), KnownOperatorKind(0),
672674
SemanticContext(unsigned(SemanticContext)),
675+
IsArgumentLabels(unsigned(IsArgumentLabels)),
673676
NotRecommended(unsigned(NotRecommendedReason::None)),
674677
NumBytesToErase(NumBytesToErase), CompletionString(CompletionString),
675678
BriefDocComment(BriefDocComment), TypeDistance(TypeDistance) {
@@ -683,11 +686,12 @@ class CodeCompletionResult {
683686
/// \note The caller must ensure \c CodeCompletionString outlives this result.
684687
CodeCompletionResult(CodeCompletionLiteralKind LiteralKind,
685688
SemanticContextKind SemanticContext,
686-
unsigned NumBytesToErase,
689+
bool IsArgumentLabels, unsigned NumBytesToErase,
687690
CodeCompletionString *CompletionString,
688691
ExpectedTypeRelation TypeDistance)
689692
: Kind(Literal), KnownOperatorKind(0),
690693
SemanticContext(unsigned(SemanticContext)),
694+
IsArgumentLabels(unsigned(IsArgumentLabels)),
691695
NotRecommended(unsigned(NotRecommendedReason::None)),
692696
NumBytesToErase(NumBytesToErase), CompletionString(CompletionString),
693697
TypeDistance(TypeDistance) {
@@ -702,7 +706,7 @@ class CodeCompletionResult {
702706
/// arguments outlive this result, typically by storing them in the same
703707
/// \c CodeCompletionResultSink as the result itself.
704708
CodeCompletionResult(SemanticContextKind SemanticContext,
705-
unsigned NumBytesToErase,
709+
bool IsArgumentLabels, unsigned NumBytesToErase,
706710
CodeCompletionString *CompletionString,
707711
const Decl *AssociatedDecl, StringRef ModuleName,
708712
CodeCompletionResult::NotRecommendedReason NotRecReason,
@@ -712,6 +716,7 @@ class CodeCompletionResult {
712716
enum ExpectedTypeRelation TypeDistance)
713717
: Kind(ResultKind::Declaration), KnownOperatorKind(0),
714718
SemanticContext(unsigned(SemanticContext)),
719+
IsArgumentLabels(unsigned(IsArgumentLabels)),
715720
NotRecommended(unsigned(NotRecReason)),
716721
NumBytesToErase(NumBytesToErase), CompletionString(CompletionString),
717722
ModuleName(ModuleName), BriefDocComment(BriefDocComment),
@@ -728,9 +733,9 @@ class CodeCompletionResult {
728733
getOperatorKind() != CodeCompletionOperatorKind::None);
729734
}
730735

731-
// FIXME:
736+
// Used by deserialization.
732737
CodeCompletionResult(SemanticContextKind SemanticContext,
733-
unsigned NumBytesToErase,
738+
bool IsArgumentLabels, unsigned NumBytesToErase,
734739
CodeCompletionString *CompletionString,
735740
CodeCompletionDeclKind DeclKind, bool IsSystem,
736741
StringRef ModuleName,
@@ -743,6 +748,7 @@ class CodeCompletionResult {
743748
: Kind(ResultKind::Declaration),
744749
KnownOperatorKind(unsigned(KnownOperatorKind)),
745750
SemanticContext(unsigned(SemanticContext)),
751+
IsArgumentLabels(unsigned(IsArgumentLabels)),
746752
NotRecommended(unsigned(NotRecReason)), IsSystem(IsSystem),
747753
NumBytesToErase(NumBytesToErase), CompletionString(CompletionString),
748754
ModuleName(ModuleName), BriefDocComment(BriefDocComment),
@@ -805,6 +811,10 @@ class CodeCompletionResult {
805811
return static_cast<SemanticContextKind>(SemanticContext);
806812
}
807813

814+
bool isArgumentLabels() const {
815+
return static_cast<bool>(IsArgumentLabels);
816+
}
817+
808818
bool isNotRecommended() const {
809819
return getNotRecommendedReason() != NotRecommendedReason::None;
810820
}

lib/AST/Attr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1090,7 +1090,7 @@ bool DeclAttribute::printImpl(ASTPrinter &Printer, const PrintOptions &Options,
10901090
} else {
10911091
Printer << attr->AsyncFunctionName;
10921092
}
1093-
Printer << "\", completionHandleIndex: " <<
1093+
Printer << "\", completionHandlerIndex: " <<
10941094
attr->CompletionHandlerIndex << ')';
10951095
break;
10961096
}

lib/ClangImporter/ImportDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8104,7 +8104,7 @@ void addCompletionHandlerAttribute(Decl *asyncImport,
81048104
member->getAttrs().add(
81058105
new (SwiftContext) CompletionHandlerAsyncAttr(
81068106
cast<AbstractFunctionDecl>(*asyncImport), completionIndex,
8107-
SourceLoc(), SourceLoc(), SourceRange()));
8107+
SourceLoc(), SourceLoc(), SourceRange(), /*implicit*/ true));
81088108
}
81098109
}
81108110
}

lib/IDE/CodeCompletion.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,31 +1294,31 @@ CodeCompletionResult *CodeCompletionResultBuilder::takeResult() {
12941294
}
12951295

12961296
return new (*Sink.Allocator) CodeCompletionResult(
1297-
SemanticContext, NumBytesToErase, CCS, AssociatedDecl, ModuleName,
1298-
NotRecReason, copyString(*Sink.Allocator, BriefComment),
1297+
SemanticContext, IsArgumentLabels, NumBytesToErase, CCS, AssociatedDecl,
1298+
ModuleName, NotRecReason, copyString(*Sink.Allocator, BriefComment),
12991299
copyAssociatedUSRs(*Sink.Allocator, AssociatedDecl),
13001300
copyArray(*Sink.Allocator, CommentWords), ExpectedTypeRelation);
13011301
}
13021302

13031303
case CodeCompletionResult::ResultKind::Keyword:
13041304
return new (*Sink.Allocator)
13051305
CodeCompletionResult(
1306-
KeywordKind, SemanticContext, NumBytesToErase,
1306+
KeywordKind, SemanticContext, IsArgumentLabels, NumBytesToErase,
13071307
CCS, ExpectedTypeRelation,
13081308
copyString(*Sink.Allocator, BriefDocComment));
13091309

13101310
case CodeCompletionResult::ResultKind::BuiltinOperator:
13111311
case CodeCompletionResult::ResultKind::Pattern:
13121312
return new (*Sink.Allocator) CodeCompletionResult(
1313-
Kind, SemanticContext, NumBytesToErase, CCS, ExpectedTypeRelation,
1314-
CodeCompletionOperatorKind::None,
1313+
Kind, SemanticContext, IsArgumentLabels, NumBytesToErase, CCS,
1314+
ExpectedTypeRelation, CodeCompletionOperatorKind::None,
13151315
copyString(*Sink.Allocator, BriefDocComment));
13161316

13171317
case CodeCompletionResult::ResultKind::Literal:
13181318
assert(LiteralKind.hasValue());
13191319
return new (*Sink.Allocator)
1320-
CodeCompletionResult(*LiteralKind, SemanticContext, NumBytesToErase,
1321-
CCS, ExpectedTypeRelation);
1320+
CodeCompletionResult(*LiteralKind, SemanticContext, IsArgumentLabels,
1321+
NumBytesToErase, CCS, ExpectedTypeRelation);
13221322
}
13231323

13241324
llvm_unreachable("Unhandled CodeCompletionResult in switch.");
@@ -2895,6 +2895,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
28952895
: CodeCompletionResult::ResultKind::Pattern,
28962896
SemanticContext ? *SemanticContext : getSemanticContextKind(AFD),
28972897
expectedTypeContext);
2898+
Builder.setIsArgumentLabels();
28982899
if (AFD) {
28992900
Builder.setAssociatedDecl(AFD);
29002901
setClangDeclKeywords(AFD, Pairs, Builder);

0 commit comments

Comments
 (0)