Commit Graph

2556 Commits

Author SHA1 Message Date
Allan Shortlidge 75ee444a94 Sema: Add source loc to implicit CGFloat/Double conversion.
This ensures MemberImportVisibility diagnostics about missing imports of
CoreFoundation for `CGFloat.init(_:)` get a source location.

Resolves rdar://177380270.
2026-05-19 14:50:32 -07:00
Xi Ge 4f60cc6e6e Merge pull request #89057 from nkcsgexi/hidden-type 2026-05-13 06:38:57 -07:00
Xi Ge 08776427a1 [AST] Introduce HiddenType for mangled-name placeholders
HiddenType is a new TypeBase subclass that carries a mangled name
without leaking the actual type definition. It serves as a type-slot
placeholder for stored-property types that have been elided from a
serialized binary module, so that the client side can either

(1) resolve this mangled name to the real type if the client has access to the owning module, or

(2) use the mangled name as a key to query abstract layout information also serialized in the binary module.

As an example — a library with a hidden field of a bridging-imported type:

```
    // Utility.h (internal bridging header)
    //   typedef struct { int value; } Wrapper;

    public struct S {
      private var w: Wrapper
      public var weight: Double
    }

  In the serialized module, the client's view reconstructs as:

    public struct S {
      private var w: @_hidden("$sSo7Wrappera")
      public var weight: Double
    }
```
2026-05-12 17:13:14 -07:00
Slava Pestov 97d6221295 Sema: Remove redundant call to setType() 2026-05-08 15:46:19 -04:00
Slava Pestov 2caba51bc0 Sema: Remove unused variable from buildArgumentListForDynamicMemberLookupSubscript() 2026-05-08 15:46:19 -04:00
Slava Pestov fa2448b4ff Sema: Migrate dynamic member lookup to use matchCallArguments() 2026-05-08 15:46:18 -04:00
Itai Ferber f448191d34 Support additional args in @dynamicMemberLookup subscripts
Adds support for `SubscriptDecl`s to fulfill `@dynamicMemberLookup`
requirements if they have additional arguments after `dynamicMember:` so
long as those arguments have default values, or are variadic.

This allows exposing values like `#function`, `#fileID`, `#line`, etc.
to dynamic member lookup.
2026-05-08 15:46:17 -04:00
Ben Cohen c9c9000b20 MiscDiagnostics: handle implicit callee in fixItEncloseTrailingClosure (#88860)
When a CallExpr's callee is implicit (e.g. `callAsFunction`),
`fn->getEndLoc()` collapses to the call site's location, so the
bare-trailing-closure path could compute `lastLoc` at or past the
closure's start. The resulting `fixItReplaceChars(lastLoc,
closureRange.Start, ...)` produced a degenerate SourceRange that crashed
the Swift-syntax-aware diagnostic renderer when constructing
`Range<AbsolutePosition>`. Detect that case and fall back to a plain
insertion at the closure's start.

fixes rdar://170779809
2026-05-07 05:51:55 -07:00
Konrad Malawski 3beefe5bd8 Rename CallerIsolationInheriting -> NonisolatedNonsending 2026-04-28 09:21:23 -07:00
Hamish Knight 178a528fd5 Merge pull request #88013 from hamishknight/more-call-per-call
[CS] Better handle rewriting implicit `callAsFunction` call splitting
2026-03-23 18:15:41 +00:00
Hamish Knight aa38700de6 [CS] Assert correct number of args in coerceCallArguments
We were previously getting away with passing an argument list with
more arguments than were being bound by parameters.
2026-03-21 13:45:27 +00:00
Hamish Knight 54c0870a25 [CS] Better handle rewriting implicit callAsFunction call splitting
The previous logic was relying on doing `coerceCallArguments` with the
full argument list instead of only the non-trailing args, and wasn't
handling the non-shorthand-init case. Update the logic to fix-up the
apply during the pre-walk, ensuring it gets applied consistently.

rdar://170076966
2026-03-21 13:45:27 +00:00
Hamish Knight c065d18d6f [CS] Remove a bit of unnecessary logic from finishApply
We already have the callee locator and callee computed.
2026-03-21 13:45:27 +00:00
Slava Pestov e7a94ee205 AST: Remove TypeBase::hasDependentMember()
I need to free up a bit.
2026-03-21 08:48:47 -04:00
Slava Pestov c197635ad9 AST: Factor out ASTContext::get{CGFloat,Double}InitDecl() from CSApply.cpp
Also, since the mock SDK's implementation of CGFloat is wrong,
update some existing tests to use the real SDK instead. This
exposed a few instances where the behavior was not as intended;
I added FIXME comments explaining what's going on.
2026-03-20 15:56:32 -04:00
Pavel Yaskevich 25dbbd3db2 Merge pull request #87778 from xedin/rdar-171146729
[CSApply] Don't use special isolation erasure for global-actor to `@i…
2026-03-11 13:10:25 -07:00
Pavel Yaskevich 5097a86b88 [CSApply] Don't use special isolation erasure for global-actor to @isolated(any) conversions
Regular `FunctionConversionExpr` handles that correctly and
`ActorIsolationErasureExpr` should only be used for cases when
the resulting type is `nonisolated`.

Resolves: rdar://171146729
2026-03-10 20:21:17 -07:00
Slava Pestov 601e253fd8 Sema: Inline findResolvedMemberRef() into its only caller 2026-03-10 14:47:30 -04:00
Artem Chikin b6e9e5c7ba [Literal Expressions] Introduce expression-based generic arguments
Introduce new syntax for parsing arbitrary integer literal expressions for generic value arguments:
```swift
InlineArray<(<Expr>), T>
[(<Expr>) of T]
```
Which, for now, will co-exist alongside the current syntax of simple integer literals.

Replace `IntegerTypeRepr` with `GenericArgumentExprTypeRepr`, a new `TypeRepr` node that wraps arbitrary expressions in generic argument positions (e.g., `InlineArray<(1 + 3), Int>`). The node tracks resolution state, distinguishing whether the expression resolved to a type or an integer value.

Key changes:
- Parse parenthesized generic arguments as expressions
- Recover and distinguish types from integer expressions in `resolveGenericArgumentExprTypeRepr`.
- When the `LiteralExpressions` feature is enabled, type-check and constant-fold expressions to integer values
- Extract `PreCheckTarget` into a public header to expose `simplifyTypeExpr` for use during type resolution

Resolves rdar://168005391
2026-02-24 14:10:39 +00:00
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