Commit Graph

103252 Commits

Author SHA1 Message Date
Konrad 'ktoso' Malawski
6989f05abe Revert revert & fix distributed protocol and TBD handling
This reverts a revert that was done internally here https://stashweb.sd.apple.com/projects/DEVTOOLS/repos/swift/pull-requests/8697/overview
and corrects some issues with the reverted code while at it.

This fix is crucial to land for correctness and necessary to fix the
rdar://144568615 which had a fix submitted however that assumed that
THIS change also was present, so the fix submitted for 144568615 is
incomplete without this change as well.

This enables, and adds more TBD testing and was explicitly checked
against the GameKit reproducer project from rdar://144568615.

I will also upstream the necessary parts missing from OSS repo there so
we have alignment between all branches.
2025-06-30 11:47:29 +09:00
Doug Gregor
2f838823ee Merge pull request #82590 from DougGregor/no-main-actor-when-conforming-to-sendable-6.2
[6.2] [SE-0466 experimental amendment] Don't infer @mainactor on types conforming to Sendable
2025-06-28 05:57:50 -07:00
Doug Gregor
997a252da4 Merge pull request #82585 from DougGregor/nonisolated-deinit-availability-6.2
"nonisolated deinit" does not have back-deployment constraints
2025-06-28 03:27:38 -07:00
Hamish Knight
b50dcb1d0f Merge pull request #82570 from hamishknight/mac-n-cheese-6.2 2025-06-28 09:17:08 +01:00
Slava Pestov
f72260f85c Merge pull request #82586 from slavapestov/fix-issue-82160-6.2
[6.2] AST: Better cope with UnboundGenericType in TypeBase::getSuperclass()
2025-06-28 02:41:09 -04:00
Slava Pestov
68b9a52fc6 Merge pull request #82508 from slavapestov/warn-long-expression-type-checking-6.2
[6.2] Sema: Fix -warn-long-expression-type-checking when expression timer is disabled
2025-06-28 01:31:02 -04:00
nate-chandler
9b8e749027 Merge pull request #82573 from nate-chandler/cherrypick/release/6.2/rdar154407327
6.2: [DestroyAddrHoisting] Don't fold into read access.
2025-06-27 19:35:58 -07:00
Dave Lee
2d40d0e73d IRGen: Emit objc type encoding for ivars
ObjC ivar metadata has up to now emitted an empty string for the ivar's objc type encoding. Conversely, ObjC property metadata is emitted with an objc type encoding. This changes the compiler to also emit an objc type encoding for ivars.

