1627 Commits

Author SHA1 Message Date
swift-ci
2b8612c203 Merge remote-tracking branch 'origin/main' into rebranch 2025-07-08 00:16:43 -07:00
Pavel Yaskevich
43eec8fede [AST/Sema] SE-0487: Expand @nonexhaustive attribute to support warn argument
The spelling `@nonexhaustive(warn)` replaces `@preEnumExtensibility`
attriubte.
2025-07-04 10:20:25 -07:00
swift-ci
4668d6c04c Merge remote-tracking branch 'origin/main' into rebranch 2025-06-26 13:55:39 -07:00
Anthony Latsis
1f89bb6a94 Merge pull request #82452 from swiftlang/jepa2
Sema: Fix the insertion location for conformances attributes
2025-06-26 21:38:41 +01:00
Anthony Latsis
ad8c52237c Sema: Fix the insertion location for conformances attributes 2025-06-24 14:49:03 +01:00
swift-ci
1a1486e792 Merge remote-tracking branch 'origin/main' into rebranch 2025-06-23 22:18:31 -07:00
Meghana Gupta
adceb7abc3 Serialize/deserialize lifetime dependencies on enum elements 2025-06-23 13:42:54 -07:00
swift-ci
9a08a18af2 Merge remote-tracking branch 'origin/main' into rebranch 2025-06-20 15:45:44 -07:00
Anthony Latsis
3e9923f0c0 ASTBridging: Bridge swift::AccessorKind directly 2025-06-19 04:26:52 +01:00
Anthony Latsis
6e9d9e175d ClangImporter: Conservatively handle new clang::HLSLInlineSpirvType type
See https://github.com/llvm/llvm-project/pull/134034
2025-06-13 21:57:37 +01:00
Slava Pestov
71186eb07f AST: Call setExtendedNominal() instead of cacheOutput(ExtendedNominalRequest...) 2025-06-11 20:07:42 -04:00
Meghana Gupta
36f3574f9c Fix deserialization of lifetime dependencies on ast function types
While deserializing AST function types FunctionType and GenericFunctionType which include
lifetime dependencies and an implicit self parameter, we don't correctly populate
ASTExtInfoBuilder.lifetimeDependencies.  We end up reading one dependency less due to
incorrect index calculation.

Unlike SILFunctionType, AST function types FunctionType and GenericFunctionType
do not include implicit self in their param list. They represent methods with
implicit self as like: `(Self) -> (Args...) -> Result` and don't have any information
to indicate they may have implicit self. Since we use number of parameters while
deserializing lifetime dependencies, we go wrong for such function types.

Serialize the length of parameter indices, so that lifetime dependencies can be
deserialized to that length.

rdar://151768216
2025-06-02 17:29:05 -07:00
Arnold Schwaighofer
13ff5abdb8 Introduce @specialized attribute
Implements SE-0460 -- the non-underscored version of @specialized.

It allows to specify "internal" (not abi affecting) specializations.

rdar://150033316
2025-05-23 13:12:47 -07:00
Pavel Yaskevich
04d46760bb [AST] Extend @_inheritActorContext attribute to support optional always modifier
By default (currently) the closure passed to a parameter with `@_inheritActorContext`
would only inherit isolation from `nonisolated`, global actor isolated or actor
context when "self" is captured by the closure. `always` changes this behavior to
always inherit actor isolation from context regardless of whether it's captured
or not.
2025-05-14 20:07:57 -07:00
Becca Royal-Gordon
b6be85222f Standardize serialization of DeclNameRefs
There are four attributes which serialize out a DeclNameRef, sometimes by dropping some of its components. Standardize them with a representation that can handle module selectors.
2025-05-14 11:16:30 -07:00
Michael Gottesman
9d59dbed17 [swift-settings] Now that we aren't using it immediately, remove it from tree.
We can always get it back from the git history.

