Commit Graph

2588 Commits

Author SHA1 Message Date
Pavel Yaskevich
b5930625be Merge pull request #74315 from xedin/rdar-129599097
[AST] `@preconcurrency` conformance applies to implied conformances a…
2024-06-13 16:30:02 -07:00
Kavon Farvardin
9eba052ab2 Merge pull request #74322 from kavon/se427-noimplicit-for-invertible
SE-427: Make conditional conformances to Copyable more explicit.
2024-06-12 22:03:49 -07:00
Kavon Farvardin
ec4a125f3e NCGenerics: ext's might not infer invertible req's
If the extension adds conformance to an invertible protocol, it's
confusing for people to also infer conditional requirements on the
generic parameters for those invertible protocols. This came up in the
review of SE-427.
2024-06-12 14:44:22 -07:00
Pavel Yaskevich
414295df96 [AST] @preconcurrency conformance applies to implied conformances as well
A `@preconcurrency` conformance to an inherited protocol should imply
`@preconcurrency` on its parents as well. For example:

```swift
protocol Parent {
  func a()
}

protocol Child: Parent {
  func b()
}

@MainActor
class Test: @preconcurrency Child {
  func a() {
  }

  func b() {
  }
}
```

`Test` conformance to `Parent` implied by its conformance to `Child`
should carry `@preconcurrency` and inject dynamic actor isolation checks
to witness of `a()`.

Resolves: https://github.com/apple/swift/issues/74294
Resolves: rdar://129599097
2024-06-11 15:52:41 -07:00
Mike Ash
b86fe88c43 [Runtime] Fix key argument indexing when checking invertible protocols.
Track the key argument index separately from the generic parameter index when performing the invertible protocol checking in _checkGenericRequirements. This keeps the indexing correct when a non-key argument is followed by a key argument.

rdar://128774651
2024-06-11 12:39:23 -04:00
nate-chandler
a2b2087a5e Merge pull request #74198 from nate-chandler/rdar128900124
[MoveOnly] Call mutating methods on existentials.
2024-06-10 11:29:45 -07:00
Nate Chandler
e2fcdb4524 [MoveOnlyAddressChecker] Handle init_exi_addr.
It's a pass-through for FSPL's purposes.

rdar://128900124
2024-06-06 19:04:41 -07:00
Alex Lorenz
5aa63fc93e Merge pull request #72634 from hyp/eng/android/ndk-overlay
[android] add an Android NDK Swift overlay
2024-06-05 19:35:13 -07:00
Pavel Yaskevich
e61671d9e4 Merge pull request #74130 from xedin/rdar-128667580
[IRGen] Strip marker protocols in a few more places
2024-06-05 08:47:53 -07:00
Pavel Yaskevich
5d243bd8a2 [IRGen] Move marker protocol stripping from mangleTypeSymbol to mangleTypeForFlatUniqueTypeRef
The original check introduced by https://github.com/apple/swift/pull/71855
is too broad. For concrete metadata we call the runtime demangler so
we need to strip off marker protocols when mangling that string and
`mangleTypeForReflection` already does that.
2024-06-04 21:58:59 -07:00
nate-chandler
23915e8075 Merge pull request #74109 from nate-chandler/rdar113142446
[ConsumeObjectChecker] End lifetimes at consumes.
2024-06-04 18:17:36 -07:00
Pavel Yaskevich
552749e2f3 [IRGen] Strip marker protocols when forming generic metadata requests
Without this might might end up with a single element protocol compositions
which are invalid.
2024-06-04 14:28:14 -07:00
Nate Chandler
cae89a9562 [ConsumeObjectChecker] End lifetimes at consumes.
The checker already verifies that no non-destroy consuming users occur
after any `move_value`s corresponding to `consume` operators applied to
a value.  There may, however, be _destroy_ users after it.

Previously, the checker did not shorten the lifetime from those destroys
up to `move_value`s that appear after those `move_value`s.  The result
was that the value's lifetime didn't end at the `consume`.

Here, the checker is fixed to rewrite the lifetimes so that they both
end at `consume`s and also maintain their lexical lifetimes on paths
away from the `consume`s.  This is done by using
`OwnedValueCanonicalization`/`CanonicalizeOSSALifetime`.

Specifically, it passes the `move_value`s that correspond to
source-level `consume`s as the `lexicalLifetimeEnds` to the
canonicalizer.  Typically, the canonicalizer retracts the lexical
lifetime of the value from its destroys.  When these `move_value`s are
specified, however, instead it retracts them from the lifetime boundary
obtained by maximizing the lifetime within its original lifetime while
maintaining the property that the lifetime ends at those `move_value`s.

