Commit Graph

103491 Commits

Author SHA1 Message Date
Pavel Yaskevich
6cfbafd968 [CSSimplify] VariadicGenerics: Don't attempt to wrap optional into one-element tuple
If we have a tuple with unresolved pack expansion on one side
and an optional type on the other, prevent `matchTypes` from
wrapping optional into a one-element tuple because the matching
should be handled as part of the optional injection.

Resolves: rdar://152940244
2025-06-17 18:25:22 -07:00
Stephen Canon
09dc0920e7 Add a feature check for extern c support of builtin vectors (#82306)
We want to be able to adopt
(https://github.com/swiftlang/swift/pull/82225) in the stdlib without
breaking people building at desk with older toolchains, so let's add a
feature flag.
2025-06-17 19:50:16 -04:00
Pavel Yaskevich
84cb3c89ff Merge pull request #79893 from simanerush/fix-explicit-nonisolated-proto-inference
[Concurrency] Look for explicit 'nonisolated' when getting isolation from protocol conformances.
2025-06-17 15:23:26 -07:00
Hamish Knight
b37e34ea8d [Sema] Tighten up function call check in resolveKeyPathExpr
Check for `CallExpr` instead of `ApplyExpr`, we don't support
arbitrary postfix operators in key paths.
2025-06-17 23:07:46 +01:00
Slava Pestov
fee97ea96a RequirementMachine: Fix the most embarassing bug of all time
The implementation of Knuth-Bendix completion has had a subtle
bookkeeping bug since I first wrote the code in 2021.

It is possible for two rules to overlap in more than one position,
but the ResolvedOverlaps set was a set of pairs (i, j), where
i and j are the index of the two rules. So overlaps other than
the first were not considered. Fix this by changing ResolvedOverlaps
to a set of triples (i, j, k), where k is the position in the
left-hand side of the first rule.

The end result is that we would incorrectly accept the protocol M3
shown in the test case. I'm pretty sure the monoid that M3 encodes
does not have a complete presentation over any alphabet, so of
course it should not be accepted here.
2025-06-17 17:51:26 -04:00
Slava Pestov
bf3f4a6d79 AST: Fix lost GenericSignatureErrors in getPlaceholderRequirementSignature() 2025-06-17 17:51:25 -04:00
Slava Pestov
7f8175b3da RequirementMachine: Add two more completion termination checks for concrete type requirements
The concrete nesting limit, which defaults to 30, catches
things like A == G<A>. However, with something like
A == (A, A), you end up with an exponential problem size
before you hit the limit.

Add two new limits.

The first is the total size of the concrete type, counting
all leaves, which defaults to 4000. It can be set with the
-requirement-machine-max-concrete-size= frontend flag.

The second avoids an assertion in addTypeDifference() which
can be hit if a certain counter overflows before any other
limit is breached. This also defaults to 4000 and can be set
with the -requirement-machine-max-type-differences= frontend flag.
2025-06-17 17:51:25 -04:00
Pavel Yaskevich
fc573b6612 [ConstraintSystem] Guard all the performance hacks with a flag
Package the flag into `performanceHacksEnabled()` method on
`ConstraintSystem` and start using it to wrap all of the hacks
in constraint generator and the solver.
2025-06-17 13:53:05 -07:00
Pavel Yaskevich
833b6b19e9 [Frontend] Remove -disable-solver-shrink option
It's folded into a more general "disable performance hacks" one.
2025-06-17 13:52:28 -07:00
Michael Gottesman
bf78c6206b Revert "[flow-isolation] Allow for initialization of fields of a Global Actor isolated class in its nonisolated inits"
This reverts commit 501bad55a8.
2025-06-17 13:01:28 -07:00
(null)
aaf283258b Merge branch 'main' into mchiu/freebsd 2025-06-17 15:41:57 -04:00
(null)
cf041b126e address pltaform orders and other nits 2025-06-17 15:37:49 -04:00
(null)
d6811260a9 Merge commit '665515c781999a81094bbe4f8302a7cb1a6a6b39' into mchiu/freebsd 2025-06-17 15:12:23 -04:00
Slava Pestov
a4bfa3f72b Merge pull request #82275 from slavapestov/more-fuzzer-fixes-2
More fuzzer fixes
2025-06-17 14:57:38 -04:00
Slava Pestov
dad358350a Sema: Relax diagnosis of implied marker protocol conformances with mismatched availability
This logic was introduced in https://github.com/swiftlang/swift/pull/75135.
The intent was to prevent an implied conformance from overriding an
existing unavailable one, for example in the case of Sendable. Let's
relax this check a bit to only diagnose if the mismatch is in the
unconditional availability, and not OS version.

Fixes rdar://142873265.
2025-06-17 14:27:14 -04:00
Artem Chikin
66b8f35a5e Merge pull request #81569 from artemcm/NoBatchForYou
[Legacy Driver] Obsolete and remove batch compilation mode from the legacy driver
2025-06-17 10:49:16 -07:00
Evan Wilde
3376785630 Use C++ driver when C++ interop is enabled
This aligns the old driver with the behavior of the new driver.
When building with C++ interop enabled, it's important that we link a
C++ runtime, which is handled by the clang++ driver.
The new driver uses clang++ when linking with C++ enabled, either
through the c++ interoperability mode flag or the experimental C++
interop flag. The old driver only enabled it with the experimental C++
interop flag. This results in the C++ interop tests failing on FreeBSD
and a behavioral difference between what we are testing and what we are
shipping.
2025-06-17 10:42:57 -07:00
Pavel Yaskevich
2f920ceb5a Merge pull request #82289 from xedin/rdar-145519840
[Concurrency] SE-0449: `nonisolated` on a type should prevent isolati…
2025-06-17 09:02:52 -07:00
Egor Zhdan
f6e61728c5 Merge pull request #82161 from swiftlang/egorzhdan/template-param-nullability
[cxx-interop] Import nullability of templated function parameters correctly
2025-06-17 16:51:47 +01:00
Gábor Horváth
304d558f43 Merge pull request #82203 from swiftlang/gaborh/shared-references-are-safe
[cxx-interop] Shared references are considered safe
2025-06-17 16:12:59 +01:00
Joe Groff
b8f5a36fc6 Merge pull request #82288 from jckarter/transitive-addressability-fields-and-addressors
SILGen: Handle struct fields and addressors as addressable storage.
2025-06-17 07:36:49 -07:00
Hamish Knight
89a7014db9 [Sema] Add null check in createMemberwiseInitParameter
The property wrapper initializer info may be null if e.g we had a
request cycle, just use the property's interface type in that case.

rdar://82899428
2025-06-17 15:16:44 +01:00
Slava Pestov
1b4178ff48 ASTScope: Fix llvm_unreachable when printing scopes before extension binding 2025-06-17 10:15:30 -04:00
Slava Pestov
cfa9de8f0a Parse: Address an llvm_unreachable that is actually reachable 2025-06-17 10:15:30 -04:00
Slava Pestov
b79f2817f9 Sema: Fix MissingCallFailure::diagnoseAsError() crash with special base names 2025-06-17 09:52:04 -04:00
Slava Pestov
0d6470345b Sema: Fix crash on invalid code in isOverrideBasedOnType() 2025-06-17 09:52:04 -04:00
Slava Pestov
ef5e2861a2 Sema: Fix crash on invalid code in diagnoseDictionaryLiteralDuplicateKeyEntries() 2025-06-17 09:52:03 -04:00
Slava Pestov
8b12f8cb8e Sema: Fix null pointer dereference in LazyStoragePropertyRequest::evaluate() 2025-06-17 09:52:03 -04:00
Slava Pestov
eec924b505 Sema: Fix crash in diagnoseIfSynthesisUnsupportedForDecl() with tuple extension 2025-06-17 09:52:03 -04:00
Slava Pestov
9a01e872da Sema: Address FIXME resulting in a crash in filterProtocolRequirements() 2025-06-17 09:52:03 -04:00
Slava Pestov
4fa2e979fa RequirementMachine: Don't crash if we cannot desugar a same-shape requirement 2025-06-17 09:52:02 -04:00
nate-chandler
5b37832e1f Merge pull request #82280 from nate-chandler/rdar151726387
[IRGen] Fix FixedArray of fixedSize 1 element addressing.
2025-06-17 06:39:31 -07:00
Slava Pestov
908c9368ed Parse: Only accept certain literals as enum case raw values
Just checking for LiteralExpr is too broad, because Sema doesn't
know what to do with RegexLiteralExpr for example.
2025-06-17 09:19:00 -04:00
Slava Pestov
401d297ee2 AST: Fix crash on invalid in isVanishingTupleConformance() 2025-06-17 09:16:26 -04:00
Stephen Canon
1e02b3b596 Quick support for calling extern c functions with Builtin vector types. (#82225)
This gives us a means to use llvm's intrinsics that implement more niche
SIMD instructions from the standard library, where we cannot use the C
intrinsics headers from clang (because they're in the cpp module).
2025-06-17 09:00:21 -04:00
Slava Pestov
de3fb02bf5 Merge pull request #82238 from slavapestov/coding-keys-parameter-pack
Sema: Relax enum parameter pack restriction for CodingKeys
2025-06-17 07:48:35 -04:00
Hamish Knight
6257828593 [AST] Replace type variables and placeholders in original ErrorTypes
Turns out we can also get solver-allocated original ErrorTypes through
type resolution. Given the original type is only used for
printing/debugging, let's just fold away any type variables and
placeholders into UnresolvedType (which print as placeholders). This
matches what `Solution::simplifyType` does.
2025-06-17 12:09:25 +01:00
Pavel Yaskevich
06be7bda39 [Concurrency] SE-0449: Implied conformances to nonisolated protocols make witnesses nonisolated
Even if the requirement is stated on an isolated protocol if the
conformance is implied by a nonisolated one all of the requirements
and witnesses should be nonisolated.
2025-06-17 00:05:16 -07:00
Pavel Yaskevich
e50acbf3d5 [Concurrency] SE-0449: nonisolated on a type should prevent isolation inference from protocol requirements
If a `nonisolated` type conforms to a global-isolated protocol
the witnesses to the protocol requirements should infer the
isolation from the protocol but instead be `nonisolated`.

Resolves: rdar://145519840
2025-06-16 21:28:41 -07:00
Andrew Trick
5a1d3a84a5 Merge pull request #82268 from atrick/infer-implicit-read
LifetimeDependence type check: infer trivial _read accessor
2025-06-16 21:10:35 -07:00
Anthony Latsis
faa7f67960 Merge pull request #82165 from AnthonyLatsis/jepa
{AST,Basic}Bridging: Use  `<swift/bridging>` and try directly bridging one of our enums
2025-06-17 04:52:41 +01:00
Nate Chandler
6e8170c34d [IRGen] Fix FixedArray of fixedSize 1 elt addring.
When a `FixedArray`'s fixed size is 1, it looks like `[1 x %Ty]`. Given
an array's address, performing an operation on each element's address
entail's indexing into the array to each element's index to produce an
element's address for each index.  That is true even when the array
consists of a single element.  In that case, produce an address for that
single element by indexing to index 0 into each passed-in array.

rdar://151726387
2025-06-16 20:34:41 -07:00
Joe Groff
761faaa169 SILGen: Handle struct fields and addressors as addressable storage.
When accessing stored properties out of an addressable variable or parameter
binding, the stored property's address inside the addressable storage of the
aggregate is itself addressable. Also, if a computed property is implemented
using an addressor, treat that as a sign that the returned address should be
used as addressable storage as well. rdar://152280207
2025-06-16 20:23:47 -07:00
Sima Nerush
7e42a19187 [Concurrency] Make sure to still infer global actor if the conformance kind is explicit. 2025-06-16 13:59:15 -07:00
Sima Nerush
4fca62a771 [Concurrency] Look for explicit 'nonisolated' when getting isolation from protocol conformances. 2025-06-16 13:59:15 -07:00
Pavel Yaskevich
64404f5b7d Merge pull request #82229 from xedin/rdar-152689053
[Concurrency] NonisolatedNonsendingByDefault: Except `@Test` test-cases and `$` prefixed declarations from migration
2025-06-16 13:42:17 -07:00
Cyndy Ishida
64168edbf5 [Modules] Allow implicit conversions when loading interfaces with invalid os versions (#82228)
Initially, the compiler rejected building dependencies that contained OS
versions in an invalid range. However, this happens to be quite
disruptive, so instead allow it and request that these versions be
implicitly bumped based on what `llvm::Triple::getCanonicalVersionForOS`
computes.

resolves: rdar://153205856
2025-06-16 12:46:32 -07:00
Hamish Knight
060c9f4c5f Merge pull request #82237 from hamishknight/cod-cycle
[Sema] Scale back CodingKeys hack in `TypeChecker::lookupUnqualifiedType`
2025-06-16 20:37:35 +01:00
Anthony Latsis
b40b192227 ASTBriding: Bridge swift::DiagnosticKind directly 2025-06-16 19:11:35 +01:00
Anthony Latsis
106d5f4461 {AST,Basic}Bridging: Use SWIFT_COMPUTED_PROPERTY 2025-06-16 19:11:32 +01:00