Commit Graph

46922 Commits

Author SHA1 Message Date
Doug Gregor
b88e678694 [SE-0306] Disable actor inheritance.
Actor inheritance was removed in the second revision of SE-0306. Remove
the ability to inherit actors.

Note that this doesn't fully eliminate all vestigates of inheritance
from actors. There are simplifications that need to be performed
still, e.g., there's no need to distinguish
designated/convenience/required initializers. That will follow.
2021-04-23 15:08:57 -07:00
Arnold Schwaighofer
e50d5c313c Merge pull request #37039 from aschwaighofer/fix_async_dyn_repl_compiler
IRGen: Fix async dynamic replacements
2021-04-23 13:26:15 -07:00
Alex Hoppen
aa78216bd5 Merge pull request #37011 from ahoppen/pr/deserialization-error
[Deserialization] Fix error when typealias required by protocol refers to type in @_implementationOnly module
2021-04-23 21:35:53 +02:00
Alex Hoppen
727c11dc4f Merge pull request #37037 from ahoppen/pr/vararg-label-completion
[CodeCompletion] Fix code suggestions for arguments in vararg followed by normal arg
2021-04-23 21:33:06 +02:00
swift-ci
2b435f9839 Merge pull request #37042 from aschwaighofer/reenable_test_interpreter_async_arm64e 2021-04-23 12:17:38 -07:00
Mishal Shah
7169ab1da2 Enable import_as_member.swift test (#37031) 2021-04-23 11:58:24 -07:00
QuietMisdreavus
7a57818ad7 Merge pull request #37017 from apple/revert-36542-QuietMisdreavus/supplementary-symbol-graph
Revert "[Driver][Frontend] add the symbol graph dir to the supplementary file map"
2021-04-23 11:27:15 -06:00
Arnold Schwaighofer
87e7c1c655 Re-enable test/Interpreter/async.swift on arm64e 2021-04-23 10:01:26 -07:00
Pavel Yaskevich
5a7fd6825d Merge pull request #36732 from Strieker/composed_property_wrapper_improved_error_handling
Improved error handling for composed property wrapper mismatches
2021-04-23 09:22:21 -07:00
Arnold Schwaighofer
1f890dc6a2 IRGen: Fix async dynamic replacements
We need to emit a full async suspend sequence when calling the
replacement.

rdar://77072724
2021-04-23 09:03:51 -07:00
eeckstein
40b5aa0d0d Merge pull request #37036 from eeckstein/fix-open-archetype-mapping
SILModule: track opened archetypes per function.
2021-04-23 18:03:16 +02:00
Alex Hoppen
2392e79ec9 [CodeCompletion] Fix code suggestions for arguments in vararg followed by normal arg
For a function and call like
```swift
func test(_: Foo..., yArg: Baz) {}
test(.bar, #^COMPLETE^#)
```
the parser matches the code completion token to the `yArg` with a missing label, because this way all parameters are provided. However, because of this we don’t suggest any variables that could belong the the previous vararg list.

To fix this, if we encounter such a situation (argument without label after vararg), manually adjust the code completion token’s position in params to belong to the vararg list.

Fixes rdar://76977325 [SR-14515]
2021-04-23 17:23:57 +02:00
Erik Eckstein
eecb9fa975 SILModule: track opened archetypes per function.
In theory we could map opened archetypes per module because opened archetypes _should_ be unique across the module.
But currently in some rare cases SILGen re-uses the same opened archetype in multiple functions.
The fix is to add the SILFunction to the map's key.
That also requires that we update the map whenever instructions are moved from one function to another.

This fixes a compiler crash.

rdar://76916931
2021-04-23 14:13:26 +02:00
Doug Gregor
7cc19b5807 [SE-0306] Require 'nonisolated' on lets for synchronous cross-actor access. 2021-04-23 02:20:35 -07:00
Yuta Saito
619226b480 Fix calling convention mismatch on Builtin.getCurrentAsyncTask (#37008)
* Add explicit calling convention on builtin GetCurrentTask

This builtin function emits a call of swift_task_getCurrent, and user
code can declare the same name function with slightly different
signature at LLVM level (data size should be same) using @_silgen_name.
In that case, IRGen insert cast inst to cast the function to the
expected signature. But this cast inst drops calling convention info, so
call inst was emitted without swiftcc.

This patch changed to emit a call of swift_task_getCurrent with the
explicit calling convention.

* Add test case to ensure builtin function cc when conflict
2021-04-23 09:35:37 +01:00
Ben Barham
55dc7c1c11 [Tests] Do not ignore swiftsourceinfo by default in lit tests
This was added as a default in b103997c29,
with the reasoning that users do not have .swiftsourceinfo for the
stdlib. A later change (51d6243d24) then
avoids emitting .swiftsourceinfo for the stdlib at all, so this is no
longer an issue.
2021-04-23 13:36:46 +10:00
Mishal Shah
b5a01ba5e0 Support for x86_64 watchOS simulator
* Start testing watchOS simulator x86_64 and i386 by default

Users will require to install watchOS 6.2 or older simulator to support i386.

1. Install watchOS 6.2 or older simulator (Xcode -> Preferences -> Components -> Simulators).
2. Create a 32-bit watchOS device.
3. Run:
`xcrun simctl create 'Apple Watch Series 2 - 42mm' com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-2-42mm com.apple.CoreSimulator.SimRuntime.watchOS-6-2`
2021-04-22 20:06:17 -07:00
swift-ci
1e63681009 Merge pull request #37021 from apple/ktoso-patch-3 2021-04-22 18:52:10 -07:00
swift-ci
3c61374ff5 Merge pull request #37019 from DougGregor/inherit-actor-context-feature 2021-04-22 18:37:12 -07:00
Artem Chikin
5cb92278ab Merge pull request #37005 from artemcm/OldSDKNoConcurrency
Verify that `_Concurrency` *can* be imported on implicit import
2021-04-22 17:03:58 -07:00
Alexis Laferrière
c0394f6421 Merge pull request #36996 from xymus/lib-access-level-spi-in-api
[Sema] Allow SPI use in API for a module that is completely SPI
2021-04-22 16:54:49 -07:00
Konrad `ktoso` Malawski
ff2b2ce3b9 Update async_taskgroup_asynciterator_semantics.swift 2021-04-23 08:13:33 +09:00
Konrad `ktoso` Malawski
48ddcdcbd2 [TaskGroup] add simple test to group asynciterator test
Simple additional test, not because it's unexpected but to document what we're expecting.
2021-04-23 08:07:12 +09:00
Doug Gregor
cdd6ad8bfd Introduce a feature for @_inheritActorContext
Add a feature for this new attribute, and make sure we use the feature
guard for functions that use it, e.g., the new `async`.

Finishes rdar://76927008.
2021-04-22 15:49:48 -07:00
Artem Chikin
f92abb8c81 Verify that _Concurrency *can* be imported on implicit import.
In case the compiler is used with concurrency features enabled (by-default or otherwise), and an older SDK is used which does not include the `_Concurrency` module, do not load this module implicitly. Instead, emit a diagnostic indicating that no such module is found.

rdar://76967260
2021-04-22 13:46:59 -07:00
Victoria Mitchell
87fe71ec5a fix SymbolGraph/EmitWhileBuilding output map
the new driver fails when running this test, because the file map and
the command-line specify the same module output for both the individual
swift file and the module as a whole
2021-04-22 14:12:33 -06:00
Doug Gregor
623e54f45c Merge pull request #37007 from DougGregor/async-operation
[Concurrency] Add "async" operation for continuing work asynchronously.
2021-04-22 12:00:16 -07:00
Strieker
4e2b67cbae [NFC] Resolved merge conflict in CSSimplify.cpp after making changes to improve error handling for composed wrapped value mismatches 2021-04-22 11:49:21 -07:00
Strieker
b732319538 [NFC] Fixed and added property wrapper tests. 2021-04-22 11:31:41 -07:00
QuietMisdreavus
419483863f Revert "[Driver][Frontend] add the symbol graph dir to the supplementary file map" 2021-04-22 12:20:14 -06:00
Doug Gregor
fbc62373e0 Work around lack of qos_class_self in non-Darwin libdispatch 2021-04-22 09:11:00 -07:00
Alex Hoppen
16adf76b68 Merge pull request #36994 from ahoppen/pr/refactor-protocol-requirement-async
[Refactoring] Fix crash when refactoring protocol requirement to async
2021-04-22 17:02:44 +02:00
Alex Hoppen
ab2fdbbb74 [Deserialization] Fix error when typealias required by protocol refers to type in @_implementationOnly module
In the added test case, the `typealias` refers to the `HiddenStruct` type in the private module, which is imported as `@_implementationOnly`. Because the import is `@_implementationOnly`, during deserialization, we don’t import the private module and hence any reference to the `HiddenStruct` type fails. In the common deserialization code path, this causes us to skip over the `typealias` member. However, when creating the protocol conformance, we assume that we can resolve the type to which the `typealias` refers and thus we are crashing.

If `LangOpts.EnableDeserializationRecovery` is set to `true`, we should do our best to recover from such failures so this patch makes the deserialization failure handling more graceful and resolve the right-hand side of the `typealias` as an `ErrorType`.

Fixes rdar://72891807
2021-04-22 17:01:10 +02:00
David Zarzycki
a7c24c5347 Merge pull request #36990 from davezarzycki/pr36990
[Testing] Unbreak minimal Swift builds
2021-04-22 06:22:29 -04:00
Alex Hoppen
9d62f9d4db [Refactoring] Fix crash when refactoring protocol requirement to async
When a function declaration has no body (e.g. because it’s a protocol requirement), we construct the range to replace by the `async` keyword as follows:
- Start: One character after the closing `)` (or potentially the `throws` keyword if it exists)
- End: Last token in the function declaration

Since the last token in the function declaration is the `)`, we end up with a range that has `End < Start`, which crashes when trying to print the range.

If the function has no body, we should just use the range’s start location as the end location to construct an empty range.

Fixes rdar://76677035
2021-04-22 11:56:34 +02:00
Doug Gregor
90c1fece9e Merge pull request #37002 from DougGregor/inherit-actor-context-attr 2021-04-21 23:10:56 -07:00
Doug Gregor
3c3f216be3 [Concurrency] Add "async" operation for continuing work asynchronously.
The `async` operation is a global function that initiates asynchronous
work on behalf of the synchronous code that calls it. Unlike `detach`,
`async` inherits priority, actor context, and other aspects of the
synchronous code that initiates it, making it a better "default"
operation for creating asynchronous work than `detach`. The `detach`
operation is still important for creating truly detached tasks that
can later be `await`'d or cancelled if needed.

Implements the main entry point for rdar://76927008.
2021-04-21 22:21:24 -07:00
Andrew Trick
ed8b1b25dd Merge pull request #36970 from atrick/destructure-conversion
CanonicalizeOSSA: Destructure canonicalization and conslidate borrow scope support for destructure
2021-04-21 19:50:00 -07:00
Doug Gregor
6928c3f1c9 Make sure that we perform the actor hop for @_inheritActorContext 2021-04-21 17:35:17 -07:00
Robert Widmann
ce7bdab9e4 Merge pull request #36752 from LucianoPAlmeida/SR-9425-enum-eq
[SR-9425][Sema] Use derived conformance as witness when possible for == operator of raw representable enums
2021-04-21 16:39:38 -07:00
Doug Gregor
b9f1e7f626 [Concurrency] Add @_inheritActorContext hidden parameter attribute.
This new attribute can be used on parameters of `@Sendable async` type
to indicate that the closures arguments passed to such parameters
should inherit the actor context where they are formed, which is not
the normal behavior for `@Sendable` closures.

Another part of rdar://76927008.
2021-04-21 15:23:27 -07:00
Andrew Trick
340feb41df CanonicalOSSALifetime: rewrite consolidateBorrowScope
It now handles looking through forwarding consumes such as
destructures.

Expected to be NFC since borrow consolidation is still disabled by
default.

TODO: Write unit tests for various forwarding consumes in addition to
destructure.
2021-04-21 14:39:48 -07:00
Slava Pestov
bfa690e121 Merge pull request #36403 from slavapestov/remove-synthesized-decls
Sema: Remove SourceFile::SynthesizedDecls
2021-04-21 15:11:13 -04:00
David Zarzycki
75087862e0 [Testing] Unbreak minimal Swift builds 2021-04-21 14:11:46 -04:00
Doug Gregor
e87505cb34 Merge pull request #36986 from DougGregor/data-race-checking-flags
[SILGen] Put actor data-race checking behind a flag.
2021-04-21 08:55:17 -07:00
nate-chandler
a0a60c1b65 Merge pull request #36932 from nate-chandler/wrangle/test/Concurrency/Runtime/async_task_yield.swift
[Test] Disabled two Concurrency tests for back deploy.
2021-04-21 08:34:40 -07:00
Alex Hoppen
6b5c03208d [SourceKit] Don’t transform type when printing if CurrentType can’t have members
Since 9ba892c we always transform `CurrentType` in `ASTPrinter` to be an interface type.

This causes issues when the variable type is a generic parameter type. Previously we had `CurrentType` set to a `PrimaryArchetypeType`. With the fix in d93ae06, we are mapping the archetype out of context to a `GenericParamType`. A `GenericParamType`, however, can’t have members, so we’re hitting an assertion when creating a `TypeTransformContext`. Since the entire type transformation in `printTransformedTypeWithOptions` is only affecting type members, we should be able to safely skip over the transformation if `CurrentType` can’t have any members.

Fixes rdar://76750555 [SR-14497]
2021-04-21 11:53:06 +02:00
Richard Wei
7e2d23896f Merge pull request #36974 from integralpro/SR-14290
[AutoDiff] Use correct debug scope for pullback trampoline block.
2021-04-21 01:02:05 -07:00
eeckstein
7611ecca2b Merge pull request #36975 from eeckstein/optimize-async-let
concurrency: make the startAsyncLet closure no-escaping
2021-04-21 08:50:17 +02:00
Doug Gregor
19a7fa6625 [SILGen] Put actor data-race checking behind a flag.
Introduce flags `-enable-actor-data-race-checks` and
`-disable-actor-data-race-checks` to enable/disable emission of code
that checks that we are on the correct actor. Default to `false` for
now but make it easy to enable in the future.
2021-04-20 22:30:53 -07:00