rdar://113142446
2024-06-03 15:45:32 -07:00
Slava Pestov
23be369c0e SILGen: Update for PackElementExpr captures
Fixes https://github.com/apple/swift/issues/68941.
Fixes https://github.com/apple/swift/issues/69282.
Fixes https://github.com/apple/swift/issues/72153.
Fixes rdar://110711746.
Fixes rdar://119212867.
Fixes rdar://124202697.
2024-05-30 16:39:49 -04:00
Hamish Knight
63e685dce7 [test] Disable moveonly_swiftskell.swift for back deployment 2024-05-28 21:56:29 +01:00
Alex Lorenz
0f9a69c712 android test fixes 2024-05-28 12:59:26 -07:00
Konrad `ktoso` Malawski
7790609fc8 [Concurrency] Futher prevent crashes in legacy mode of isCurrentExecutor 2024-05-27 17:02:26 +09:00
Nate Chandler
8aec8966b9 [Test] Add regression test.
rdar://125864434
2024-05-23 12:26:43 -07:00
Kavon Farvardin
478d8a68d7 Merge pull request #73795 from kavon/expand-swiftskell-2
Test: add `List.reverse` and deinit testing to Swiftskell
2024-05-21 15:58:07 -07:00
Slava Pestov
fd5fe7dc63 test/Interpreter/element_archetype_captures.swift requires executable_test 2024-05-21 17:15:15 -04:00
Kavon Farvardin
6edc0ad1e9 Merge pull request #73777 from kavon/expand-swiftskell
Test: Implement a functional-style noncopyable List
2024-05-21 12:42:54 -07:00
Kavon Farvardin
a626c6b089 Test: more coverage for deinits 2024-05-21 11:18:46 -07:00
Kavon Farvardin
af9ce5f557 Test: convert empty method to borrowing getter
it's cheap enough that it can be a computed property; and gives more
test coverage.
2024-05-21 11:10:24 -07:00
Kavon Farvardin
a74e7ce677 Test: promote check to library 2024-05-21 11:09:26 -07:00
Kavon Farvardin
c4b47cb12e Test: implement reverse 2024-05-21 10:50:17 -07:00
Becca Royal-Gordon
d9912009b0 Merge pull request #73309 from beccadax/objcimpl-category-on-objc 2024-05-21 10:19:14 -07:00
Kavon Farvardin
b72824d167 Test: start implementing List 2024-05-20 22:53:45 -07:00
Kavon Farvardin
a361eabbb1 Test: get to "hello world" 2024-05-20 17:42:51 -07:00
Kavon Farvardin
59050f7526 Test: re-enable test 2024-05-20 17:37:52 -07:00
Becca Royal-Gordon
10ae9db27a Fix objcImpl resilience tests 2024-05-17 14:57:32 -07:00
Slava Pestov
4aa0008d74 SILGen: Rewrite captured local archetypes into primary archetypes
This implements support for autoclosures, closures and local functions
nested within a pack iteration for loop.

The combination of explicit closure expressions and pack expansion
expressions still needs some work.

Fixes #66917.
Fixes #69947.
Fixes rdar://113505724.
Fixes rdar://122293832.
Fixes rdar://124329076.
2024-05-17 17:45:05 -04:00
Joe Groff
10f9289ef8 Enable 'BorrowingSwitch' feature. 2024-05-14 07:31:59 -07:00
Kavon Farvardin
21b303ffb0 Merge pull request #73501 from kavon/ncgeneric-not-experimental
NCGenerics: it's not experimental
2024-05-08 16:29:03 -07:00
Kavon Farvardin
0420310623 NCGenerics: it's no longer "experimental"
resolves rdar://127701059
2024-05-08 10:49:12 -07:00
Slava Pestov
d5985158cb IRGen: Fix some more incorrect conformance checks 2024-05-07 10:37:49 -04:00
Slava Pestov
5d7e502299 IRGen: Fix incorrect conformance check
Fixes rdar://126637139, rdar://126779977.
2024-05-07 10:37:49 -04:00
Dario Rexin
db7580f842 Merge pull request #73426 from drexin/wip-127379960
[Runtime] Mask out spare bits after copying for Error in CVW
2024-05-06 13:59:37 -07:00
Alastair Houghton
6afdcd311f Merge pull request #72061 from al45tair/eng/PR-123504095
[Linux][Runtime][IRGen] Mark metadata sections as retained and support section GC.
2024-05-04 09:23:06 +01:00
Dario Rexin
101f8a4760 [Runtime] Mask out spare bits after copying for Error in CVW
rdar://127379960

