Commit Graph

120591 Commits

Author SHA1 Message Date
Holly Borla
c305b57ba3 Merge pull request #37407 from hborla/wrapped-parameter-serialization
[Property Wrappers] Fix a crash in merge-modules with wrapped parameters.
2021-05-13 15:48:46 -07:00
swift-ci
e87f237ea8 Merge pull request #37397 from jirid/SR-14453-remove-enable-swiftcall 2021-05-13 15:46:45 -07:00
fwcd
da77e61d76 Remove deprecation tag from use_of_qq_on_non_optional_value 2021-05-14 00:42:32 +02:00
Pavel Yaskevich
3823966e01 Merge pull request #37395 from xedin/rdar-75849035
[Concurrency] Actor cannot conform to global actor isolated protocol
2021-05-13 13:44:07 -07:00
Hamish Knight
ef318a16cb Merge pull request #37387 from hamishknight/any-comments 2021-05-13 21:09:26 +01:00
Xi Ge
42a89af00c Merge pull request #37355 from nkcsgexi/77676064-flag
Frontend: teach the compiler to use a backup directory to find .swiftinterface files to compile
2021-05-13 11:45:32 -07:00
Puyan Lotfi
7d7a6c6bcc [cxx-interop] Detect IndirectFields nested in non-importable anon-unions
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.
2021-05-13 07:31:33 -10:00
Holly Borla
df43914406 [Property Wrappers] Return early from computing the backing property type
if the wrapped property came from a module file.
2021-05-13 09:16:38 -07:00
3405691582
eb945c81f2 [concurrency] Provide missing header file. (#37004)
HAVE_PTHREAD_H is supplied in this config file.

The `__has_include` pattern is discouraged, but there is no other way of
conditioning on `pthread_np.h`, which is required for `pthread_main_np`
on OpenBSD. Therefore, use it, but call it out in a comment.
2021-05-13 09:13:36 -07:00
Xi Ge
b6cd513534 Frontend: teach the compiler to use a backup directory to find .swiftinterface files to compile
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
2021-05-13 09:11:45 -07:00
QuietMisdreavus
51c96a4df0 Merge pull request #37351 from apple/QuietMisdreavus/protocol-req-sourceOrigin
[SymbolGraph] add sourceOrigin field for symbols implementing remote protocol requirements
2021-05-13 09:06:37 -07:00
swift-ci
63b85fdee5 Merge pull request #37401 from aschwaighofer/mark_async_stream_as_executable_test 2021-05-13 08:52:49 -07:00
Eric Miotto
c3f8dacdf0 [Build] allow to generate symbols for a subset of binaries (#37120)
This would be needed to reduce overall build times in scenarios when
generating symbols for all binaries is too expensive and/or not needed.

At the same time, introduce tests around the logic that handles symbols.

Addresses rdar://76865276
2021-05-13 07:32:41 -07:00
Arnold Schwaighofer
f82edf72c7 Mark test async_stream as executable_test
It fails on non_executable bots.

rdar://77963528
2021-05-13 06:26:10 -07:00
Hamish Knight
8cb319b640 [Refactoring] Preserve comments in async transform
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
2021-05-13 14:16:27 +01:00
Hamish Knight
3a7a880fa0 [Refactoring] Store SourceFile on AsyncConverter 2021-05-13 14:16:26 +01:00
Ben Barham
a2ce02a639 Merge pull request #37302 from bnbarham/async-shadowing
[Refactoring] Avoid redeclarations or shadowing in async refactored code
2021-05-13 22:23:30 +10:00
Ben Barham
8569c8a51b [Refactoring] Avoid redeclarations or shadowing in async refactored code
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
2021-05-13 17:48:41 +10:00
Robert Widmann
724e015dae Merge pull request #37386 from CodaFi/ir-ony
Delete Flaky IR Hash Test
2021-05-12 19:11:03 -07:00
Jiri Dutkevic
d4e5014fc8 [SR-14453] Removed unused option enable_swiftcall. 2021-05-12 17:42:47 -07:00
Mishal Shah
d9e5895941 Merge pull request #37390 from apple/shahmishal/update-checkout-scheme-concurrency-5.5-abi-2
Add scheme for concurrency-5.5-abi-2
2021-05-12 16:56:37 -07:00
Pavel Yaskevich
ecfff76552 [Concurrency] Actor cannot conform to global actor isolated protocol
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
2021-05-12 16:00:25 -07:00
Artem Chikin
364f154fff Merge pull request #37350 from artemcm/DeployTargetIndependentAvailabilityDiagnostic
Warn about unnecessary availability independently from the deployment target
2021-05-12 15:39:45 -07:00
Joe Groff
74736c75ba Disable flaky test/Concurrency/Runtime/objc_async.swift test.
We need to introduce some proper synchronization between the @main task and the ObjC
completion handler to make this reliably deterministic. rdar://77934626
2021-05-12 15:24:40 -07:00
Andrew Trick
3b02a39d94 Merge pull request #37358 from atrick/fix-refactor-script
Fix refactor-check-compiles.py for python3
2021-05-12 14:47:02 -07:00
Mishal Shah
6ea3163971 Add scheme for concurrency-5.5-abi-2 2021-05-12 13:09:02 -07:00
Artem Chikin
5146bd5191 Report unnecessary availability warnings independently from the deployment target
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
2021-05-12 11:57:57 -07:00
Slava Pestov
c74c66d479 Merge pull request #37374 from slavapestov/fix-perf-regressions
Fix a couple of performance regressions
2021-05-12 13:07:42 -04:00
Robert Widmann
7c360ff1d8 Delete Flaky IR Hash Test
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
2021-05-12 10:02:48 -07:00
Eric Miotto
1e5f790d06 [Build] allow to generate symbols for a subset of binaries
This would be needed to reduce overall build times in scenarios when
generating symbols for all binaries is too expensive and/or not needed.

Addresses rdar://76865276
2021-05-12 10:02:41 -07:00
Eric Miotto
b903a6cc65 Put symbol generation logic under test
...before adding the logic to filter paths

In particular:
* print the list of files that `cpio` copies, so we can test explicitly
  which files end up in the symroot (and also see those when asking for
  a toolchain in PR testing)
* use `find` instead of `grep` to filter files we want symbols generated
  for -- this is to avoid the script failing when there are no symbol to
  process, especially in lit tests
* remove an unnecessary check for `swift-api-digester` -- this is now a
  symlink to `swift-frontend` and we only process regular files.

Supports rdar://76865276
2021-05-12 09:52:30 -07:00
Holly Borla
eeeea25695 Merge pull request #37282 from hborla/propagate-async-to-closure
[CSApply] NFC: Clean up some duplicated logic for propagating `async` from contextual types to closure types.
2021-05-12 08:56:08 -07:00
Holly Borla
e1591314cf Merge pull request #37380 from hborla/property-wrapper-inference-crash
[ConstraintSystem] Fix a constraint system crash with property wrapper inference using the $ syntax.
2021-05-12 08:55:51 -07:00
Alex Hoppen
65b9a1c1fc Merge pull request #37314 from ahoppen/pr/refactor-to-async-variable-callback
[Refactoring] Support refactoring calls to async if a variable or function is used as completion handler
2021-05-12 16:57:34 +02:00
Kim de Vos
779365cca2 [SwiftSyntax]: Use check for suffix instead of contains when checking for token
Syntax kind should end with token not contain it before it is considered as a token
2021-05-12 12:45:45 +02:00
Pavel Yaskevich
d500f9cc8a Merge pull request #37373 from xedin/rdar-76058892
[CSSimplify] Increase fix impact when passing closure to a non-function type parameter
swift-DEVELOPMENT-SNAPSHOT-2021-05-12-a
2021-05-12 00:30:17 -07:00
Alex Hoppen
f1455c29bf [Refactoring] Check that code compiles after refatorings in variable_as_callback.swift 2021-05-12 09:26:42 +02:00
Alex Hoppen
effae5f2a9 [Refactoring] Remove the VARIABLE-COMPLETION-HANDLER suffix from checks in variable_as_callback.swift
These were a legacy from when the tests lived in `basic.swift`. They are no longer needed.
2021-05-12 09:26:42 +02:00
Alex Hoppen
32ceb24b6c [Refactoring] Promote call to refactored completion handlers to return
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.
2021-05-12 09:26:25 +02:00
Philippe Hausler
4886bd56e4 [Concurrency] AsyncStream and AsyncThrowingStream
* 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>
2021-05-11 21:41:33 -07:00
Xi Ge
93eae81b04 Merge pull request #37375 from nkcsgexi/diagnose-new-driver-only-options
Driver: diagnose options that are only supported in the new driver
2021-05-11 19:05:30 -07:00
Holly Borla
c297070106 [Diagnostics] Always use the parameter name for closure parameter diagnostics,
because the $ prefix does not indicate that the parameter is anonymous.
2021-05-11 18:30:27 -07:00
Holly Borla
ef58f6a827 [ConstraintSystem] If the contextual parameter type doesn't exist when
resolving a closure, create a new type variable for inferred property
wrapper types.
2021-05-11 18:26:22 -07:00
fredriss
3ed11125f3 Merge pull request #37325 from fredriss/async-task-id
[Concurrency] Add a unique Task ID to AsyncTask
2021-05-11 17:59:47 -07:00
Xi Ge
01b1aea958 Driver: diagnose options that are only supported in the new driver 2021-05-11 16:28:57 -07:00
Slava Pestov
161c837a9b AST: Avoid expensive calls to getAttachedPropertyWrappers()
Check for the presence of a CustomAttr first, before calling into the
request evaluator.

Also clean up the logic a tiny bit.
2021-05-11 18:42:26 -04:00
Pavel Yaskevich
c346bbd514 [Diagnostics] Point out where anonymous closure parameters are used in a multi-statement closure 2021-05-11 15:07:44 -07:00
Pavel Yaskevich
493ad7c8fa [Diagnostics] NFC: Re-phrase reference to unused closure parameter in extraneous arguments diagnostic 2021-05-11 15:07:17 -07:00
Pavel Yaskevich
7ce8a44f6d [CSSimplify] Increase fix impact when passing closure to a non-function type parameter
In overloaded context it's possible that there is an overload that
expects a closure but it can have other issues e.g. different number
of parameters, so in order to pick a better solution let's always
increase a score for overloads where closure is matched against a
non-function type parameter.
2021-05-11 15:07:17 -07:00
Arnold Schwaighofer
bd010c3998 Merge pull request #37369 from aschwaighofer/availability_macro_concurrency_tests
Use availability macro insteada of macOS 9999 in Concurrency tests
swift-DEVELOPMENT-SNAPSHOT-2021-05-11-a
2021-05-11 14:01:15 -07:00