2176 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
d5a8982db5 Merge remote-tracking branch 'origin/main' into rebranch 2025-07-01 00:37:27 -07:00
Pavel Yaskevich
907606ef28 [Serialization] A temporary fix for LocatableType
Gracefully handle `LocatableType` types if they show up during
serialization. This is a temporary fix until we can remove
`TransitivelyConformsTo` constraint from the solver which is
the underlying cause of the issue (see https://github.com/swiftlang/swift/pull/82541).

Resolves: rdar://153461854
2025-06-30 14:53:36 -07: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
Meghana Gupta
d1a97f1b0d Merge pull request #81879 from meg-gupta/fixdeserialization
Fix deserialization of lifetime dependencies on ast function types
2025-06-03 08:56:54 -07: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
Pavel Yaskevich
bc61bfb442 [Serialization] Prevent using declarations from being serialized 2025-05-31 11:10:39 -07:00
Pavel Yaskevich
aabfebec03 [AST] Add new declaration - using
Initially this declaration is going to be used to determine
per-file default actor isolation i.e. `using @MainActor` and
`using nonisolated` but it could be extended to support other
file-global settings in the future.
2025-05-30 00:39:06 -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
Hamish Knight
d672f750e7 [Basic] Rename abortWithPrettyStackTraceMessage to ABORT
Turn it into a wrapping macro that includes the file location, and
move into `Assertions.h`.
2025-05-19 20:55:01 +01: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
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
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
Hamish Knight
8834f6c4c7 Merge pull request #80496 from hamishknight/message-in-a-crash-log
[Mangler] Include verification errors in the crash log
2025-04-07 17:03:18 +01:00
Pavel Yaskevich
bf19481ab6 [Frontend/Serialization] Remove ExtensibleEnums experimental flag
For now the semantics provided by `@extensible` keyword on per-enum
basis. We might return this as an upcoming feature in the future with
a way to opt-out.
2025-04-03 16:30:23 -07:00
Hamish Knight
54023f85e7 [Basic] Introduce abortWithPrettyStackTraceMessage
Introduce a convenience for aborting while printing a given message
to a frame of the pretty stack trace. Use this in the existing places
where we're currently doing this.
2025-04-03 15:59:48 +01: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
Alejandro Alonso
dccbcf3cd7 Merge pull request #80318 from Azoy/fix-inline-array-sugar-serialization
[Serialization] Fix serialization for InlineArray sugar
2025-03-27 09:34:16 -07:00
Alejandro Alonso
b5e8f495f7 Fix serialization for InlineArray sugar 2025-03-26 12:37:34 -07:00
Slava Pestov
32514119df Serialization: Add an assertion 2025-03-26 10:55:23 -04:00
Nate Chandler
a3ba93609e [DefaultOverrides] SIL de/serialization. 2025-03-25 07:22:40 -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
Allan Shortlidge
3af72e4dca Serialization: Skip invalid @available attributes during lazy serialization.
When performing lazy module serialization, we may be making the first attempt
to turn an `AvailableAttr` into a `SemanticAvailableAttr`. If it turns out the
attribute is invalid at that point, we need to skip it instead of assuming
that the attribute will always be valid there.

Resolves rdar://147539902.
2025-03-21 15:45:53 -07:00
Doug Gregor
6eb79052f6 [Isolated conformances] Infer main actor isolation under UnspecifiedMeansMainActorIsolated
When code in the current module defaults to main actor (under SE-0466),
also infer main-actor isolation for protocol conformances of main-actor
isolated types.
2025-03-12 23:18:34 -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
Erik Eckstein
d225c47d25 AST: rename OpenArchetypeType -> ExistentialArchetypeType
NFC
2025-03-11 20:21:46 +01:00
Michael Gottesman
04bb69f426 Merge pull request #79727 from gottesmm/pr-025c1133954b74e7b4eda77e1a6f3bcafd4eb6cf
[concurrency] Add initial support for SwiftSettings to control defaultIsolation at the file level.
2025-03-10 22:35:00 -07:00
Michael Gottesman
f64dd5a8d5 [concurrency] Add initial support for SwiftSettings to control defaultIsolation at the file level.
We introduce a new macro called #SwiftSettings that can be used in conjunction
with a new stdlib type called SwiftSetting to control the default isolation at
the file level. It overrides the current default isolation whether it is the
current nonisolated state or main actor (when -enable-experimental-feature
UnspecifiedMeansMainActorIsolated is set).
2025-03-10 17:33:45 -07:00
Rintaro Ishizaki
002d7d7cdf [Parse/AST] Remove PoundDiagnosticDecl
There is no reson to make a AST node for '#error' and '#warning'
directives. Parser knows the diagnostics should be emitted or not.
2025-03-07 21:48:01 -08:00
Artem Chikin
de26e960e2 Rename '_const' attribute to 'CompileTimeLiteral'
To pave the way for the new experimental feature which will operate on '@const' attribute and expand the scope of what's currently handled by '_const' without breaking compatibility, for now.
2025-03-04 07:30:02 -08:00
Doug Gregor
7aac28e64b [Serialization] Add the STRICT_MEMORY_SAFETY record type. 2025-02-26 15:29:46 -08:00
Pavel Yaskevich
3cc24f7c19 [Serialization] Serialize a flag that indicates whether ExtensibleEnum feature is supported by a module
When `ExtensibleEnums` flag is set, it's going to be reflected in
the module file produced by the compiler to make sure that consumers
know that non-`@frozen` enumerations can gain new cases in the
future and switching cannot be exhaustive.
2025-02-25 00:05:21 -08:00
Usama Hameed
500187cf1e Add support for serializing debug_value instructions (#78056)
This patch adds support for serialization of debug value instructions. Enablement is currently gated behind the -experimental-serialize-debug-info flag.

Previously, debug_value instructions were lost during serialization. This made it harder to debug cross module inlined functions.
2025-02-24 20:21:15 -08:00
Joe Groff
f778170cfb Merge pull request #79351 from jckarter/lifetime-dependence-lowering
SIL: Lower lifetime dependencies when lowering function types.
2025-02-17 07:51:20 -08:00
Joe Groff
c65475628f SIL: Lower lifetime dependencies when lowering function types.
Map the lifetime dependencies described in terms of the formal AST-level parameters
to the correct parameter(s) in the lowered SIL function type. There can be 0, 1,
or many SIL parameters per formal parameter because of tuple exploding. Also,
record which dependencies are on addressable parameters (meaning that the dependency
includes not only the value of the parameter, but its specific memory location).
2025-02-14 09:47:53 -08:00