3572 Commits

Author SHA1 Message Date
Hamish Knight
f7e459a9b5 [AST] Factor out GenericSignature::forInvalid
Factor out the common logic from `getPlaceholderGenericSignature`.
2025-10-08 21:16:02 +01:00
Slava Pestov
244d2afea3 RequirementMachine: New way of propagating failure when building rewrite system for protocol
If we failed to construct a rewrite system for a protocol, either because
the Knuth-Bendix algorithm failed or because of a request cycle while
resolving requirements, we would end up in a situation where the resulting
rewrite system didn't include all conformance requirements and associated
types, so name lookup would find declarations whose interface types are
not valid type parameters.

Fix this by propagating failure better and just doing nothing in
getReducedTypeParameter().

Fixes rdar://147277543.
2025-10-04 09:17:46 -04:00
Mishal Shah
03a599c5be Merge pull request #84606 from swiftlang/rebranch
Merge clang 21.x rebranch into main
2025-10-02 20:17:05 -07:00
Arnold Schwaighofer
3447bd1b31 Change implementation to infer @inlinable semantics from @inline(always) on public declarations 2025-09-30 08:36:32 -07:00
swift-ci
0d2c4ca9be Merge remote-tracking branch 'origin/main' into rebranch 2025-09-15 10:29:21 -07:00
Meghana Gupta
c764244df0 Merge pull request #84180 from meg-gupta/borrowandmutatepr
Add preliminary support for borrow accessors
2025-09-15 10:01:15 -07:00
swift-ci
48eb65ee53 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-11 08:04:53 -07:00
Slava Pestov
507f7617ea AST: Remove AbstractFunctionDecl::hasDynamicSelfResult() 2025-09-10 19:26:02 -04:00
swift-ci
f22ddb12f6 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-10 06:55:39 -07:00
John McCall
e5b6a88c5e Merge pull request #84181 from rjmccall/isolation-fixes
Isolation fixes for closures and defer bodies
2025-09-10 08:39:09 -04:00
swift-ci
95736f8e88 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-10 01:39:11 -07:00
Hamish Knight
f8218e3254 Merge pull request #83777 from hamishknight/ext-cleanup
[Sema] Clean up extension binding a little
2025-09-10 09:37:20 +01:00
Hamish Knight
17fe3de8c7 [Sema] Clean up extension binding a little
- Turn `BindExtensionsForIDEInspectionRequest` into the main extension
binding request.
- Change `ExtendedNominalRequest` such that it's no longer what
extension binding calls into to do the name lookup, instead it calls
directly into `computeExtendedNominal`. `getExtendedNominal` can
then be the entrypoint for `ExtendedNominalRequest` and assumes that
extension binding has already run. This avoids needing to fake the
dependency relationship in the DeclChecker.
2025-09-09 23:18:52 +01:00
Meghana Gupta
280fc83292 Avoid synthesizing read when borrow is present and modify when mutate is present 2025-09-09 14:45:07 -07:00
Meghana Gupta
9fe489ce22 Introduce borrow and mutate as new accessor kinds
And handle them in various covered switches
2025-09-09 14:30:26 -07:00
John McCall
c7cad4ba54 Add a function for querying the isolation of an Initializer. 2025-09-09 14:26:57 -04:00
John McCall
367520cd3f Fix two bugs with the isolation of defer bodies.
The first bug is that we weren't computing isolation correctly for
nested defers. This is an unlikely pattern of code, but it's good to fix.

The second bug is that getActorIsolationOfContext was looking through
defers, but getActorIsolation itself was not. This was causing defer
bodies to be emitted in SILGen without an isolation parameter, which
meant that #isolation could not possibly provide the right value. Fixing
this involves teaching SILGen that non-async functions can have
nonisolated(nonsending) isolation, but that's relatively straightforward.

