Commit Graph

2537 Commits

Author SHA1 Message Date
Aidan Hall 978baeaf14 Merge pull request #87085 from aidan-hall/closure-lifetimes
Basic support for closures with lifetime dependencies
2026-02-10 22:03:08 +00:00
Anthony Latsis 85db41932d Switch ASTContext::isLanguageModeAtLeast to LanguageMode 2026-02-10 16:06:58 +00:00
Aidan Hall d000346824 LifetimeDependence: Inference for closure expressions
This allows us to coerce closure expressions to function types with lifetime
dependencies.

Since captures are added to the parameter list when lowering closures to SIL
functions, we also need to update the result index when lowering their lifetime
dependencies.
2026-02-10 11:23:58 +00:00
Kavon Farvardin ae77ba81e3 Merge pull request #87013 from kavon/revert-84789
Back out #84789 after additional testing
2026-02-06 02:58:00 -08:00
Kavon Farvardin d5f9a1eeeb Revert "Merge pull request #84789 from nickolas-pohilets/mpokhylets/fix-82618"
This reverts commit b633bd37ac, reversing
changes made to b27bb64b03.
2026-02-05 11:34:59 -08:00
Pavel Yaskevich 613f4eafa2 [Concurrency] Fix thunk emission for function types with isolated parameters
This is important for things like instance methods of actors in
particular because otherwise it won't be possible to compute a
correct isolation for the thunk.

This fix enables fully unapplied references to actor-isolated
instance methods and other functions with isolated parameters.

