2525 Commits

Author SHA1 Message Date
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
Slava Pestov
af3b5e8e3b Sema: Clean up getMemberReferenceTypeFromOpenedType() 2025-09-08 10:31:49 -04:00
Slava Pestov
ab4e754ef9 Sema: Don't stick CovariantReturnConversionExpr around property access with DynamicSelfType base
It could be that refTy->hasDynamicSelfType() is true whereas
varDecl->getValueInterfaceType()->hasDynamicSelfType() is false.
This happens if the base of the access is dynamic Self, so the
refTy is (Self) -> @lvalue Int or whatever.

Note that replaceDynamicSelfType() behaves correctly in this case;
it leaves that Self in place, because it's in contravariant
position.

However, the other place where we check the condition would then
form a nonsensical CovariantReturnConversionExpr around the result
of the access, even though no conversion was necessary here; the
type of the returned value does not involve Self.

Simplify this logic further with the correct condition.

Fixes rdar://159531634.
2025-09-08 10:31:27 -04:00
Hamish Knight
cac98f3a18 Merge pull request #84142 from hamishknight/for-none
[CS] NFC: Remove `CTP_ForEachStmt`
2025-09-06 22:43:28 +01:00
Hamish Knight
71d825dcb8 [CS] NFC: Remove CTP_ForEachStmt 2025-09-05 22:20:28 +01:00
Slava Pestov
aa3a0756f4 Merge pull request #84115 from slavapestov/remove-covariant-result-type
Remove TypeBase::replaceCovariantResultType()
2025-09-05 07:40:34 -04:00
Slava Pestov
55082c4eea Sema: Split off buildVarMemberRef() from buildMemberRef() 2025-09-04 18:07:46 -04:00
Slava Pestov
1ddcdc74d4 Sema: Convert conditional into an assert 2025-09-04 17:54:00 -04:00
Slava Pestov
250e3fd08b Sema: Split off buildStaticCurryThunk() from buildMemberRef() 2025-09-04 17:53:14 -04:00
Slava Pestov
d81fbd6c63 Sema: Split off buildDynamicMemberRef() from buildMemberRef() 2025-09-04 17:46:40 -04:00
Slava Pestov
853f50c90d Sema: Remove usage of replaceCovariantResultType() 2025-09-04 17:24:07 -04:00
Hamish Knight
7fb532e4e6 Merge pull request #83776 from hamishknight/the-diags-never-stop-no
[Diags] Allow multiple in-flight diagnostics
2025-09-03 19:59:44 +01:00
Hamish Knight
a9e339b973 [CS] Strengthen check for completion in CSApply
Turns out we don't always set a completion callback for some unqualified
completion positions. Upgrade the check for a completion callback to
a check for a completion buffer to account for this. This avoids
unnecessary type-checker work as well as fixing a couple of
double-type-checking crashers.
2025-08-29 16:20:06 +01:00