This commit doesn't fix #isolation or adequately test SILGen, but that'll
be handled in a follow-up.
2025-09-09 14:26:57 -04:00
John McCall
3088b85c2c Don't crash if there's a request cycle with DefaultArgumentExprRequest. 2025-09-09 14:26:57 -04:00
Hamish Knight
79fe1b3548 [AST] Remove findParentPatternCaseStmtAndPattern
Add the extra logic to `VarDecl::getParentPattern` necessary to
handle fallthrough and case body variables instead. This also changes
the behavior for case body vars - previously we would return the first
pattern in the CaseStmt, but that's not necessarily correct. Instead,
return the first pattern that actually binds the variable.
2025-09-09 13:48:40 +01:00
Hamish Knight
413824c082 [AST] Simplify getRecursiveParentPatternStmt
`findParentPatternCaseStmtAndPattern` does more work than is necessary
for this, we just want the parent of the canonical var.
2025-09-09 13:48:40 +01:00
Hamish Knight
84befd43ab [AST] Make case body variables for CaseStmt non-optional
We don't really care about the distinction between empty and nil here.
2025-09-09 13:48:40 +01:00
swift-ci
605811fda2 Merge remote-tracking branch 'origin/main' into rebranch 2025-08-29 00:13:26 -07:00
Kavon Farvardin
3bb8fa848a nfc: !isNoncopyable() -> isCopyable() 2025-08-28 12:13:21 -07:00
swift-ci
fd22790987 Merge remote-tracking branch 'origin/main' into rebranch 2025-08-18 05:56:12 -07:00
Doug Gregor
4ff65cc244 Merge pull request #83784 from DougGregor/never-emit-into-client
Add @_neverEmitIntoClient to prohibit SIL serialization for a function
2025-08-18 04:19:59 -07:00
Doug Gregor
2f60d729f0 Add @_neverEmitIntoClient to prohibit SIL serialization for a function
Part of the Embedded Swift linkage model, this attribute ensures that
the function it applies to has a strong definition in its owning
module, and that its SIL is never serialized. That way, other modules
will not have access to its definition.

Implements rdar://158364184.
2025-08-17 23:21:57 -07:00
swift-ci
ec2a539ee6 Merge remote-tracking branch 'origin/main' into rebranch 2025-08-15 01:15:19 -07:00
Slava Pestov
24ee8cf681 AST: Add typeCheckFunctionBodies parameter to getUniqueUnderlyingTypeSubstitutions() 2025-08-14 17:01:47 -04:00
Anthony Latsis
ece73d8004 Manually merge remote-tracking branch 'origin/main' into rebranch
Conflicts:
-	include/swift/AST/Decl.h
2025-08-07 15:31:16 +01:00
Allan Shortlidge
78f50ba741 AST: Refactor ConditionallyAvailableSubstitutions to use AvailabilityQuery.
Conditionally available opaque return types should support availability
conditions that are evaluated in any availability domain. Update
`ConditionallyAvailableSubstitutions` to model its conditions with
`AvailabilityQuery` instead of assuming that conditions are always a single
version query for the current platform.
2025-08-06 18:01:10 -07:00
swift-ci
3998a187f9 Merge remote-tracking branch 'origin/main' into rebranch 2025-07-30 09:36:41 -07:00
Anthony Latsis
3f841b515c Merge remote-tracking branch 'origin/main' into jepa-rebranch 2025-07-30 14:31:33 +01:00
Anthony Latsis
fec049e5e4 Address llvm::PointerUnion::{is,get} deprecations
These were deprecated in
https://github.com/llvm/llvm-project/pull/122623.
2025-07-29 18:37:48 +01:00
Allan Shortlidge
7d866bfe69 AST: Skip serializing non-public accessors of @backDeployed properties.
Avoids a crash in SILGen when skipping non-inlinable function bodies.

Resolves rdar://136853454.
2025-07-27 21:25:44 -07:00
swift-ci
367f0082fc Merge remote-tracking branch 'origin/main' into rebranch 2025-07-22 22:17:45 -07:00
Anthony Latsis
2920ea84d1 Address llvm::(Mutable)ArrayRef ctor deprecations
See:
- https://github.com/llvm/llvm-project/pull/146113
- https://github.com/llvm/llvm-project/pull/146011
2025-07-21 12:36:53 +01:00
Anthony Latsis
d71d0f92b4 Merge pull request #83188 from swiftlang/jepa-rebranch
[rebranch] Get rebranch swift-frontend building again
2025-07-19 21:51:16 +01:00
Anthony Latsis
c1d794364b Adjust code after changes to llvm::TrailingObjects API
See:
- https://github.com/llvm/llvm-project/pull/138970
- https://github.com/llvm/llvm-project/pull/144930
2025-07-19 01:48:18 +01:00
Allan Shortlidge
634f28176e AST: Move parentDeclForInferredAvailability() to Decl.
NFC.
2025-07-17 18:59:14 -07:00
Allan Shortlidge
d09e117dc0 AST: Canonicalize platform versions for @backDeployed attrs.
Also, diagnose invalid platform versions.