Resolves: rdar://148395744
2026-01-30 14:55:42 -08:00
Hamish Knight 1bff51d40d [AST] NFC: Introduce isAtLeastFutureMajorLanguageMode
And use it for clients checking for the next future major language mode.
2026-01-27 23:30:43 +00:00
Hamish Knight de91fd77ec [CS] Remove some now-unnecessary for loop logic
We no longer need to track the `ForEachStmtInfo` in the
`SyntacticElementTarget`, and we can remove the special diagnostic
logic for `next` and `makeIterator` since those are type-checked
separately now.
2026-01-23 15:17:29 +00:00
Elsa Keirouz f7c21941b8 [AST] ForEachStmt: rename sequence getter/setter 2026-01-23 15:17:29 +00:00
Elsa Keirouz d54a572f7f [Sema] desugar ForEachStmt at AST level 2026-01-23 15:17:29 +00:00
Mykola Pokhylets 551a2cec6c Using ClosureExpr instead of ConversionPair in CollectionUpcastConversionExpr 2026-01-20 14:49:56 +01:00
Slava Pestov 6c1978ef9e Sema: Fix edge case where we form curry thunk for immediately-called constructor 2025-12-19 10:49:12 -05:00
Anthony Latsis 153dd02cd8 Merge pull request #85833 from swiftlang/jepa-main
[NFC] "SwiftVersion" → "LanguageMode" in `DiagnosticEngine::warnUntilSwiftVersion`, etc.
2025-12-05 09:34:30 +00:00
Anthony Latsis 88220a33c3 [NFC] "SwiftVersion" → "LanguageMode" in DiagnosticEngine::warnUntilSwiftVersion, etc. 2025-12-04 15:11:07 +00:00
Hamish Knight 019520b25f Merge pull request #85740 from hamishknight/out-of-place
Rework emission of EditorPlaceholderExprs
2025-12-02 23:25:40 +00:00
Hamish Knight 3861d58175 [CS] Remove CTP_CannotFail
This is now unused.
2025-11-30 11:12:39 +00:00
Hamish Knight ae82b29e35 Rework emission of EditorPlaceholderExprs
Rather than synthesizing a semantic expression to emit, add a compiler
intrinsic to the stdlib that is simple enough to just SILGen the
emission.
2025-11-30 11:12:39 +00:00
Hamish Knight ae2a18b3c8 [CS] Remove a use of typeCheckExpression in CSApply
We can just use `coerceToType` here.
2025-11-30 11:03:03 +00:00
Hamish Knight 9a31ef029c [CS] NFC: Remove CTP_ComposedPropertyWrapper
This has been unused since we added a custom `AllowWrappedValueMismatch`
fix.
2025-11-16 18:31:55 +00:00
Hamish Knight 6abfea9312 [CS] NFC: Remove CTP_CalleeResult
This has been unused since the removal of CSDiag.
2025-11-16 18:29:37 +00:00
Slava Pestov 64f2d1acce AST: Rename mapConformanceOutOfContext() => mapConformanceOutOfEnvironment(), mapReplacementTypesOutOfContext() => subs.mapReplacementTypesOutOfEnvironment() 2025-11-12 14:48:19 -05:00
Slava Pestov 819738c83e AST: Rename mapTypeIntoContext() => mapTypeIntoEnvironment(), mapTypeOutOfContext() => mapTypeOutOfEnvironment() 2025-11-12 14:48:19 -05:00
Pavel Yaskevich 8e9048aeba [CSApply] NFC: Unify transform for expressions with a single sub-expression
Copy, Borrow, {Any, Optional}Try, VarargExpansion expressions
have to perform the same transformation - resolve the type and
use it to coerce their sub-expression. This change introduces a
single method to do just that instead of copying the same code
around.
2025-10-30 08:48:19 -07:00
Pavel Yaskevich 66ad2a97b9 [CSApply] NFC: Simplify solution application to try expressions
Since `try!` now forces l-value -> r-value conversion during
CSGen, let's simplify solution application to `try` expressions
by coercing sub-expression to a type of a `try` itself which
would introduce all necessary loads.
2025-10-30 00:02:44 -07:00
Hamish Knight 6a7bf6fef5 Merge pull request #85188 from hamishknight/tuple-trouble
[CS] Upgrade a couple of tuple warnings to error for future lang mode
2025-10-29 23:34:22 +00:00
Hamish Knight 00d8774032 [Sema] Upgrade tuple shuffle warning to error in future lang mode
This has been deprecated for a while now, flip it to an error for a
future language mode.
2025-10-29 15:14:23 +00:00
Hamish Knight 24347812f5 [Diag] Reword the tuple shuffle diagnostic
"reorder" seems a bit less jargony than "shuffle", and include the 
labels that are being reordered.
2025-10-29 15:14:23 +00:00
Slava Pestov 2ba29d3806 Merge pull request #85183 from slavapestov/fix-issue-85034
Sema: Don't coerce subexpression of 'try' to rvalue
2025-10-29 07:20:27 -04:00
Slava Pestov f014a9aeec Sema: Don't coerce subexpression of 'try' to rvalue
The change in 8ab8b2e3e9, was too
broad. We want to coerce the subexpression of `try!` to an rvalue,
but not the subexpression of a `try`.

If the subexpression of a `try` becomes an rvalue even though the
type of the parent expression is an lvalue, we can end up with
infinite recursion in coerceToType(), as demonstrated by the
test case.

Fixes https://github.com/swiftlang/swift/issues/85034.
2025-10-28 19:21:35 -04:00
Becca Royal-Gordon 393965090e Merge pull request #34556 from beccadax/mod-squad-2
[SE-0491] Implement lookup and diagnostics for module selectors (MyMod::someName)
2025-10-28 16:00:26 -07:00
Hamish Knight 05e3d15955 [CS] Propagate CSApply failures in a few more places
We had some cases where we weren't propagating failures to apply the
solution, and as such weren't invalidating the resulting AST. Fix up
these cases.
2025-10-26 14:49:17 +00:00
Becca Royal-Gordon e662993a08 [NFC] Audit some DeclName➡️DeclNameRef conversions
Adds comments explaining why these conversions aren’t lossy.
2025-10-24 16:23:33 -07:00
Pavel Yaskevich 2b7adbc4ff Merge pull request #84800 from xedin/remove-csapply-operator-devirt
[CSApply] Don't attempt operator devirtualization
2025-10-18 23:09:23 +09:00
Pavel Yaskevich 9d00c7bd18 [CSApply] Don't attempt operator devirtualization
This appears to only support synthesized conformances because
operators in such cases use different names - `__derived_*`.