When the spare bits of an Error objects are used to store tag bits, this caused the enum tag to be lost, which caused the wrong enum cases to be matched.
2024-05-03 12:26:43 -07:00
Dario Rexin
c1d732a9cb [IRGen] Fix alignment for imported C types in CVW
rdar://127279770

When an imported C type is over or under aligned, we did not use the alignment of the type, but computed the maximum alignment of its components, causing alignment issues in compact value witnesses.
2024-05-02 17:05:38 -07:00
Becca Royal-Gordon
981233ad37 Merge pull request #73128 from beccadax/objcimpl-resilient
Handle resilient stored properties in objcImpl
2024-04-30 20:50:33 -07:00
Becca Royal-Gordon
6d3e1ad794 Fix -target in several objcImpl tests 2024-04-30 12:03:46 -07:00
Becca Royal-Gordon
f94ed6d606 Hide objcImpl resilience support behind feature
Resilence support will require changes to the Objective-C runtime to expand support for metadata initialization functions. Add a separate experimental feature flag to help with staging that support in, and modify diagnostics to not suggest increasing the minimum deployment target for now.
2024-04-30 12:03:46 -07:00
Becca Royal-Gordon
427386feea Support resilient stored properties in objcImpl
When an @objc @implementation class requires the use of `ClassMetadataStrategy::Update` because some of its stored properties do not have fixed sizes, we adjust the direct field offsets during class realization by emitting a custom metadata update function which calls a new entry point in the Swift runtime. That entry point adjusts field offsets like `swift_updateClassMetadata2()`, but it only assumes that the class has Objective-C metadata, not Swift metadata.

This commit introduces an alternative mechanism which does the same thing without using any Swift-only metadata. It’s a rough implementation with important limitations:

• We’re currently using the field offset vector, which means that field offsets are being emitted into @objc @implementation classes; these will be removed.
• The new Swift runtime entry point duplicates a lot of `swift_updateClassMetadata2()`’s implementation; it will be refactored into something much smaller and more compact.
• Availability bounds for this feature have not yet been implemented.

Future commits in this PR will correct these issues.
2024-04-30 12:03:44 -07:00
Alastair Houghton
f9ec4793e9 [Test] Add linker_overridden feature.
When testing different linkers, it's sometimes useful to run the tests
with `SWIFT_DRIVER_TEST_OPTIONS=" -use-ld=<linker>"`.  If we do this,
it will break a handful of tests because they expect the compiler driver
to choose an appropriate linker automatically.

To avoid having these fail, detect when someone has done this, and
set a new feature, `linker_overridden`, then mark the tests in question
with `UNSUPPORTED: linker_overridden`.

rdar://123504095
2024-04-29 10:48:22 +01:00
Dario Rexin
09cd036d15 [IRGen] Fix size computation for imported C types in type layouts (#73271)
rdar://126954341

C types don't have separate size and stride, but in type layouts we always computed the size as if they did. This could cause wrong offsets in compact value witnesses
2024-04-25 19:58:14 -07:00
Becca Royal-Gordon
35f05cdf8d Fix objc_implementation_objc_client test
Because this test is disabled, a previous commit failed to add an experimental feature flag that’s required to run it.
2024-04-24 11:39:24 -07:00
Dario Rexin
b97fbac9a6 [Runtime] Fix CVW for genreic single payload enums with no extra inha… (#73186)
* [Runtime] Fix CVW for genreic single payload enums with no extra inhabitants

rdar://126728925

When the payload of a generic SPE did not have any extra inhabitants, we erroneously always treated it as the no payload case.
Additionally the offset and skip values were improperly computed.

* Fixed FileCheck string
2024-04-22 22:56:57 -07:00
Nate Chandler
de8f1c0b69 [NoncopyablePartialConsumption] Promote to feature 2024-04-19 12:37:34 -07:00
Pavel Yaskevich
7b8f76e3c4 Merge pull request #73007 from xedin/promote-dynamic-actor-isolation-to-upcoming-feature
[SE-0423] Promote `DynamicActorIsolation` to an upcoming feature and add a way to disable checks
2024-04-16 11:46:41 -07:00