rdar://150695113
2025-05-05 13:39:03 -07:00
Slava Pestov
e1fc29193d AST: Add GenericTypeParamType::getWeight()
This is currently always 0, but can be set to 1.
2025-04-29 13:55:29 -04:00
Alexis Laferrière
a6beaf8deb Merge branch 'main' into cdecl-global-function-checking 2025-04-16 11:19:37 -07:00
Pavel Yaskevich
9bc96d4669 [AST] Mark parameter declarations as caller isolated
When `nonisolated(nonsending)` parameter specifier is present
mark the declaration as caller isolated.
2025-04-15 14:52:56 -07:00
Doug Gregor
f09cdc2893 Fix deserialization assertion involving isolated conformances 2025-04-13 15:42:00 -07:00
Pavel Yaskevich
07ff063ae3 [AST/ASTGen/Sema/Serialization] Remove @execution attribute
Complete the transition from `@execution` to `@concurrent` and `nonisolated(nonsending)`
2025-04-11 15:59:25 -07:00
Pavel Yaskevich
b1ffa063b6 [AST/Sema] Intoduce nonisolated(nonsending) as a replacement for @execution(caller) 2025-04-11 15:57:11 -07:00
Alexis Laferrière
79d304fcb3 Serialization: Read and write the underscored bit for @cdecl 2025-04-11 11:34:39 -07:00
Alexis Laferrière
02b5998536 Parser: Intro @cdecl attribute and gate it behind feature flag CDecl 2025-04-11 11:34:39 -07:00
Allan Shortlidge
94a8526526 Merge pull request #80616 from tshortli/availability-domain-serialization
Serialization: Encode custom availability domains
2025-04-08 22:39:03 -07:00
Alexis Laferrière
52ebd4a122 Merge pull request #80550 from xymus/deser-late-shadowing
Serialization: Bring back shadowing but only after the filtering
2025-04-08 10:01:31 -07:00
Allan Shortlidge
abac42b759 Serialization: Encode custom availability domains.
When serializing `@available` attributes, if the attribute applies to a custom
domain include enough information to deserialize the reference to that domain.

Resolves rdar://138441265.
2025-04-08 08:53:42 -07:00
Anthony Latsis
a0930dec31 AST: Cut down on DescriptiveDeclKind usage in DiagnosticsSema.def 2025-04-05 12:31:19 +01:00
Alexis Laferrière
f4dedc32b5 Serialization: Bring back shadowing but only after the filtering
Followup fix to #80009. We can still get ambiguities from colliding
decls across modules with the deserialization filtering. Bring back
calling the general lookup shadowing after the filtering. This way it
won't use filtered out decls to hide potential candidates.

rdar://148286345
2025-04-04 13:42:42 -07:00
Artem Chikin
281f84da0f [Compile Time Values] Rewrite the 'Diagnose Unknown Compile Time Values' diagnostic pass in Swift 2025-03-28 10:30:07 -07:00
Michael Gottesman
de7a62e13e Merge pull request #80312 from gottesmm/pr-126bc735b2d01c0f2f35f27268ff26d404b2fb16
[sil] Make SILFunctionTypeInfo a struct enum.
2025-03-26 18:05:57 -07:00
Becca Royal-Gordon
123447d160 Don’t add HasStorageAttr to ABI-only decls
It’s unnecessary, shouldn’t be serialized into module interfaces, and Swift doesn’t know how to compute it for an ABI-only decl since it doesn’t have accessors or an initial value.

No tests because enforcement isn’t in yet.
2025-03-26 10:47:14 -07:00
Michael Gottesman
8cfb029b5c [sil] Make SILFunctionTypeInfo a struct enum.
I am doing this in preparation for adding the ability to represent in the SIL
type system that a function is global actor isolated. Since we have isolated
parameters in SIL, we do not need to represent parameter, nonisolated, or
nonisolated caller in the type system. So this should be sufficient for our
purposes.

I am adding this since I need to ensure that we mangle into thunks that convert
execution(caller) functions to `global actor` functions what the global actor
is. Otherwise, we cannot tell the difference in between such a thunk and a thunk
that converts execution(caller) to execution(concurrent).
2025-03-26 10:23:44 -07:00
Slava Pestov
0155b41b50 AST: Extend @_originallyDefinedIn to allow specifying module name for linker directive purposes
The module name changes the symbol mangling, and also causes
TBDGen to emit linker directives. To separate out these two
behaviors, introduce a terrible hack. If the module name
contains a semicolon (`;`), the part before the semicolon
is the module name for mangling, and the part after the
semicolon is the module name for linker directives.

If there is no semicolon, both module names are identical,
and the behavior is the same as before.
2025-03-24 17:56:45 -04:00
Doug Gregor
731f58443c Address review feedback on AbstractConformance in ProtocolConformanceRef 2025-03-23 20:54:39 -07:00
Doug Gregor
2a7de1b559 Store the conforming type within an abstract ProtocolConformanceRef
An "abstract" ProtocolConformanceRef is a conformance of a type
parameter or archetype to a given protocol. Previously, we would only
store the protocol requirement itself---but not track the actual
conforming type, requiring clients of ProtocolConformanceRef to keep
track of this information separately.

Record the conforming type as part of an abstract ProtocolConformanceRef,
so that clients will be able to recover it later. This is handled by a uniqued
AbstractConformance structure, so that ProtocolConformanceRef itself stays one
pointer.

