107225 Commits

Author SHA1 Message Date
Hamish Knight
54fd18e5b5 Merge pull request #86011 from hamishknight/dyn-apply
[CS] Do member lookup last when binding dynamic member overload
2025-12-13 23:45:15 +00:00
eeckstein
80640f7f39 Merge pull request #86005 from eeckstein/fix-sil-combine
SILCombine: don't sink forwarding instructions with address operands
2025-12-13 16:50:48 +00:00
Slava Pestov
ab8ca27701 Merge pull request #86020 from slavapestov/opaque-archetype-sugar-type-variable
AST: Canonicalize opaque archetype substitution maps in the solver arena
2025-12-13 08:54:58 -05:00
Meghana Gupta
96cd2e1e10 Merge pull request #85987 from meg-gupta/undefcapture
Tolerate undef closure captures in ClosureLifetimeFixup
2025-12-12 16:31:09 -08:00
Slava Pestov
54521bd21b AST: Canonicalize opaque archetype substitution maps in the solver arena
Preserving sugar if we have type variables uses way too much memory.

Canonicalize these substitution maps for now, as a (temporary?) workaround.

In the future, if we decide preserving sugar is more important than a
few dozen Mb of memory usage, we can also bump the arena memory limit,
instead.

Fixes rdar://166237860.
Fixes rdar://165863647.
2025-12-12 18:11:04 -05:00
Alexis Laferrière
74c8fcfc66 Merge pull request #85990 from xymus/serial-conf-diag
Serialization: Minor improvements to the error on conformance mismatch
2025-12-12 15:05:53 -08:00
Anthony Latsis
dea291c047 Merge pull request #85971 from swiftlang/jepa-main4
SIL: Adjust pack `isa` after upstream LLVM implementation change
2025-12-12 22:20:39 +00:00
Hamish Knight
a4ae17133c Merge pull request #85973 from bnbarham/convert-async-shorthand
[SourceKit] Allow converting functions containing shorthand ifs to async
2025-12-12 17:19:23 +00:00
Pavel Yaskevich
3754042c9c Merge pull request #85964 from xedin/rdar-166244164
[Concurrency] Add `ApproachableConcurrency` as a pseudo upcoming feature flag
2025-12-12 09:01:34 -08:00
Gábor Horváth
0fcf2e1ce8 Merge pull request #85980 from Xazax-hun/recursive-enums-fix
[cxx-interop] Fix crashing on recursive enums
2025-12-12 16:45:12 +00:00
Hamish Knight
4b25dc528d [CS] Do member lookup last when binding dynamic member overload
Otherwise if the member lookup gets simplified immediately and we 
have a recursive dynamic member lookup we will crash since we wouldn't
have introduced the corresponding applicable function constraint.

rdar://164321858
2025-12-12 16:39:02 +00:00
Kathy Gray
472937e57d Merge pull request #85591 from kathygray-pl/kathy/diagnosticProperty
[Diagnostics] Increase possibility for missed property diagnostic
2025-12-12 16:09:12 +00:00
John Hui
747234cf0c Merge pull request #86002 from j-hui/migrate-incomplete-template-spec-check 2025-12-12 07:52:00 -08:00
Erik Eckstein
aa4e77a46c SILCombine: don't sink forwarding instructions with address operands
We don't do memory lifetime analysis for this peephole optimization.
Therefore we can't risk sinking instructions with address operands out of the addressed memory's lifetime.

For example:
```
  %3 = mark_dependence %2 on %1 : $*T  // must not be moved after the destroy_addr
  destroy_addr %1
```