These days devirtualization like this is performed as part of
mandatory inlining. And this approach doesn't stack well with
features like `MemberImportVisibility` because there is change
to check whether witness is available or not.
2025-10-10 16:31:11 -07:00
Tim Kientzle 4c0b58096e Make _InlineArray subject to the same optimizations as InlineArray 2025-10-10 14:06:14 -07:00
Hamish Knight 5171b84dba [CS] Replace UnresolvedType with ErrorType in simplifyType/resolveType
This means we now either produce a bare ErrorType, or an ErrorType
with a generic parameter original type for a generic parameter hole.
We ought to further consolidate this logic by sinking the generic
parameter original type replacement into `simplifyType` itself, but
I'm leaving that for a future patch since it affects completion
results and I want to try keep this close to NFC.
2025-10-03 09:50:42 +01:00
Slava Pestov d3a8a9a862 Merge pull request #84628 from slavapestov/tiny-fuzzer-fixes
Two minor fixes for issues discovered by the fuzzer
2025-10-01 20:13:25 -04:00
Slava Pestov 5cc9b9b237 Sema: Don't crash if a property with an opaque result type has both an initial value and a getter 2025-10-01 14:48:51 -04:00
Slava Pestov 5be227a9b9 Sema: Fix the same bug with subscripts as well
Fixes rdar://161588385.
2025-10-01 01:19:32 -04:00
Slava Pestov 782d68fc99 Sema: Fix malformed AST when both DynamicSelfType and opened existentials are involved
This worked for functions, but for properties, we did things in
the wrong order.

Fixes rdar://160816868.
2025-09-30 13:42:03 -04:00
Allan Shortlidge 2467b931a7 ConstraintSystem: Move key path type utilities to AST. 2025-09-25 07:13:17 -07:00
Doug Gregor 9bdd7db739 Eliminate a null pointer dereference 2025-09-18 12:55:33 -07:00
Doug Gregor ade6e55b0c [Embedded] Diagnose uses of generic methods on existential values
Generic methods declared in protocols (and extensions thereof) cannot
be used on existential values, because there is no way to specialize
them for all potential types. Diagnose such cases in Embedded Swift
mode and via `-Wwarning EmbeddedRestrictions`.

This adds a bunch more warnings to the standard library that we'll
need to clean up, probably by `#if`'ing more code out.

Part of rdar://119383905.
2025-09-18 10:05:35 -07:00
Hamish Knight 3484f63ca1 [CS] Strengthen a couple of CSApply assertions
Enforce that we don't ever encounter solutions that contain holes or
error types.
2025-09-17 16:11:53 +01:00
Slava Pestov 90bfc1676d Sema: Remove some unreachable code from CSApply
I believe these code paths could only be reached by re-typechecking
invalid code in the old CSDiag implementation.
2025-09-17 16:11:53 +01:00
Hamish Knight a7c0460877 [CS] Record IgnoreInvalidASTNode for invalid key path component
And ensure we don't end up with invalid key paths in CSApply.
2025-09-17 16:11:53 +01:00
Slava Pestov d6fb460bde Sema: Clean up curry thunk logic in buildMemberRef() 2025-09-10 19:26:02 -04:00
Slava Pestov 59b7599f8a Sema: Simplify handling of DynamicSelfType in buildSingleCurryThunk() 2025-09-10 19:25:37 -04:00
Slava Pestov 27c52eb4a9 Sema: Clean up buildOtherConstructorRef() 2025-09-09 18:58:09 -04:00
Slava Pestov 9e2d4c520f Sema: More DynamicSelfType cleanup 2025-09-09 18:58:09 -04:00