There remain a small number of places where we create an abstract
ProtocolConformanceRef with a null type. We'll want to chip away at
those and establish some stronger invariants on the abstract conformance
in the future.
2025-03-23 20:53:48 -07:00
Hamish Knight
f8ab391737 Introduce type sugar for InlineArray (#80087)
* [CS] Decline to handle InlineArray in shrink

Previously we would try the contextual type `(<int>, <element>)`,
which is wrong. Given we want to eliminate shrink, let's just bail.

* [Sema] Sink `ValueMatchVisitor` into `applyUnboundGenericArguments`

Make sure it's called for sugar code paths too. Also let's just always
run it since it should be a pretty cheap check.

* [Sema] Diagnose passing integer to non-integer type parameter

This was previously missed, though would have been diagnosed later
as a requirement failure.

* [Parse] Split up `canParseType` 

While here, address the FIXME in `canParseTypeSimpleOrComposition`
and only check to see if we can parse a type-simple, including
`each`, `some`, and `any` for better recovery.

* Introduce type sugar for InlineArray

Parse e.g `[3 x Int]` as type sugar for InlineArray. Gated behind
an experimental feature flag for now.
2025-03-23 15:31:37 -07:00
Alexis Laferrière
c9b586207d Serialization: Update recent uses of SET_OR_RETURN_ERROR 2025-03-19 16:25:48 -07:00
Alexis Laferrière
fe9c48cc8c Serialization: Protect getType for params and classes 2025-03-19 16:25:48 -07:00
Alexis Laferrière
06d2d4cb50 Serialization: Recover from missing raw types on an enum
Recover from a raw type hidden behind an internal or implementation-only
import by dropping the whole enum when the raw type is unavailable. This
scenario should happen only when looking at non-public decl for indexing or
debugging, or if dependencies somehow changed and left behind a stale
swiftmodule file.

rdar://147091863
2025-03-19 14:10:57 -07:00
Alexis Laferrière
10f95098ad Serialization: Rename macro to SET_OR_RETURN_ERROR and invert params
Rename the macro UNWRAP to SET_OR_RETURN_ERROR for clarity and invert its
parameters to have a more intuitive order of assignment target and then
expression.
2025-03-19 14:10:33 -07:00
Slava Pestov
9c657e440c Serialization: Fix a call to ProtocolConformanceRef::forAbstract() 2025-03-18 19:38:43 -04:00
Alexis Laferrière
7ae7371b62 Merge pull request #80009 from xymus/deser-internal-shadow
Serialization: Ignore lookup shadowing when resolving cross-references
2025-03-18 10:42:38 -07:00
Alexis Laferrière
18eb4e43e4 Serialization: Skip lookup shadowing when resolving cross-references
When a Swift function shadows a clang function of the same name, the
assumption was that Swift code would refer only to the Swift one.
However, if the Swift function is `@usableFromInline internal` it can be
called only from the local module and inlined automatically in other
clients. Outside of that module, sources see only the clang function, so
their inlinable code calls only the clang function and ignores the Swift
one. This configuration passed type checking but it could crash the
compiler at inlining the call as the compiler couldn't see the clang
function.

Let's update the deserialization logic to support inlined calls to the
shadowed or the shadower. Typical shadowing is already handled by the
custom deserialization cross-reference filtering logic which looks for
the defining module, scope and whether it's a Swift or clang decl. We
can disable the lookup shadowing logic and rely only on the
deserialization filtering.

rdar://146320871
https://github.com/swiftlang/swift/issues/79801
2025-03-14 12:35:18 -07:00
Doug Gregor
4cc6411d05 Merge pull request #79983 from DougGregor/isolated-conformances-alignment
Align isolated conformances with the current proposal
2025-03-13 22:40:36 -07:00
Alexis Laferrière
1392926139 Merge pull request #79927 from xymus/deser-protect-loadAllConformances
Serialization: Don't crash in loadAllConformances in extended recovery
2025-03-13 09:39:42 -07:00
Doug Gregor
0e873e723c [Isolated conformances] Change syntax to @<global actor type> P
Instead of using the `isolated P` syntax, switch to specifying the
global actor type directly, e.g.,

   class MyClass: @MainActor MyProto { ... }

No functionality change at this point
2025-03-12 23:18:10 -07:00
eeckstein
47b449372e Merge pull request #79917 from eeckstein/rename-opened-archetype-type
AST: rename OpenArchetypeType -> ExistentialArchetypeType
2025-03-12 06:01:10 +01:00
Alexis Laferrière
e4ad174a1d Serialization: Don't crash in loadAllConformances in extended recovery
In extended recovery mode we should recover from all errors without
crashing. Protect loadAllConformances and drop all conformance errors in
this mode.

rdar://81811394
2025-03-11 15:12:15 -07:00
Alexis Laferrière
c0a4056768 Merge pull request #79851 from xymus/deser-recover-conformance-xref
Serialization: Diagnose broken conformances from stale swiftmodule files
2025-03-11 15:07:38 -07:00