Skip to content

Update GettingStarted.md #38659

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 92 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
d70e93b
[Demangler] Fix OldRemangler to cope with single argument functions.
al45tair Jun 19, 2021
d57cedd
Merge branch 'main' into problem/63678072
al45tair Jun 25, 2021
52ec3d1
Merge branch 'main' into problem/63678072
al45tair Jul 7, 2021
96dce95
[RemoteMirror] Add swift_reflection_interop_projectEnumValue()
al45tair Jul 9, 2021
c3df37c
[RemoteMirror] Move interop test to the test directory, run it automa…
al45tair Jul 13, 2021
c23d2f4
[Demangler] Fix NULL dereference on malformed mangled class name.
al45tair Jul 16, 2021
202905f
[CodeCompletion] Allow preChecking an expression twice in code comple…
ahoppen Jul 21, 2021
6ccfe03
[Runtime] Static constructors and destructors should be an error here.
al45tair Jul 22, 2021
a8f126f
C++ Interop: import const methods as non-mutating
egorzhdan Jul 24, 2021
fec7f6c
[CodeCompletion] Fix issue causing the completion status to not be se…
ahoppen Jul 22, 2021
916d7b6
[test] Add test for inout arg in strange interpolation
hamishknight Jul 27, 2021
3f0bdff
Re-enable test that should not be flaky now.
DougGregor Jul 27, 2021
bc258d0
SILGen: Don't reabstract a member ref we're about to directly apply.
jckarter Jul 28, 2021
849f6b9
[stdlib] Update SubSequence docs
lorentey Jul 26, 2021
4597fe2
Update GettingStarted.md
mcc-devel Jul 28, 2021
13443e4
Update GettingStarted.md
mcc-devel Jul 28, 2021
3b51e86
[Refactoring] Disable availability checking to reduce errors
bnbarham Jul 28, 2021
6d07945
Merge pull request #38635 from lorentey/update-subsequence-docs
swift-ci Jul 28, 2021
fb4ee55
Merge pull request #38657 from DougGregor/enable-yield-test
DougGregor Jul 28, 2021
20cc067
[AST] Introduce BuiltinProtocolConformance
Azoy May 23, 2020
ecd830e
Rework BuiltinProtocolConformance to be more like NormalProtocolConfo…
DougGregor Jul 28, 2021
314220f
benchmarks of performance when filling memory buffers
glessard Jul 21, 2021
119e886
Merge pull request #38656 from hamishknight/up-for-interpolation
hamishknight Jul 28, 2021
030e0ff
Merge pull request #38332 from al45tair/problems/62128103
al45tair Jul 28, 2021
95be0d6
Merge pull request #37997 from al45tair/problem/63678072
al45tair Jul 28, 2021
f15c2a7
Merge pull request #38429 from al45tair/problem/80602920
al45tair Jul 28, 2021
9a48cf9
Merge pull request #38562 from al45tair/problem/80965245
al45tair Jul 28, 2021
3253a4f
[SE-0302] Implement structural conformances to Sendable.
DougGregor Jul 28, 2021
4434ee9
Merge pull request #38658 from jckarter/avoid-reabstracting-applied-m…
jckarter Jul 28, 2021
37c06cd
[CodeCompletion] Complete typealias from inherited protocol
ahoppen Jul 28, 2021
3bea2b7
[Async Refactoring] Handle parenthesis around params that no longer n…
ahoppen Jul 7, 2021
210ade3
add a reference to a bugs.swift.org report
glessard Jul 28, 2021
4dc7657
GSB: Canonicalize subject type in isValidDerivationPath()
slavapestov Jul 21, 2021
106decb
GSB: Try harder to handle a combination of a superclass and conforman…
slavapestov Jul 22, 2021
e4115a2
GSB: New way of handling concrete same-type requirements when rebuild…
slavapestov Jul 22, 2021
b773697
Sema: checkConformancesInContext() should only ever be called on pars…
slavapestov Jul 20, 2021
77cb4b6
Merge pull request #38559 from ahoppen/pr/dont-add-members-twice
ahoppen Jul 28, 2021
640e067
Update the rebranch scheme to use stable/20210726 llvm-project branch
shahmishal Jul 28, 2021
6c66fd3
Additional architecture support for the `ScanDependencies/clang-targe…
artemcm Jul 28, 2021
ba43a4d
Replace the ad-hoc Sendable checking visitor with "conforms to protoc…
DougGregor Jul 28, 2021
7c0bdff
Improve misleading diagnostics regarding implicit Sendable conformances
DougGregor Jul 28, 2021
e2985b6
Merge pull request #38618 from egorzhdan/cxx-mutating
egorzhdan Jul 28, 2021
a92acc7
Merge pull request #38621 from glessard/buffer-benchmarks
swift-ci Jul 28, 2021
9789130
Merge pull request #38667 from apple/update-checkout-stable-20210726
swift-ci Jul 28, 2021
91c9b18
[test] Change a %refactor into %refactor-check-compiles
hamishknight Jul 28, 2021
06908ad
[Async Refactoring] Handle multiple trailing closures
hamishknight Jul 28, 2021
1a7d987
Merge pull request #38474 from ahoppen/pr/dont-precheck-twice
ahoppen Jul 28, 2021
c8ad4cd
Merge pull request #38664 from ahoppen/pr/complete-typealias-from-pro…
ahoppen Jul 28, 2021
1286bbe
Merge pull request #38665 from ahoppen/pr/async-refactoring-parens-ar…
ahoppen Jul 28, 2021
9edd190
Merge pull request #38666 from slavapestov/tiny-conformance-check-cle…
slavapestov Jul 28, 2021
43776ce
Merge pull request #38669 from DougGregor/structural-sendable-conform…
DougGregor Jul 28, 2021
eb70e0f
[tests] Make sure to build module interface test dummy library for x8…
LucianoPAlmeida Jul 19, 2021
c5ad287
[tests] Run module interface build alternative interface test in dyna…
LucianoPAlmeida Jul 19, 2021
4efb9ac
[Tests] Mark some tests as unsupported in back deployment testing.
mikeash Jul 28, 2021
18aa987
Fix test.
gottesmm Jul 28, 2021
c70f280
[AST] Add CallExpr::createImplicitEmpty
hamishknight Jul 28, 2021
72d4d9f
[AST] Add some 'create' factory methods
hamishknight Jul 28, 2021
7055988
[AST] Simplify KeyPath::Component construction slightly
hamishknight Jul 28, 2021
df566e3
[AST] Rename decomposeInput/composeInput
hamishknight Jul 28, 2021
ebd820c
Merge pull request #38660 from apple/disable-refactoring-availability…
bnbarham Jul 28, 2021
1fc7f07
[tests] Make sure to build module interface test dummy library for ar…
LucianoPAlmeida Jul 28, 2021
e7e9b57
Replace @completionHandlerAsync with @available(*, renamed:)
bnbarham Jul 14, 2021
f64833b
Merge pull request #38671 from artemcm/ClangTargetTestMoreTargetsLess
artemcm Jul 28, 2021
3b15f30
Merge pull request #38679 from mikeash/block-some-tests-from-back-dep…
swift-ci Jul 29, 2021
2132a90
DependenciesScanner: include -sdk in Swift module building command
nkcsgexi Jul 29, 2021
7bee60e
Merge pull request #38643 from apple/available-not-completionhandlera…
bnbarham Jul 29, 2021
4a8a647
[Test] Used test header rather than SDK.
nate-chandler Jul 29, 2021
94ca17e
Merge pull request #38684 from nkcsgexi/81177968
nkcsgexi Jul 29, 2021
0389ea5
[ClangImporter] Add @available(*, renamed:) to imported async getters
bnbarham Jul 14, 2021
b897e0c
Disable cxx_interop_ir test (SR-14986)
shahmishal Jul 29, 2021
221755c
Merge pull request #38690 from apple/shahmishal/disable-cxx_interop_i…
shahmishal Jul 29, 2021
d8686f7
Merge pull request #38687 from nate-chandler/validation-test/compiler…
swift-ci Jul 29, 2021
04dde14
C++ Interop: fix `ClangImporter/cxx_interop_ir.swift` on 32-bit
egorzhdan Jul 29, 2021
ebdae7c
Merge pull request #38504 from hamishknight/construction-site
hamishknight Jul 29, 2021
813a721
Merge pull request #38674 from hamishknight/following-the-trail
hamishknight Jul 29, 2021
8918a09
[Tests] Fix RemoteMirror/interop.swift to work with ASAN enabled.
al45tair Jul 29, 2021
c9c5438
Merge pull request #38553 from slavapestov/gsb-canonicalize-requireme…
slavapestov Jul 29, 2021
1ec6b82
Merge pull request #38680 from gottesmm/pr-ea11107f193cc1529851ec1fa8…
gottesmm Jul 29, 2021
3722bcb
Revert "[concurrency] Implement a compatibility .a library for Concur…
shahmishal Jul 29, 2021
4489a65
Merge pull request #38695 from apple/revert-38616-pr-43566c09aa169640…
shahmishal Jul 29, 2021
aec4ec4
[Runtime] Weakly import dyld protocol conformance functions.
mikeash Jul 29, 2021
a887046
Revert "Fix test."
shahmishal Jul 29, 2021
d342593
Merge pull request #38697 from apple/revert-38680-pr-ea11107f193cc152…
shahmishal Jul 29, 2021
c52fe9b
Merge pull request #38694 from al45tair/problem/81274645
al45tair Jul 29, 2021
022d44d
Merge pull request #38464 from LucianoPAlmeida/require-arch-for-test
LucianoPAlmeida Jul 29, 2021
0ccf43d
Merge pull request #38688 from apple/add-available-to-getters
bnbarham Jul 29, 2021
d0f2260
Update GettingStarted.md
mcc-devel Jul 30, 2021
bedb434
[Serialization] Ignore conformance failures when allowing errors
bnbarham Jul 28, 2021
598eef3
Merge pull request #38696 from mikeash/weak-import-dyld-calls
mikeash Jul 30, 2021
9d39821
Merge pull request #38661 from apple/conformance-failures
bnbarham Jul 30, 2021
4cd373c
Merge pull request #38692 from egorzhdan/cxx-ir-fix
egorzhdan Jul 30, 2021
756d897
Merge branch 'apple:main' into patch-1
mcc-devel Jul 30, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ set(SWIFT_BENCH_MODULES
single-source/BitCount
single-source/Breadcrumbs
single-source/BucketSort
single-source/BufferFill
single-source/ByteSwap
single-source/COWTree
single-source/COWArrayGuaranteedParameterOverhead
Expand Down
121 changes: 121 additions & 0 deletions benchmark/single-source/BufferFill.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
//===--- BufferFill.swift -------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//

import TestsUtils

public let BufferFill = [
BenchmarkInfo(name: "BufferFillFromSlice",
runFunction: bufferFillFromSliceExecute,
tags: [.validation, .api],
setUpFunction: bufferFillFromSliceSetup,
tearDownFunction: bufferFillFromSliceTeardown),
BenchmarkInfo(name: "RawBufferCopyBytes",
runFunction: rawBufferCopyBytesExecute,
tags: [.validation, .api],
setUpFunction: rawBufferCopyBytesSetup,
tearDownFunction: rawBufferCopyBytesTeardown),
BenchmarkInfo(name: "RawBufferInitializeMemory",
runFunction: rawBufferInitializeMemoryExecute,
tags: [.validation, .api],
setUpFunction: rawBufferInitializeMemorySetup,
tearDownFunction: rawBufferInitializeMemoryTeardown),
]

let c = 100_000
let a = Array(0..<c)
var b: UnsafeMutableBufferPointer<Int> = .init(start: nil, count: 0)
var r = Int.zero

public func bufferFillFromSliceSetup() {
assert(b.baseAddress == nil)
b = .allocate(capacity: c)
r = a.indices.randomElement()!
}

public func bufferFillFromSliceTeardown() {
b.deallocate()
b = .init(start: nil, count: 0)
}

@inline(never)
public func bufferFillFromSliceExecute(n: Int) {
// Measure performance when filling an UnsafeBuffer from a Slice
// of a Collection that supports `withContiguousStorageIfAvailable`
// See: https://bugs.swift.org/browse/SR-14491

for _ in 0..<n {
let slice = Slice(base: a, bounds: a.indices)
var (iterator, copied) = b.initialize(from: slice)
blackHole(b)
CheckResults(copied == a.count && iterator.next() == nil)
}

CheckResults(a[r] == b[r])
}

var ra: [UInt8] = []
var rb = UnsafeMutableRawBufferPointer(start: nil, count: 0)

public func rawBufferCopyBytesSetup() {
assert(rb.baseAddress == nil)
ra = a.withUnsafeBytes(Array.init)
r = ra.indices.randomElement()!
rb = .allocate(byteCount: ra.count, alignment: 1)
}

public func rawBufferCopyBytesTeardown() {
rb.deallocate()
rb = .init(start: nil, count: 0)
ra = []
}

@inline(never)
public func rawBufferCopyBytesExecute(n: Int) {
// Measure performance when copying bytes into an UnsafeRawBuffer
// from a Collection that supports `withContiguousStorageIfAvailable`
// See: https://bugs.swift.org/browse/SR-14886

for _ in 0..<n {
rb.copyBytes(from: ra)
blackHole(rb)
}

CheckResults(ra[r] == rb[r])
}

public func rawBufferInitializeMemorySetup() {
assert(rb.baseAddress == nil)
rb = .allocate(byteCount: a.count * MemoryLayout<Int>.stride, alignment: 1)
r = a.indices.randomElement()!
}

public func rawBufferInitializeMemoryTeardown() {
rb.deallocate()
rb = .init(start: nil, count: 0)
}

@inline(never)
public func rawBufferInitializeMemoryExecute(n: Int) {
// Measure performance when initializing an UnsafeRawBuffer
// from a Collection that supports `withContiguousStorageIfAvailable`
// See: https://bugs.swift.org/browse/SR-14982

for _ in 0..<n {
var (iterator, initialized) = rb.initializeMemory(as: Int.self, from: a)
blackHole(rb)
CheckResults(initialized.count == a.count && iterator.next() == nil)
}

let offset = rb.baseAddress!.advanced(by: r*MemoryLayout<Int>.stride)
let value = offset.load(as: Int.self)
CheckResults(value == a[r])
}
2 changes: 2 additions & 0 deletions benchmark/utils/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import BinaryFloatingPointProperties
import BitCount
import Breadcrumbs
import BucketSort
import BufferFill
import ByteSwap
import COWTree
import COWArrayGuaranteedParameterOverhead
Expand Down Expand Up @@ -225,6 +226,7 @@ registerBenchmark(BinaryFloatingPointPropertiesUlp)
registerBenchmark(BitCount)
registerBenchmark(Breadcrumbs)
registerBenchmark(BucketSort)
registerBenchmark(BufferFill)
registerBenchmark(ByteSwap)
registerBenchmark(COWTree)
registerBenchmark(COWArrayGuaranteedParameterOverhead)
Expand Down
2 changes: 2 additions & 0 deletions docs/HowToGuides/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ Double-check that running `pwd` prints a path ending with `swift`.

⚠️ Since version 0.2.14, `sccache` no longer caches compile commands issued by `build-script` because of [sccache PR 898](https://github.com/mozilla/sccache/pull/898), since `build-script` adds the `-arch x86_64` argument twice. The instructions below may install `sccache` 0.2.14 or newer. You may want to instead download and install an older release from their [Releases page](https://github.com/mozilla/sccache/releases) until this issue is resolved.

This issue is already resolved in sscache commit 7f8d643c633b240cf33fb5dbd5a89d36b0a0c1e3 at https://github.com/mozilla/sccache/commit/7f8d643c633b240cf33fb5dbd5a89d36b0a0c1e3. However, no current version builds sscache with this change.

1. Install [Xcode 12.3][Xcode] or newer:
The required version of Xcode changes frequently and is often a beta release.
Check this document or the host information on <https://ci.swift.org> for the
Expand Down
3 changes: 3 additions & 0 deletions docs/Testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,9 @@ code for the target that is not the build machine:
* ``%target-cc-options``: the clang flags to setup the target with the right
architecture and platform version.

* ``%target-sanitizer-opt``: if sanitizers are enabled for the build, the
corresponding ``-fsanitize=`` option.

* ``%target-triple``: a triple composed of the ``%target-cpu``, the vendor,
the ``%target-os``, and the operating system version number. Possible values
include ``i386-apple-ios7.0`` or ``armv7k-apple-watchos2.0``.
Expand Down
7 changes: 7 additions & 0 deletions include/swift/AST/ASTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ namespace swift {
class InheritedProtocolConformance;
class SelfProtocolConformance;
class SpecializedProtocolConformance;
class BuiltinProtocolConformance;
enum class ProtocolConformanceState;
class Pattern;
enum PointerTypeKind : unsigned;
Expand Down Expand Up @@ -1029,6 +1030,12 @@ class ASTContext final {
SelfProtocolConformance *
getSelfConformance(ProtocolDecl *protocol);

/// Produce the builtin conformance for some structural type to some protocol.
BuiltinProtocolConformance *
getBuiltinConformance(Type type, ProtocolDecl *protocol,
GenericSignature genericSig,
ArrayRef<Requirement> conditionalRequirements);

/// A callback used to produce a diagnostic for an ill-formed protocol
/// conformance that was type-checked before we're actually walking the
/// conformance itself, along with a bit indicating whether this diagnostic
Expand Down
6 changes: 1 addition & 5 deletions include/swift/AST/Attr.def
Original file line number Diff line number Diff line change
Expand Up @@ -621,11 +621,7 @@ SIMPLE_DECL_ATTR(reasync, AtReasync,
ABIBreakingToAdd | ABIBreakingToRemove | APIBreakingToAdd | APIBreakingToRemove,
110)

DECL_ATTR(completionHandlerAsync, CompletionHandlerAsync,
OnAbstractFunction | ConcurrencyOnly | LongAttribute |
ABIStableToAdd | ABIStableToRemove |
APIStableToAdd | APIStableToRemove,
111)
// 111 was an experimental @completionHandlerAsync and is now unused

CONTEXTUAL_SIMPLE_DECL_ATTR(nonisolated, Nonisolated,
DeclModifier | OnFunc | OnConstructor | OnVar | OnSubscript |
Expand Down
66 changes: 13 additions & 53 deletions include/swift/AST/Attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ class AvailableAttr : public DeclAttribute {

AvailableAttr(SourceLoc AtLoc, SourceRange Range,
PlatformKind Platform,
StringRef Message, StringRef Rename,
StringRef Message, StringRef Rename, ValueDecl *RenameDecl,
const llvm::VersionTuple &Introduced,
SourceRange IntroducedRange,
const llvm::VersionTuple &Deprecated,
Expand All @@ -639,7 +639,7 @@ class AvailableAttr : public DeclAttribute {
PlatformAgnosticAvailabilityKind PlatformAgnostic,
bool Implicit)
: DeclAttribute(DAK_Available, AtLoc, Range, Implicit),
Message(Message), Rename(Rename),
Message(Message), Rename(Rename), RenameDecl(RenameDecl),
INIT_VER_TUPLE(Introduced), IntroducedRange(IntroducedRange),
INIT_VER_TUPLE(Deprecated), DeprecatedRange(DeprecatedRange),
INIT_VER_TUPLE(Obsoleted), ObsoletedRange(ObsoletedRange),
Expand All @@ -660,6 +660,12 @@ class AvailableAttr : public DeclAttribute {
/// the `NS_SWIFT_NAME` annotation in Objective-C.
const StringRef Rename;

/// The declaration referred to by \c Rename. Note that this is only set for
/// deserialized attributes or inferred attributes from ObjectiveC code.
/// \c ValueDecl::getRenamedDecl should be used to find the declaration
/// corresponding to \c Rename.
ValueDecl *RenameDecl;

/// Indicates when the symbol was introduced.
const Optional<llvm::VersionTuple> Introduced;

Expand Down Expand Up @@ -746,6 +752,11 @@ class AvailableAttr : public DeclAttribute {
llvm::VersionTuple Obsoleted
= llvm::VersionTuple());

/// Create an AvailableAttr that indicates the given \p AsyncFunc should be
/// preferentially used in async contexts
static AvailableAttr *createForAlternative(ASTContext &C,
AbstractFunctionDecl *AsyncFunc);

AvailableAttr *clone(ASTContext &C, bool implicit) const;

static bool classof(const DeclAttribute *DA) {
Expand Down Expand Up @@ -2021,57 +2032,6 @@ class TransposeAttr final
}
};

/// The `@completionHandlerAsync` attribute marks a function as having an async
/// alternative, optionally providing a name (for cases when the alternative
/// has a different name).
class CompletionHandlerAsyncAttr final : public DeclAttribute {
public:
/// Reference to the async alternative function. Only set for deserialized
/// attributes or inferred attributes from ObjectiveC code.
AbstractFunctionDecl *AsyncFunctionDecl;

/// DeclName of the async function in the attribute. Only set from actual
/// Swift code, deserialization/ObjectiveC imports will set the decl instead.
const DeclNameRef AsyncFunctionName;

/// Source location of the async function name in the attribute
const SourceLoc AsyncFunctionNameLoc;

/// The index of the completion handler
const size_t CompletionHandlerIndex;

/// Source location of the completion handler index passed to the index
const SourceLoc CompletionHandlerIndexLoc;

CompletionHandlerAsyncAttr(DeclNameRef asyncFunctionName,
SourceLoc asyncFunctionNameLoc,
size_t completionHandlerIndex,
SourceLoc completionHandlerIndexLoc,
SourceLoc atLoc, SourceRange range)
: DeclAttribute(DAK_CompletionHandlerAsync, atLoc, range,
/*implicit*/ false),
AsyncFunctionDecl(nullptr),
AsyncFunctionName(asyncFunctionName),
AsyncFunctionNameLoc(asyncFunctionNameLoc),
CompletionHandlerIndex(completionHandlerIndex),
CompletionHandlerIndexLoc(completionHandlerIndexLoc) {}

CompletionHandlerAsyncAttr(AbstractFunctionDecl &asyncFunctionDecl,
size_t completionHandlerIndex,
SourceLoc completionHandlerIndexLoc,
SourceLoc atLoc, SourceRange range,
bool implicit)
: DeclAttribute(DAK_CompletionHandlerAsync, atLoc, range,
implicit),
AsyncFunctionDecl(&asyncFunctionDecl) ,
CompletionHandlerIndex(completionHandlerIndex),
CompletionHandlerIndexLoc(completionHandlerIndexLoc) {}

static bool classof(const DeclAttribute *DA) {
return DA->getKind() == DAK_CompletionHandlerAsync;
}
};

/// Attributes that may be applied to declarations.
class DeclAttributes {
/// Linked list of declaration attributes.
Expand Down
2 changes: 2 additions & 0 deletions include/swift/AST/ClangModuleLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ class ClangModuleLoader : public ModuleLoader {
instantiateCXXFunctionTemplate(ASTContext &ctx,
clang::FunctionTemplateDecl *func,
SubstitutionMap subst) = 0;

virtual bool isCXXMethodMutating(const clang::CXXMethodDecl *method) = 0;
};

/// Describes a C++ template instantiation error.
Expand Down
15 changes: 14 additions & 1 deletion include/swift/AST/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -6196,9 +6196,22 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
/// constructor.
bool hasDynamicSelfResult() const;


/// The async function marked as the alternative to this function, if any.
AbstractFunctionDecl *getAsyncAlternative() const;

/// If \p asyncAlternative is set, then compare its parameters to this
/// (presumed synchronous) function's parameters to find the index of the
/// completion handler parameter. This should be the the only missing
/// parameter in \p asyncAlternative, ignoring defaulted parameters if they
/// have the same label. It must have a void-returning function type and be
/// attributed with @escaping but not @autoclosure.
///
/// Returns the last index of the parameter that looks like a completion
/// handler if \p asyncAlternative is not set (with the same conditions on
/// its type as above).
Optional<unsigned> findPotentialCompletionHandlerParam(
AbstractFunctionDecl *asyncAlternative = nullptr) const;

/// Determine whether this function is implicitly known to have its
/// parameters of function type be @_unsafeSendable.
///
Expand Down
5 changes: 0 additions & 5 deletions include/swift/AST/DiagnosticsParse.def
Original file line number Diff line number Diff line change
Expand Up @@ -1703,11 +1703,6 @@ ERROR(sil_inst_autodiff_invalid_witness_generic_signature,PointsToFirstBadToken,
"parameters as original function generic signature '%1'",
(StringRef, StringRef))

// completionHandlerAsync
ERROR(attr_completion_handler_async_invalid_name, none,
"argument of '%0' attribute must be an identifier or full function name",
(StringRef))

//------------------------------------------------------------------------------
// MARK: Generics parsing diagnostics
//------------------------------------------------------------------------------
Expand Down
32 changes: 6 additions & 26 deletions include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -1923,6 +1923,12 @@ ERROR(type_cannot_conform, none,
NOTE(only_concrete_types_conform_to_protocols,none,
"only concrete types such as structs, enums and classes can conform to protocols",
())
NOTE(nonsendable_function_type,none,
"a function type must be marked '@Sendable' to conform to 'Sendable'", ())
NOTE(nonsendable_tuple_type,none,
"a tuple type must be composed of 'Sendable' elements to conform to "
"'Sendable'", ())

NOTE(required_by_opaque_return,none,
"required by opaque return type of %0 %1", (DescriptiveDeclKind, DeclName))
NOTE(required_by_decl,none,
Expand Down Expand Up @@ -3387,32 +3393,6 @@ ERROR(diff_params_clause_param_not_differentiable,none,
"'Differentiable', but %0 does not conform to 'Differentiable'", (Type))

// completionHanderAsync attribute
ERROR(attr_completion_handler_async_handler_not_func,none,
"'%0' should be attached to a non-async completion-handler function",
(DeclAttribute))

NOTE(note_attr_function_declared_async,none,
"function declared async", ())

NOTE(note_attr_completion_function_must_return_void,none,
"completion handler must return 'Void'", ())

NOTE(note_attr_completion_handler_async_type_is_not_function,none,
"%0 is not a function type", (Type))

NOTE(note_attr_completion_handler_async_handler_attr_req,none,
"completion handler must%select{ not|}0 be '@%1'",
(bool, StringRef))

ERROR(attr_completion_handler_async_handler_out_of_range,none,
"completion handler index out of range of the function parameters", ())

ERROR(attr_completion_handler_async_ambiguous_function,none,
"ambiguous '%0' async function %1", (DeclAttribute, DeclNameRef))

ERROR(attr_completion_handler_async_no_suitable_function,none,
"no corresponding async function named %0", (DeclNameRef))

WARNING(warn_use_async_alternative,none,
"consider using asynchronous alternative function",())

Expand Down
Loading