The motivation for this change is for lldb to print ivars of classes declared in Objective-C but implemented in Swift, as defined in [SE-0436](https://github.com/swiftlang/swift-evolution/blob/main/proposals/0436-objc-implementation.md). Without the presence of type encoding for ivars, lldb is unable to present to the user the ivars/properties of instances of such classes.

rdar://138569299
(cherry picked from commit ce7a3b39a4)
2025-06-27 16:24:49 -07:00
Doug Gregor
b5cce1f694 [SE-0466] Don't infer @MainActor on types conforming to Sendable
When the default isolation is main-actor, don't infer @MainActor
for a type that conforms to a protocol P in its primary definition when
P inherits from Sendable. Such types should remain non-isolated
because they're highly unlikely to be able to implement the P
conformance (which cannot be isolated).

Put this feature behind a new experimental flag,
SendableProhibitsMainActorInference.

Implements rdar://151029300
2025-06-27 15:14:26 -07:00
Slava Pestov
eabc8efb41 AST: Better cope with UnboundGenericType in TypeBase::getSuperclass()
Returning the unsubstituted superclass type is not correct,
because it may contain type parameters. Let's form a new
UnboundGenericType instead.

- Fixes https://github.com/swiftlang/swift/issues/82160.
- Fixes rdar://152989888.
2025-06-27 18:11:40 -04:00
Argyrios Kyrtzidis
0127926255 Merge pull request #82513 from sina-mahdavi/sina-mahdavi/cherry-pick-fix-llvm-prefix-mapping-calls
[6.2🍒] fix calls to llvm prefix mapping functions to use space-separated option format
2025-06-27 15:08:32 -07:00
Doug Gregor
2f6d21ebe6 "nonisolated deinit" does not have back-deployment constraints
Fixes rdar://150484159
2025-06-27 14:56:57 -07:00
Pavel Yaskevich
a381143495 [CSFix] Fix getConcurrencyFixBehavior to account for non-decl overloads
Adjust the downgrade check for static member references to
account for the fact that argument could come of a tuple or
some other reference that doesn't have a declaration associated
with it.

Resolves: rdar://153083848
(cherry picked from commit 3ae8d5680f)
2025-06-27 13:20:22 -07:00
Nate Chandler
9acdc921e0 [DestroyAddrHoisting] Don't fold into read access.
Narrowly fix a long-standing bug where destroy_addrs would be hoisted
into read access scopes, leaving the scope as a read despite the fact
that it modifies memory.  This is a problem for utilities which expect
access scopes to provide correct summaries.  Do this by refusing to fold
into access scopes which are marked `[read]`.

In a follow-up, we can reenable this folding, promoting each access
scope to a modify.  Doing so requires checking that there are no access
scopes which overlap with any of the access scopes which would be
promoted to modify.

rdar://154407327
2025-06-27 11:54:19 -07:00
Erik Eckstein
995264913f ClosureSpecializer: don't specialize captures of stack-allocated Objective-C blocks
Bail if the closure captures an ObjectiveC block which might _not_ be copied onto the heap, i.e optimized by SimplifyCopyBlock.
We can't do this because the optimization inserts retains+releases for captured arguments.
That's not possible for stack-allocated blocks.

Fixes a mis-compile
rdar://154241245
2025-06-27 20:08:51 +02:00
Hamish Knight
2add407ae8 [IDE] Bail from IDEInspectionSecondPassRequest if parserState is null
This shouldn't ever happen, but let's at least make sure we don't
crash.
2025-06-27 18:32:25 +01:00
Hamish Knight
0d10b579c9 [IDE] Avoid macro expansions in getEquivalentDeclContextFromSourceFile
Unfortunately haven't been able to come up with a test case for this,
but there seem to be cases where we're incorrectly picking up
a macro-expanded accessor from the cached AST when searching for the
original decl. Make sure we only consider decls that have been
written by the user.

rdar://151926231
2025-06-27 18:25:15 +01:00
Hamish Knight
4f40211259 [IDE] NFC: Use optional instead of ~0U 2025-06-27 18:25:15 +01:00
eeckstein
1aaae8514b Merge pull request #82559 from eeckstein/fix-semantic-arc-opt-6.2
[6.2] SemanticARCOpts: don't ignore dead-end blocks in the liverange analysis
2025-06-27 18:38:34 +02:00
Charles Zablit
35d94e7ac5 [demangling] add new wrapper API 2025-06-27 10:19:08 +01:00
Andrew Trick
92fd571d07 Merge pull request #82511 from atrick/62-inout-syntax
[6.2] Fix diagnostics for missing or invalid @_lifetime annotations on inout params
2025-06-26 23:33:16 -07:00
Doug Gregor
5373f52c40 Merge pull request #82546 from DougGregor/silgen-skip-isolated-deinit-6.2
[6.2] [SILGen] Ensure that we don't emit a skipped isolated deinit
2025-06-26 23:28:46 -07:00
Xi Ge
566a98dbeb Merge pull request #82544 from nkcsgexi/153683760-6.2
[6.2] ABI checker: drop usage of AllowDeserializingImplementationOnly
2025-06-26 22:18:48 -07:00
Slava Pestov
892e555310 Merge pull request #82543 from slavapestov/fix-rdar153730847-6.2
[6.2] ASTDemangler: Round-trip @isolated @sil_implicit_leading_param parameter attributes
2025-06-27 01:08:48 -04:00
Erik Eckstein
728f37abf0 SemanticARCOpts: don't ignore dead-end blocks in the liverange analysis
This can result in wrong ARC optimizations in dead-end blocks.
Fixes a SIL verification error.

rdar://154356277
2025-06-27 07:03:23 +02:00
Doug Gregor
7fa6999dc1 [SILGen] Ensure that we don't emit a skipped isolated deinit
Fixes rdar://154373088 / issue #82523
2025-06-26 14:03:58 -07:00
Xi Ge
87687a292f ABI checker: drop usage of AllowDeserializingImplementationOnly
AllowDeserializingImplementationOnly was historically added as a defensive
check against deserailzation issues introduced by @implementationOnly imports.
It's no longer specified by other tools, thus the ABI checker should drop
it as well.

rdar://153683760
2025-06-26 13:40:27 -07:00
Andrew Trick
0b0dbd9ee0 Diagnostic note for invalid @_lifetime annotations on inout params
Users commonly try to write a lifetime dependency on an 'inout' parameters as:

    @_lifetime(a: &a)
    func f_inout_useless(a: inout MutableRawSpan) {}

This is useless. Guide them toward what they really wanted:

    @_lifetime(a: copy a)

Fixes rdar://151618856 (@lifetime(..) gives inconsistent error messages)

(cherry picked from commit 87f2510a27)
2025-06-26 12:58:40 -07:00
Andrew Trick
102e5ecee1 Fix a compiler crash with '@'_lifetime(inout x), add diagnostic
This is a common mistake made more common be suggestions of existing diagnostic
that tell users not to use a 'copy' dependency.

Report a diagnostic error rather than crashing the compiler. Fix the diagnostic
output to make sense relative to the source location.

Fixes rdar://154136015 ([nonescapable] compiler assertion with @_lifetime(x: inout x))

(cherry picked from commit 080b68292d)
2025-06-26 12:58:40 -07:00
Andrew Trick
fcbcc8c1e4 Fix misleading Lifetime diagnostics for inout parameters
Correctly diagnose this as:
"invalid use of inout dependence on the same inout parameter

    @_lifetime(a: &a)
    func f_inout_useless(a: inout MutableRawSpan) {}

Correctly diagnose this as:
"lifetime-dependent parameter must be 'inout'":

    @_lifetime(a: borrow a)
    func f_inout_useless(a: borrowing MutableRawSpan) {}

(cherry picked from commit 05fa82b7a7)
2025-06-26 12:58:40 -07:00
Andrew Trick
e409752e00 Lifetime diagnostics: clarify @_lifetime usage for inout parameters
This comes up often when passing a MutableSpan as an 'inout' argument.  The
vague diagnostic was causing developers to attempt incorrect @_lifetime
annotations. Be clear about why the annotation is needed and which annotation
should be used.

(cherry picked from commit df0b81c88d)
2025-06-26 12:58:39 -07:00
Andrew Trick
52654095c1 Fix LifetimeDependence diagnostic formatting
Remove incorrectly nested single quotes from the suggested fix.

(cherry picked from commit 465d6a82e7)
2025-06-26 12:58:39 -07:00
Slava Pestov
7ed5d2bfc2 ASTDemangler: Round-trip @isolated @sil_implicit_leading_param parameter attributes
We sometimes mangle SILFunctionTypes when generating debug info
for reabstraction thunks, and these can have various exotic
parameter and result attributes. Two recent additions were
never plumbed through the mangler, causing assertion failures
when emitting debug info.

Fixes rdar://153730847.
2025-06-26 15:00:44 -04:00
Pavel Yaskevich
56383771fe [ClangImporter] SE-0463: Implement @Sendable inference exception for global actor isolated functions
Functions that are isolated to a global actor don't have completion
handlers imported as `@Sendable`. Main actor isolated functions with
completion handlers that are always called on the main actor is a
very common Objective-C pattern, and this carve out will eliminate
false positive warnings in the cases where the main actor annotation
is missing on the completion handler parameter.

Resolves: rdar://149811049
(cherry picked from commit ab227b401d)
2025-06-26 09:32:54 -07:00
Pavel Yaskevich
b2bcd21b10 [ClangImporter] Use DefaultsToSendable with completion handler parameter
This lifts the check for the feature flag up into the `importParameterType`
from `importType` and means that completion handler type for `async` variant
is no longer gains `@Sendable` attribute.

(cherry picked from commit 74471e858b)
2025-06-26 09:32:52 -07:00
Charles Zablit
e180d8bb38 Merge pull request #82479 from charles-zablit/charles-zablit/add-new-demangling-methods-to-6.2
🍒 [demangling] add new methods to the NodePrinter to enable range tracking possibilities when demangling a name
2025-06-26 11:07:26 +01:00
Hamish Knight
8e0749eea2 Merge pull request #82498 from hamishknight/tic-tac-toe-6.2 2025-06-26 09:07:26 +01:00
Doug Gregor
3094c8cfa0 Merge pull request #82495 from DougGregor/effects-subst-parameter-packs-6.2
[6.2] [Effects] Ensure that we properly substitute function types in ByClosure checks
2025-06-25 21:27:14 -07:00
Slava Pestov
017be57e9b Sema: Fix -warn-long-expression-type-checking when expression timer is turned off
My change 983b75e1cf broke
-warn-long-expression-type-checking because now the
ExpressionTimer is not instantiated by default and that
entire code path is skipped.

Change it so that if -warn-long-expression-type-checking
is passed in, we still start the timer, we just don't
ever consider it to have 'expired'.

Fixes rdar://problem/152998878.
2025-06-25 22:07:56 -04:00
Sina Mahdavi
fabbbc87c8 [6.2🍒] fix calls to llvm prefix mapping functions to use space-separated option format 2025-06-25 16:48:50 -07:00
Doug Gregor
e744e35086 Merge pull request #82384 from slavapestov/implied-isolated-conformance-6.2
[6.2] Sema: Expand isolated conformance inference to consider conformances to inherited protocols
2025-06-25 15:36:39 -07:00
Hamish Knight
0c8468e0ee [SourceKit] Print backticks if needed in printDisplayName
Ensure we print raw identifier names with backticks for e.g the
document structure request.

rdar://152524780
2025-06-25 19:52:09 +01:00
Andrew Trick
54651d1b16 Merge pull request #82473 from atrick/62-explicit-init
[6.2] Disable surprising lifetime inference of implicit initializers
2025-06-25 11:32:40 -07:00
Doug Gregor
283cb60664 [Effects] Ensure that we properly substitute function types in ByClosure checks
We weren't substituting generic arguments into function types. In the
presence of parameter packs, this could mean that the parameter and
argument lists no longer match up, which would cause the effects
checker to prematurely bail out after treating this as "invalid" code.
The overall effect is that we would not properly check for throwing
behavior in this case, allowing invalid code (as in the example) and
miscompiling valid code by not treating the call as throwing.

Fixes rdar://153926820.
2025-06-25 10:12:51 -07:00
Pavel Yaskevich
9220e686b5 Merge pull request #82470 from xedin/rdar-154202375-6.2
[6.2][Concurrency] Global actor isolated conformances are only allowed to …
2025-06-25 08:58:57 -07:00
Pavel Yaskevich
10bd67630f Merge pull request #82471 from xedin/rdar-154221449-6.2
[6.2][CSSimplify] Narrow down tuple wrapping for pack expansion matching
2025-06-25 08:58:45 -07:00
Charles Zablit
e1a1609045 remove unused API 2025-06-25 13:13:36 +01:00
Charles Zablit
80fe2dce79 add new methods to the NodePrinter to enable range tracking possibilities when demangling a name 2025-06-25 13:13:23 +01:00
Charles Zablit
c31a07460a move NodePrinter declarations to a header 2025-06-25 13:12:03 +01:00
Andrew Trick
0839675e6d Merge pull request #82407 from atrick/62-fix-accessor-infer
[6.2] [nonescapable] remove '@_lifetime' requirement on implicit accessors
2025-06-25 00:57:45 -07:00