Without this hack the call will leave a stack frame around (not tail
call optimized) and blow the stack if we call switch_task often enough.
Ideally, clang would emit this call as `musttail` but currently it does
not.
rdar://76652421
When compiling with allow errors, it's possible to have invalid
inherited types - both null and ErrorType.
Cleaned up the tests a little - moved the majority of
Frontend/allow-errors.swift into separate files in
Serialization/AllowErrors and use split_file.py instead of #defines.
Resolves rdar://78048470
If a base class initializer was not generic but had a contextual 'where'
clause, we would unconditionally inherit the 'where' clause in the override as
part of the fix for another issue (https://bugs.swift.org/browse/SR-14118).
However, it is possible that some of those requirements are satisfied by
the derived class itself. For example:
class Base<T> {
init() where T : AnyObject {}
}
class Derived : Base<AnyObject> {}
In this case, the implicit override Derived.init() has no generic requirements
at all. We used to assert because we would create a GSB with no generic
parameters.
It was also possible for a base class initializer to have generic
requirements that are not satisfied by the derived class. In this case,
we need to drop the initializer from consideration altogether.
While I'm here, I improved the comments in computeDesignatedInitOverrideSignature(),
which is the new name for configureGenericDesignatedInitOverride().
Fixes rdar://problem/77285618.
When adding an async alternative, add the @completionHandlerAsync
attribute to the sync function. Check for this attribute in addition to
the name check, ie. convert a call if the callee has either
@completionHandlerAsync or a name that is completion-handler-like name.
The addition of the attribute is currently gated behind the experimental
concurrency flag.
Resolves rdar://77486504
Previously we were unconditionally dropping a
return statement if it was the last node, which
could cause us to inadvertently drop the result
expression as well. Instead, only drop bare
'return' statements.
rdar://77789360
It's possible the user has already written an
explicit return for the call to the completion
handler. In that case, avoid adding another return.
rdar://77789360
This patch to the Clang Importer avoids an assert by detecting when an
IndirectField belongs to an anonymous union that is not importable. How
it does this is by determining if an IndirectFieldDecl's anonymous
parent field is non-importable (based on isCxxRecordImportable) and if
so skips importing the IndirectFieldDecl.
This avoids the mentioned assert because makeIndirectFieldAccessors
expects a FieldDecl of __Unnamed_union___Anonymous_field that is only
populated when the top-level union is imported from an
IndirectFieldDecl's parent. IndirectFieldDecls for the members of an
anonymous union are dependent on their parent and should not be imported
if their parent can not also be imported.
This corner case can happen in cases when an anonymous union contains an
ARC pointer, which results in a non-trivial but also inaccessible dtor.
This mechanism allows the compiler to use a backup interface file to build into a binary module when
a corresponding interface file from the SDK is failing for whatever reasons. This mechansim should be entirely opaque
to end users except several diagnostic messages communicating backup interfaces are used.
Part of rdar://77676064
Previously we would drop comments between nodes in
a BraceStmt, as we printed each node out individually.
To remedy this, always make sure we scan backwards
to find any preceding comments attached to a node,
and also keep track of any SourceLocs which we
don't print, but may have comments attached which
we want to preserve.
rdar://77401810
When converting a call or function, rename declarations such that
redeclaration errors and shadowing are avoided. In some cases this will
be overly conservative, but since any renamed variable can be fixed with
edit all in scope, this is preferred over causing redeclaration errors
or possible shadowing.
Resolves rdar://73973517
Attempting to conform an actor to a global actor isolated protocol
creates a clash in isolation when members are accessed so, let's
detect and diagnose that.
Resolves: rdar://75849035
We need to introduce some proper synchronization between the @main task and the ObjC
completion handler to make this reliably deterministic. rdar://77934626
This change separates emission of the diagnostics like:
```
unnecessary check for 'Platform'; enclosing scope ensures guard will always be true
```
from the deployment target of the current compilation. Instead, these diagnostics will only be emitted if the enclosing scope guard is explicitly specified by the user with an `#availability` attribute.
This fixes cases like the following:
```
@available(macOS 11.0, *)
class Foo {
func foo() {
if #available(macOS 11.1, *) {}
}
}
```
Compiling this with `-target x86_64-apple-macos11.2` results in:
```
warning: unnecessary check for 'macOS'; enclosing scope ensures guard will always be true
if #available(macOS 11.1, *) {}
.../test.swift:2:7: note: enclosing scope here
class Foo {
```
Even though in source-code the enclosing scope (`Foo`) of this guard does not ensure it will always be true.
This happens because availability range is propagated by intersecting ranges top-down from the root `TypeRefinementContext`, which is defined by the deployment target, causing the availability range on class `Foo` to become `11.2`.
Users may be sharing the same piece of source-code across different projects with their own respective deployment targets which makes such target-dependent warnings confusing at some times, and not-useful at others.
We should rather have the warning simply reflect what is in the source.
Resolves rdar://77607488
Our LLVM backend is supposed to have a build-time optimization where we
hash the IR and do not proceed with LLVM code generation if the hash
matches the one we last used to emit any products. This has never quite
worked for a variety of reasons - we fixed a number of those reasons in
https://github.com/apple/swift/pull/31106 but this test remained flaky
for its entire lifetime.
It's really not worth all the trouble to keep investigating this, so I'm
removing this test.
rdar://77654695
When a function’s completion handler is being passed to another function and the function that the completion handler is being declared in is converted to async, replace the call to the completion handler by a `return` statement.
For example:
```swift
func foo(completion: (String) -> Void) {
bar(completion)
}
```
becomes
```swift
func foo() async -> String {
return await bar()
}
```
Previously, we were calling the completion handler, which no longer exists in the newly created `async` function.
* Rework YieldingContinuation to service values in a buffered fashion
* Fix word size calculation for locks
* Handle terminal states and finished/failed storage
* Wrap yielding continuation into a more featureful type for better ergonomics
* Hope springs eternal, maybe windows works with this?
* Prevent value overflows at .max limits
* Add a cancellation handler
* Fix series tests missing continuation parameters
* Fix series tests for mutable itertaors
* Rename to a more general name for Series's inner continuation type
* Whitespace fixes and add more commentary about public functions on Series
* Restore YieldingContinuation for now with deprecations to favor Series
* Ensure onCancel is invoked in deinit phases, and eliminate a potential for double cancellation
* Make sure ThrowingSeries has the same nonmutating setter for onCancel as Series
* Add a swath of more unit tests that exersize cancellation behavior as well as throwing behaviors
* Remove work-around for async testing
* Fixup do/catch range to properly handle ThrowingSeries test
* Address naming consistency of resume result function
* Adopt the async main test setup
* More migration of tests to new async mechanisms
* Handle the double finish/throw case
* Ensure the dependency on Dispatch is built for the series tests (due to semaphore usage)
* Add import-libdispatch to run command for Series tests
* Use non-combine based timeout intervals (portable to linux) for dispatch semaphore
* Rename Series -> AsyncStream and resume functions to just yield, and correct a missing default Element.self value
* Fix missing naming change issue for yielding an error on AsyncThrowingStream
* Remove argument label of buffering from tests
* Extract buffer and throwing variants into their own file
* Slightly refactor for only needing to store the producer instead of producer and cancel
* Rename onCancel to onTermination
* Convert handler access into a function pair
* Add finished states to the termination handler event pipeline and a disambiguation enum to identify finish versus cancel
* Ensure all termination happens before event propigation (and outside of the locks) and warn against requirements for locking on terminate and enqueue
* Modified to use Deque to back the storage and move the storage to inner types; overall perf went from 200kE/sec to over 1ME/sec
* Update stdlib/public/Concurrency/AsyncStream.swift
Co-authored-by: Doug Gregor <dgregor@apple.com>
* Update stdlib/public/Concurrency/AsyncThrowingStream.swift
Co-authored-by: Doug Gregor <dgregor@apple.com>
* Update stdlib/public/Concurrency/AsyncStream.swift
Co-authored-by: Joseph Heck <heckj@mac.com>
* Update stdlib/public/Concurrency/AsyncThrowingStream.swift
Co-authored-by: Joseph Heck <heckj@mac.com>
* Update stdlib/public/Concurrency/AsyncThrowingStream.swift
Co-authored-by: Joseph Heck <heckj@mac.com>
* Update stdlib/public/Concurrency/AsyncThrowingStream.swift
Co-authored-by: Joseph Heck <heckj@mac.com>
* Update stdlib/public/Concurrency/AsyncStream.swift
Co-authored-by: Joseph Heck <heckj@mac.com>
* Update stdlib/public/Concurrency/AsyncThrowingStream.swift
Co-authored-by: Joseph Heck <heckj@mac.com>
* Remove local cruft for overlay disabling
* Remove local cruft for Dispatch overlay work
* Remove potential ABI impact for adding Deque
Co-authored-by: Doug Gregor <dgregor@apple.com>
Co-authored-by: Joseph Heck <heckj@mac.com>