Part of rdar://155558161.
2025-07-14 16:40:16 -07:00
Allan Shortlidge
910989c2c2 AST: Store parsed version in OriginallyDefinedInAttr instead of canonical.
Canonicalize the version on-demand instead.

NFC, part of rdar://155558161.
2025-07-14 16:04:04 -07:00
Gábor Horváth
c33ce3f029 Merge pull request #82840 from Xazax-hun/unqualified-name-lookup-fix
[cxx-interop] Fix unqualified name lookup failure
2025-07-08 17:53:35 +01:00
Gabor Horvath
4de92656dd [cxx-interop] Fix unqualified name lookup failure
When MemberImportVisibility is enabled we failed to find certain base
methods from the extensions when said base methods are imported from
C++.

rdar://154887575
2025-07-08 12:41:01 +01:00
Pavel Yaskevich
dab6f3d12e Merge pull request #82807 from xedin/se-0487-implementation-adjustments
[AST/Sema] SE-0487: Adjust implementation based on the LSG feedback
2025-07-08 00:03:36 -07:00
Allan Shortlidge
a4f59f9481 AST: Return @backDeployed attribute along with version from Decl query.
Also, introduce a convenience on `BackDeployedAttr` for getting its associated
`AvailabilityDomain`.

NFC.
2025-07-06 19:44:53 -07:00
Pavel Yaskevich
fe1ae75711 [AST/Sema] SE-0487: Rename @extensible into @nonexhaustive
This is an accepted spelling for the attribute. This commit
also renames the feature flag from `ExtensibleAttribute` to
`NonexhaustiveAttribute` to match the spelling of the attribute.
2025-07-03 17:50:05 -07:00
Hamish Knight
3daae5955e [AST] Use ErrorType for invalid value generic parameter
If we fail to resolve the value type for a value generic parameter,
previously we would have returned a null Type, causing crashes
downstream. Instead, return an ErrorType, leaving a null Type for
cases where the generic parameter isn't a value generic at all.

rdar://154856417
2025-07-02 14:46:55 +01:00
Hamish Knight
1bd32a1a6b NFC: Constify GenericTypeParamDeclGetValueTypeRequest's parameter 2025-07-02 14:46:55 +01:00
QuietMisdreavus
1948907eb3 use RespectOriginallyDefinedIn when mangling extension contexts (#82348)
Resolves rdar://152598492

Consider the following Swift, adapted from a real-world framework:

```swift
@available(macOS 10.8, *)
@_originallyDefinedIn(module: "another", macOS 11.0)
public struct SimpleStruct {}

@available(macOS 12.0, iOS 13.0, *)
public extension SimpleStruct {
    struct InnerStruct {}
}
```

In this scenario, `SimpleStruct` was originally in a module called
`another`, but was migrated to this module around the time of macOS
11.0. Since then, the module was ported to iOS and gained a nested type
`SimpleStruct.InnerStruct`. When mangling USRs for this nested type, the
result differs depending on whether we're targeting macOS or iOS.
They're mostly the same, but the macOS build yields a USR with an `AAE`
infix, designating that the `InnerStruct` was defined in an extension
from a module with the name of the base module. On iOS, this infix does
not exist.

The reason this is happening is because of the implementation of
`getAlternateModuleName` checking the availability spec in the
`@_originallyDefinedIn` attribute against the currently active target.
If the target matches the spec, then the alternate module name is
reported, otherwise the real module name is. Since the iOS build reports
the real module name, the mangling code doesn't bother including the
extension-context infix, instead just opting to include the parent
type's name and moving on.

This PR routes around this issue by passing the
`RespectOriginallyDefinedIn` variable to the
`ExtensionDecl::isInSameDefiningModule` method, and using that to skip
the alternate module name entirely. It also sets
`RespectOriginallyDefinedIn` to `false` in more places when mangling
USRs, but i'm not 100% confident that it was all necessary. The goal was
to make USRs more consistent across platforms, regardless of the
surrounding context.
2025-06-30 12:57:12 -06:00
Alexis Laferrière
81a0f98783 Merge pull request #82194 from xymus/cdecl-parser
Parser: Accept `@cdecl` with an optional identifier for a custom C name
2025-06-27 15:06:11 -07:00