Skip to content

Commit c3cb8be

Browse files
committed
Track 'release/5.5' to resolve merge conflicts.
Conflicts were just @Availability marker changes.
2 parents 474e5f7 + 0912fa2 commit c3cb8be

File tree

221 files changed

+5474
-1397
lines changed

Some content is hidden

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

221 files changed

+5474
-1397
lines changed

CHANGELOG.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,24 @@ CHANGELOG
2929
Swift 5.5
3030
---------
3131

32+
* Type names are no longer allowed as an argument to a subscript parameter that expects a metatype type
33+
34+
```swift
35+
struct MyValue {
36+
}
37+
38+
struct MyStruct {
39+
subscript(a: MyValue.Type) -> Int { get { ... } }
40+
}
41+
42+
func test(obj: MyStruct) {
43+
let _ = obj[MyValue]
44+
}
45+
```
46+
47+
Accepting subscripts with `MyValue` as an argument was an oversight because `MyValue` requires explicit `.self`
48+
to reference its metatype, so correct syntax would be to use `obj[MyValue.self]`.
49+
3250
* [SE-0310][]:
3351

3452
Read-only computed properties and subscripts can now define their `get` accessor to be `async` and/or `throws`, by writing one or both of those keywords between the `get` and `{`. Thus, these members can now make asynchronous calls or throw errors in the process of producing a value:
@@ -72,7 +90,6 @@ Swift 5.5
7290
}
7391
```
7492

75-
7693
* [SE-0306][]:
7794

7895
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:

include/swift/ABI/MetadataValues.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1977,7 +1977,8 @@ enum class JobKind : size_t {
19771977

19781978
DefaultActorInline = First_Reserved,
19791979
DefaultActorSeparate,
1980-
DefaultActorOverride
1980+
DefaultActorOverride,
1981+
NullaryContinuation
19811982
};
19821983

19831984
/// The priority of a job. Higher priorities are larger values.

include/swift/ABI/Task.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,25 @@ class ActiveTaskStatus {
155155
}
156156
};
157157

158+
class NullaryContinuationJob : public Job {
159+
160+
private:
161+
AsyncTask* Task;
162+
AsyncTask* Continuation;
163+
164+
public:
165+
NullaryContinuationJob(AsyncTask *task, JobPriority priority, AsyncTask *continuation)
166+
: Job({JobKind::NullaryContinuation, priority}, &process),
167+
Task(task), Continuation(continuation) {}
168+
169+
SWIFT_CC(swiftasync)
170+
static void process(Job *job);
171+
172+
static bool classof(const Job *job) {
173+
return job->Flags.getKind() == JobKind::NullaryContinuation;
174+
}
175+
};
176+
158177
/// An asynchronous task. Tasks are the analogue of threads for
159178
/// asynchronous functions: that is, they are a persistent identity
160179
/// for the overall async computation.
@@ -562,6 +581,10 @@ class ContinuationAsyncContext : public AsyncContext {
562581
/// The executor that should be resumed to.
563582
ExecutorRef ResumeToExecutor;
564583

584+
void setErrorResult(SwiftError *error) {
585+
ErrorResult = error;
586+
}
587+
565588
static bool classof(const AsyncContext *context) {
566589
return context->Flags.getKind() == AsyncContextKind::Continuation;
567590
}

include/swift/AST/ASTContext.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,13 @@ class ASTContext final {
880880
/// If there is no Clang module loader, returns a null pointer.
881881
/// The loader is owned by the AST context.
882882
ClangModuleLoader *getDWARFModuleLoader() const;
883+
884+
/// Check whether the module with a given name can be imported without
885+
/// importing it.
886+
///
887+
/// Note that even if this check succeeds, errors may still occur if the
888+
/// module is loaded in full.
889+
bool canImportModuleImpl(ImportPath::Element ModulePath) const;
883890
public:
884891
namelookup::ImportCache &getImportCache() const;
885892

@@ -909,6 +916,7 @@ class ASTContext final {
909916
/// Note that even if this check succeeds, errors may still occur if the
910917
/// module is loaded in full.
911918
bool canImportModule(ImportPath::Element ModulePath);
919+
bool canImportModule(ImportPath::Element ModulePath) const;
912920

913921
/// \returns a module with a given name that was already loaded. If the
914922
/// module was not loaded, returns nullptr.

include/swift/AST/Decl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1862,7 +1862,7 @@ class PatternBindingDecl final : public Decl,
18621862
bool isComputingPatternBindingEntry(const VarDecl *vd) const;
18631863

18641864
/// Is this an "async let" declaration?
1865-
bool isSpawnLet() const;
1865+
bool isAsyncLet() const;
18661866

18671867
/// Gets the text of the initializer expression for the pattern entry at the
18681868
/// given index, stripping out inactive branches of any #ifs inside the
@@ -4942,7 +4942,7 @@ class VarDecl : public AbstractStorageDecl {
49424942
bool isLet() const { return getIntroducer() == Introducer::Let; }
49434943

49444944
/// Is this an "async let" property?
4945-
bool isSpawnLet() const;
4945+
bool isAsyncLet() const;
49464946

49474947
Introducer getIntroducer() const {
49484948
return Introducer(Bits.VarDecl.Introducer);

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ ERROR(cannot_emit_ir_skipping_function_bodies,none,
136136
WARNING(emit_reference_dependencies_without_primary_file,none,
137137
"ignoring -emit-reference-dependencies (requires -primary-file)", ())
138138

139+
WARNING(warn_implicit_concurrency_import_failed,none,
140+
"unable to perform implicit import of \"_Concurrency\" module: no such module found", ())
141+
139142
ERROR(error_module_name_required,none, "-module-name is required", ())
140143
ERROR(error_bad_module_name,none,
141144
"module name \"%0\" is not a valid identifier"

include/swift/AST/DiagnosticsRefactoring.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ ERROR(unknown_callback_conditions, none, "cannot refactor complex if conditions"
6262

6363
ERROR(mixed_callback_conditions, none, "cannot refactor mixed nil and not-nil conditions", ())
6464

65-
ERROR(callback_multiple_bound_names, none, "cannot refactor when multiple names bound to single declaration, had '%0' and found '%1'", (StringRef, StringRef))
66-
6765
ERROR(callback_with_fallthrough, none, "cannot refactor switch with fallthrough", ())
6866

6967
ERROR(callback_with_default, none, "cannot refactor switch with default case", ())

include/swift/AST/DiagnosticsSema.def

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,9 @@ FIXIT(insert_closure_return_type_placeholder,
279279
"%select{| () }0-> <#Result#> %select{|in }0",
280280
(bool))
281281

282+
NOTE(use_of_anon_closure_param,none,
283+
"anonymous closure parameter %0 is used here", (Identifier))
284+
282285
ERROR(incorrect_explicit_closure_result,none,
283286
"declared closure result %0 is incompatible with contextual type %1",
284287
(Type, Type))
@@ -425,6 +428,9 @@ ERROR(cannot_convert_argument_value_anyobject,none,
425428
(Type, Type))
426429
ERROR(cannot_convert_argument_value_nil,none,
427430
"'nil' is not compatible with expected argument type %0", (Type))
431+
NOTE(note_incompatible_argument_value_nil_at_pos,none,
432+
"'nil' is not compatible with expected argument type %0 at position #%1",
433+
(Type, unsigned))
428434

429435
ERROR(cannot_convert_condition_value,none,
430436
"cannot convert value of type %0 to expected condition type %1",
@@ -806,6 +812,8 @@ ERROR(serialization_error_type,Fatal,
806812
ERROR(serialization_allowing_error_type,none,
807813
"allowing deserialization of error type '%0' in module '%1'",
808814
(StringRef, StringRef))
815+
WARNING(serialization_malformed_sourceinfo,none,
816+
"unable to use malformed module source info '%0'", (StringRef))
809817

810818
ERROR(reserved_member_name,none,
811819
"type member must not be named %0, since it would conflict with the"
@@ -4238,8 +4246,8 @@ ERROR(throwing_interpolation_without_try,none,
42384246
"interpolation can throw but is not marked with 'try'", ())
42394247
ERROR(throwing_call_without_try,none,
42404248
"call can throw but is not marked with 'try'", ())
4241-
ERROR(throwing_spawn_let_without_try,none,
4242-
"reading 'spawn let' can throw but is not marked with 'try'", ())
4249+
ERROR(throwing_async_let_without_try,none,
4250+
"reading 'async let' can throw but is not marked with 'try'", ())
42434251
ERROR(throwing_prop_access_without_try,none,
42444252
"property access can throw but is not marked with 'try'", ())
42454253
ERROR(throwing_subscript_access_without_try,none,
@@ -4268,8 +4276,8 @@ NOTE(async_access_without_await,none,
42684276

42694277
NOTE(async_call_without_await_in_autoclosure,none,
42704278
"call is 'async' in an autoclosure argument", ())
4271-
NOTE(async_call_without_await_in_spawn_let,none,
4272-
"call is 'async' in an 'spawn let' initializer", ())
4279+
NOTE(async_call_without_await_in_async_let,none,
4280+
"call is 'async' in an 'async let' initializer", ())
42734281

42744282
WARNING(no_async_in_await,none,
42754283
"no 'async' operations occur within 'await' expression", ())
@@ -4282,7 +4290,7 @@ ERROR(await_in_illegal_context,none,
42824290
"%select{<<ERROR>>|a default argument|a property wrapper initializer|a property initializer|a global variable initializer|an enum case raw value|a catch pattern|a catch guard expression|a defer body}0",
42834291
(unsigned))
42844292
ERROR(async_in_nonasync_function,none,
4285-
"%select{'async'|'async' call|'await'|'spawn let'|'async' property access|'async' subscript access}0 in "
4293+
"%select{'async'|'async' call|'await'|'async let'|'async' property access|'async' subscript access}0 in "
42864294
"%select{a function|an autoclosure}1 that does not support concurrency",
42874295
(unsigned, bool))
42884296
NOTE(note_add_async_to_function,none,
@@ -4309,21 +4317,18 @@ NOTE(protocol_witness_async_conflict,none,
43094317
ERROR(async_autoclosure_nonasync_function,none,
43104318
"'async' autoclosure parameter in a non-'async' function", ())
43114319

4312-
WARNING(async_let_is_spawn_let,none,
4313-
"'async let' is now 'spawn let'", ())
4314-
4315-
ERROR(spawn_not_let,none,
4316-
"'spawn' can only be used with 'let' declarations", ())
4317-
ERROR(spawn_let_not_local,none,
4318-
"'spawn let' can only be used on local declarations", ())
4319-
ERROR(spawn_let_not_initialized,none,
4320-
"'spawn let' binding requires an initializer expression", ())
4321-
ERROR(spawn_let_no_variables,none,
4322-
"'spawn let' requires at least one named variable", ())
4323-
NOTE(spawn_let_without_await,none,
4324-
"reference to spawn let %0 is 'async'", (DeclName))
4325-
ERROR(spawn_let_in_illegal_context,none,
4326-
"spawn let %0 cannot be referenced in "
4320+
ERROR(async_not_let,none,
4321+
"'async' can only be used with 'let' declarations", ())
4322+
ERROR(async_let_not_local,none,
4323+
"'async let' can only be used on local declarations", ())
4324+
ERROR(async_let_not_initialized,none,
4325+
"'async let' binding requires an initializer expression", ())
4326+
ERROR(async_let_no_variables,none,
4327+
"'async let' requires at least one named variable", ())
4328+
NOTE(async_let_without_await,none,
4329+
"reference to async let %0 is 'async'", (DeclName))
4330+
ERROR(async_let_in_illegal_context,none,
4331+
"async let %0 cannot be referenced in "
43274332
"%select{<<ERROR>>|a default argument|a property wrapper initializer|a property initializer|a global variable initializer|an enum case raw value|a catch pattern|a catch guard expression|a defer body}1",
43284333
(DeclName, unsigned))
43294334

@@ -4413,8 +4418,8 @@ ERROR(actor_isolated_from_concurrent_closure,none,
44134418
ERROR(actor_isolated_from_concurrent_function,none,
44144419
"actor-isolated %0 %1 cannot be %select{referenced|mutated|used 'inout'}2 from a concurrent function",
44154420
(DescriptiveDeclKind, DeclName, unsigned))
4416-
ERROR(actor_isolated_from_spawn_let,none,
4417-
"actor-isolated %0 %1 cannot be %select{referenced|mutated|used 'inout'}2 from 'spawn let' initializer",
4421+
ERROR(actor_isolated_from_async_let,none,
4422+
"actor-isolated %0 %1 cannot be %select{referenced|mutated|used 'inout'}2 from 'async let' initializer",
44184423
(DescriptiveDeclKind, DeclName, unsigned))
44194424
ERROR(actor_isolated_keypath_component,none,
44204425
"cannot form key path to actor-isolated %0 %1",
@@ -4436,9 +4441,6 @@ NOTE(actor_isolated_sync_func,none,
44364441
NOTE(actor_mutable_state,none,
44374442
"mutation of this %0 is only permitted within the actor",
44384443
(DescriptiveDeclKind))
4439-
NOTE(actor_isolated_let,none,
4440-
"use `nonisolated` to allow synchronous access to 'let' from outside "
4441-
"the actor", ())
44424444
WARNING(shared_mutable_state_access,none,
44434445
"reference to %0 %1 is not concurrency-safe because it involves "
44444446
"shared mutable state", (DescriptiveDeclKind, DeclName))
@@ -4471,12 +4473,13 @@ WARNING(non_concurrent_property_type,none,
44714473
WARNING(non_concurrent_keypath_capture,none,
44724474
"cannot form key path that captures non-sendable type %0",
44734475
(Type))
4476+
WARNING(non_concurrent_keypath_access,none,
4477+
"cannot form key path that accesses non-sendable type %0",
4478+
(Type))
44744479
ERROR(non_concurrent_type_member,none,
44754480
"%select{stored property %1|associated value %1}0 of "
44764481
"'Sendable'-conforming %2 %3 has non-sendable type %4",
44774482
(bool, DeclName, DescriptiveDeclKind, DeclName, Type))
4478-
ERROR(non_sendable_nonisolated_let,none,
4479-
"non-isolated let property %0 has non-Sendable type %1", (DeclName, Type))
44804483
ERROR(concurrent_value_class_mutable_property,none,
44814484
"stored property %0 of 'Sendable'-conforming %1 %2 is mutable",
44824485
(DeclName, DescriptiveDeclKind, DeclName))
@@ -4492,13 +4495,21 @@ ERROR(concurrent_value_inherit,none,
44924495
"%select{| other than 'NSObject'}0",
44934496
(bool, DeclName))
44944497

4498+
ERROR(actorindependent_let,none,
4499+
"'@actorIndependent' is meaningless on 'let' declarations because "
4500+
"they are immutable",
4501+
())
44954502
ERROR(actorindependent_mutable_storage,none,
44964503
"'@actorIndependent' can not be applied to stored properties",
44974504
())
44984505
ERROR(actorindependent_local_var,none,
44994506
"'@actorIndependent' can not be applied to local variables",
45004507
())
45014508

4509+
ERROR(nonisolated_let,none,
4510+
"'nonisolated' is meaningless on 'let' declarations because "
4511+
"they are immutable",
4512+
())
45024513
ERROR(nonisolated_mutable_storage,none,
45034514
"nonisolated' can not be applied to stored properties",
45044515
())

include/swift/AST/NameLookup.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -555,9 +555,7 @@ class FindLocalVal : public StmtVisitor<FindLocalVal> {
555555
VisibleDeclConsumer &Consumer)
556556
: SM(SM), Loc(Loc), Consumer(Consumer) {}
557557

558-
void checkValueDecl(ValueDecl *D, DeclVisibilityKind Reason) {
559-
Consumer.foundDecl(D, Reason);
560-
}
558+
void checkValueDecl(ValueDecl *D, DeclVisibilityKind Reason);
561559

562560
void checkPattern(const Pattern *Pat, DeclVisibilityKind Reason);
563561

include/swift/AST/TypeRefinementContext.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,21 @@ class TypeRefinementContext {
154154

155155
SourceRange SrcRange;
156156

157+
/// A canonical availiability info for this context, computed top-down from the root
158+
/// context (compilation deployment target).
157159
AvailabilityContext AvailabilityInfo;
158160

161+
/// If this context was annotated with an availability attribute, this property captures that.
162+
/// It differs from the above `AvailabilityInfo` by being independent of the deployment target,
163+
/// and is used for providing availability attribute redundancy warning diagnostics.
164+
AvailabilityContext ExplicitAvailabilityInfo;
165+
159166
std::vector<TypeRefinementContext *> Children;
160167

161168
TypeRefinementContext(ASTContext &Ctx, IntroNode Node,
162169
TypeRefinementContext *Parent, SourceRange SrcRange,
163-
const AvailabilityContext &Info);
170+
const AvailabilityContext &Info,
171+
const AvailabilityContext &ExplicitInfo);
164172

165173
public:
166174

@@ -172,6 +180,7 @@ class TypeRefinementContext {
172180
static TypeRefinementContext *createForDecl(ASTContext &Ctx, Decl *D,
173181
TypeRefinementContext *Parent,
174182
const AvailabilityContext &Info,
183+
const AvailabilityContext &ExplicitInfo,
175184
SourceRange SrcRange);
176185

177186
/// Create a refinement context for the Then branch of the given IfStmt.
@@ -245,6 +254,12 @@ class TypeRefinementContext {
245254
return AvailabilityInfo;
246255
}
247256

257+
/// Returns the information on what availability was specified by the programmer
258+
/// on this context (if any).
259+
const AvailabilityContext &getExplicitAvailabilityInfo() const {
260+
return ExplicitAvailabilityInfo;
261+
}
262+
248263
/// Adds a child refinement context.
249264
void addChild(TypeRefinementContext *Child) {
250265
assert(Child->getSourceRange().isValid());

0 commit comments

Comments
 (0)