Fixes a verifier crash
rdar://166240751
2025-12-12 16:11:13 +01:00
Michael Gottesman
22d182552c Merge pull request #85999 from gottesmm/pr-c29e9002447c10b77a408ede1f7b7e42c5034dbf
[rbi] When looking for closure uses, handle unresolved_non_copyable_value and store_borrow temporaries.
2025-12-12 00:09:08 -08:00
Michael Gottesman
79eee82b87 Merge pull request #85997 from gottesmm/pr-10810fd33c3e8d8fd1e4072f78d63d3200d35aa7
[rbi] Remove highlights from errors.
2025-12-11 23:57:55 -08:00
Chris Williams
fe0191c62c [CSSimplify] Parameter pack wrapping logic incorrectly considers tuple LValueTypes to not be tuples (#85962)
In #65125 (and beyond) `matchTypes`, has logic to attempt to wrap an
incoming parameter in a tuple under certain conditions that might help
with type expansion.

In the case the incoming type was backed by a `var`, it would be wrapped
by an `LValueType` then be subsequently mis-diagnosed as not-a-tuple.

More details in #85924 , this this is also the cause of (and fix for)
#85837 as well...
2025-12-11 22:29:42 -08:00
Slava Pestov
ca12185204 Merge pull request #85967 from slavapestov/dont-copy-that-floppy
Sema: Avoid copying BindingSets
2025-12-12 00:18:47 -05:00
Michael Gottesman
e186e5e5d0 Merge pull request #85972 from gottesmm/pr-9663abc1697da1382a8514e6877a6c3ce3f439b9
[concurrency] Hide Concurrency StackNesting builtins behind a feature flag
2025-12-11 21:16:37 -08:00
John Hui
bb5bb97958 [cxx-interop] Move incomplete template specialization check
We were only previously doing this check when we had a typedef,
because that is the scenario where we encountered this issue.

This patch moves the check closer to where we would actually instantiate
the template, so that these cases can be stopped in more situations.
2025-12-11 18:53:47 -08:00
Michael Gottesman
d64fda488e [rbi] When looking for closure uses, handle unresolved_non_copyable_value and store_borrow temporaries.
This ensures that in cases like the following:

+func testNoncopyableNonsendableStructWithNonescapingMainActorAsync() {
+  let x = NoncopyableStructNonsendable()    <=========
+  let _ = {
+    nonescapingAsyncClosure { @MainActor in
+      useValueNoncopyable(x) // expected-warning {{sending 'x' risks causing data races}}
+      // expected-note @-1 {{task-isolated 'x' is captured by a main actor-isolated closure. main actor-isolated uses in closure may race against later nonisolated uses}}
+    }
+  }
+}

We emit the diagnostic on the use instead of the <=====.

rdar://166347485
2025-12-11 18:45:06 -08:00
Michael Gottesman
8bea3518f5 [rbi] Remove highlights from errors.
I have noticed over time when working on the command line, we often times
highlight too large of an expression due to the locations provided to us by
earlier parts of the compiler. This isn't technically necessary and the
following doesn't look nice... so remove it.

```
test5.swift:171:16: error: sending 'x' risks causing data races [#SendingRisksDataRace]
169 |   let _ = {
170 |     nonescapingAsyncUse { @MainActor in
171 | _ _ _ _ _u_s_e_V_a_l_u_e_(_x_)
    |                |- error: sending 'x' risks causing data races [#SendingRisksDataRace]
    |                `- note: task-isolated 'x' is captured by a main actor-isolated closure. main actor-isolated uses in closure may race against later nonisolated uses
172 |     }
173 |   }
```
2025-12-11 17:29:20 -08:00
Ben Cohen
9dd9e96e1d Allow Hashable: ~Copyable (#85748)
Builds on #85746 which covers Equatable.
2025-12-11 14:47:36 -08:00
Meghana Gupta
f30b5841c4 Tolerate undef closure captures in ClosureLifetimeFixup
We may see undef closure captures in ClosureLifetimeFixup since
it is a mandatory pass that runs on invalid code as well.

This could sometimes hang the compiler while running `insertDeallocOfCapturedArguments`
in release builds.

This change adds a bailout when we see an undef closure capture to avoid running into this issue.
2025-12-11 12:16:12 -08:00
Pavel Yaskevich
6526dca9db [Concurrency] Add ApproachableConcurrency as a pseudo upcoming feature flag
Enables upcoming features that aim to provide a more approachable path to Swift Concurrency:
 - `DisableOutwardActorInference`
 - `GlobalActorIsolatedTypesUsability`
 - `InferIsolatedConformances`
 - `InferSendableFromCaptures`
 - `NonisolatedNonsendingByDefault`

Resolves: rdar://166244164
2025-12-11 10:36:03 -08:00
Dario Rexin
1f8e88d659 Merge pull request #85908 from drexin/wip-163631865
[IRGen] Use proper linkage for async function pointers to partial app…
2025-12-11 09:52:51 -08:00
Joe Groff
560eb9deaa Merge pull request #85954 from jckarter/sil-require-require-instruction
SIL verifier: The `atInstruction`/`atArgument` parameter to `require` should not be optional.
2025-12-11 09:43:43 -08:00
Kathy Gray
fde49b8847 Diagnostics : Increase possibility for missed property diagnostic
Impact for an unknown property access was frequently higher than other options
on ambiguous selections, by 3 to 5 points, causing fix selections that were
farther away and frequently noted to be in accurate. This commit lowers the
impact to be in a similar range to other fixes and this causes property accesses
to be selected more proprotionaly.

In the existing test suite, this changed the diagnostic only in the case of
protocol composition, which was also discovered to be a flawed binding lookup.

Tests added for the property lookup, tests updated for protocol composition
(Including correcting a likely error in a test specification)
2025-12-11 16:08:22 +00:00
Gabor Horvath
181122edf9 [cxx-interop] Fix crashing on recursive enums
Introduce a cache that helps cutting the recursion when we process a
type that we already visited before but did not finish processing yet.

Fixes #85361

rdar://164153038
2025-12-11 15:24:03 +00:00
Arnold Schwaighofer
c1c05e1298 Merge pull request #85948 from aschwaighofer/embedded_enable_existential_support
[embedded] Enable support for existentials/boxed protocol types per default
2025-12-11 07:16:26 -08:00
Anthony Latsis
9b2a7efbf2 SIL: Adjust pack isa after upstream LLVM implementation change
See https://github.com/llvm/llvm-project/pull/161403.

These `isa` calls with a `CanType` no longer compile with LLVM next
because the implementation now unfolds directly to `CastInfo` calls
rather than non-variadic `isa` calls that resolve to our partial
specializations here:

e293876e4f/include/swift/AST/Type.h (L600)

We should partially specialize `CastInfo` instead of `isa` et al. For
now, just use the non-variadic `isa`.
2025-12-11 14:18:47 +00:00
Hamish Knight
088bda7424 Merge pull request #85952 from hamishknight/skip-body-macro
[AST] Avoid walking macro expanded bodies in non-expanded mode
2025-12-11 14:08:45 +00:00
Ben Barham
7887ce8a8e [SourceKit] Allow converting functions containing shorthand ifs to async
Resolves rdar://154753663.
2025-12-11 21:46:37 +10:00
Susana Monteiro
91d1d2e06f Merge pull request #85793 from susmonteiro/susmonteiro/diagnose-swift-attrs
[cxx-interop] Diagnose invalid swift attributes
2025-12-11 11:06:41 +00:00
Slava Pestov
956dc0c1a2 Merge pull request #85955 from slavapestov/fix-issue-85860
SILGen: Fix keypath descriptor emission for class nested inside generic context
2025-12-11 00:36:18 -05:00
Michael Gottesman
7b9281fcb8 [concurrency] Hide Concurrency StackNesting builtins behind a feature flag.
rdar://166244033
2025-12-10 16:02:18 -08:00
Slava Pestov
205d8e6640 Sema: Remove unnecessary operator new overload 2025-12-10 18:48:47 -05:00
Slava Pestov
ba7df4013e Sema: Avoid copying BindingSets
They're stored inside the ConstraintGraphNode now, so returning a
`const BindingSet *` from within determineBestBindings() should
be safe.
2025-12-10 18:48:00 -05:00
Alexis Laferrière
175d0ba8e6 Serialization: Minor improvements to the error on conformance mismatch
Clarify the sources of information when a conformance reference in a
swiftmodule doesn't match with the requirements seen by the reader.
2025-12-10 15:08:03 -08:00
Andrew Trick
10e1be4387 Merge pull request #85870 from atrick/comment-copyprop
Add a FIXME to CopyPropagation to highlight an incomplete fix.
2025-12-10 13:51:30 -08:00
Egor Zhdan
f995144c1d Merge pull request #85906 from egorzhdan/egorzhdan/reland-cxx-string-cs
Reapply "[ConstraintSystem] C++ Interop: Binding a string literal to `std.string` shouldn't increase the score"
2025-12-10 21:04:15 +00:00
Slava Pestov
1013d25746 SILGen: Fix keypath descriptor emission for class nested inside generic context
hasGenericParamList() is the wrong thing to check -- we actually need to
know if any parent context is generic, as well.

- Fixes https://github.com/swiftlang/swift/issues/85860.
2025-12-10 13:28:54 -05:00
Joe Groff
da4e72cf2d SIL verifier: The atInstruction/atArgument parameter to require should not be optional.
The underlying C++ code expects a non-null `Instruction*` or `SILArgument*` pointer, and
most of the contextual information in a verifier error is derived from these arguments,
so it doesn't really make sense for the Swift level interface to present these arguments
as optional.
2025-12-10 10:27:56 -08:00
Meghana Gupta
96cfec4f84 Merge pull request #85935 from meg-gupta/lifetimeflags
Fix swiftinterface printing of accessors and inferred lifetime dependencies when Lifetimes feature is enabled
2025-12-10 10:01:01 -08:00
Hamish Knight
a9ad4e2cae [AST] Avoid walking macro expanded bodies in non-expanded mode
Make sure we don't walk into the expansion of a body macro if the AST
walker is configured not to walk macro expansions.
2025-12-10 17:41:00 +00:00
susmonteiro
fb5bc7282f [cxx-interop] Diagnose invalid copyability, escapability and mutability attributes
Fixes: https://github.com/swiftlang/swift/issues/84559
2025-12-10 17:26:14 +00:00
Arnold Schwaighofer
d019f37b68 [embedded] Enable support for existentials/boxed protocol types per default
And enable this feature in production.
2025-12-10 08:50:23 -08:00
Arnold Schwaighofer
be78127c23 Merge pull request #85923 from aschwaighofer/embedded_existentials_requires_embedded
[embedded] Feature::EmbeddedExistentials requires Feature::Embedded
2025-12-10 07:13:45 -08:00
Mishal Shah
0c0a98d591 Merge pull request #85943 from egorzhdan/egorzhdan/std-function-compile-error
[cxx-interop] Fix compile error
2025-12-10 06:59:10 -08:00
Arnold Schwaighofer
4730181c7a Merge pull request #85914 from aschwaighofer/embedded_foreign_type_metadata
[embedded] Add support for some foreign metadata
2025-12-10 06:58:55 -08:00