Commit Graph

2129 Commits

Author SHA1 Message Date
Anton Korobeynikov
797f500286 Add basic boilerplate for AST coroutines and yields 2025-11-12 21:02:25 -08:00
Pavel Yaskevich
30b207ecf4 Merge pull request #85418 from xedin/rdar-164267736
[AST/Serialization] A few fixes for `nonisolated(nonsending)` handling
2025-11-12 09:34:49 -08:00
Anthony Latsis
bda6edb85c AST: Rename GenericContext::isGeneric to hasGenericParamList
`isGeneric` is a misleading name because this method checks for the
existence of a `GenericParamList`, which is not implied by genericity.
2025-11-11 15:55:16 +00:00
Pavel Yaskevich
c3ea3031b9 [AST] Fix printing of nonisolated(nonsending) in parameter type positions
Printing shouldn't rely on parameter declaration bit because it only
works in cases when there is an explicit `nonisolated(nonsending)`
modifier on the type.

Always print `nonisolated(nonsending)` before `sending`, `@escaping`
and other declaration attributes/modifiers to avoid parsing issues.

Resolves: rdar://164267736
2025-11-10 11:31:24 -08:00
Pavel Yaskevich
5f91e49c9c Merge pull request #85105 from xedin/rdar-140928937
[AST/Sema] Allow `Sendable` suppression on Objective-C class declarations
2025-11-07 15:09:35 -08:00
Pavel Yaskevich
3ce0f941e8 Merge pull request #85187 from xedin/rdar-161739470
[AST] NonisolatedNonsendingByDefault: Print `@concurrent` on `nonisol…
2025-11-04 06:28:02 -08:00
Pavel Yaskevich
9f7d31e118 [AST] NonisolatedNonsendingByDefault: Print @concurrent on nonisolated async function types
With the feature enabled any function type without an explicit `@concurrent`
is going to be inferred to be `nonisolated(nonsending)`. `@concurrent` should
always be printed for diagnostic and other purposes because the isolation
checking would consider them to be `nonisolated(nonsending)` otherwise, especially
important to code produced by fix-its.

Resolves: rdar://161739470
2025-11-03 09:13:02 -08:00
Becca Royal-Gordon
9454c0aaa4 Emit module selectors in swiftinterfaces
This support is currently opt-in and can be disabled by a blocklist.
2025-10-31 16:48:06 -07:00
Hamish Knight
8306112aec [AST] Fix crash in PrintAST::printAccessors
Make sure we check whether `accessorsToPrint` is empty.
2025-10-24 13:08:26 +01:00
Pavel Yaskevich
2c1329e861 [ClangImporter] Add "suppressed" bit to SynthesizedProtocolAttr
Makes it possible to support `~Sendable` and potentially other
suppressible conformances.
2025-10-23 23:56:05 +09:00
Hamish Knight
a1e1656ed5 [AST] Remove respectOriginallyDefinedIn parameter from mangleAnyDecl
This was always set to `true` except for USR mangling, where we already
have it set to `false` for IDE USRs. The other clients were:

- AutoDiff, which is just using the resulting string as a dictionary
key, so don't seem to have any preference.
- The ClangImporter, which always overrides `@_originallyDefinedIn`
anyway.
2025-10-23 09:11:17 +01:00
Meghana Gupta
25f0e2f934 [NFC] Replace @guaranteed_addr by @guaranteed_address 2025-10-20 09:05:37 -07:00
Meghana Gupta
a0c939bd3b Use @inout result convention for mutate accessors 2025-10-20 09:05:32 -07:00
Rintaro Ishizaki
13e17870cc Merge pull request #84972 from rintaro/accessor-disambiguation-rdar140943107
[ASTPrinter/Parse] Disambiguate accessor block in .swiftinterface
2025-10-17 18:40:56 -07:00
Rintaro Ishizaki
6a1604ba09 [ASTPrinter/Parse] Disambiguate accessor block in .swiftinterface
.swiftinterface sometimes prints a pattern binding initializer and the
accessor block. However the parser doesn't expect such constructs and
the disambiguation from trailing closures would be fragile. To make it
reliable, introduce a disambiguation marker `@_accessorBlock` .
`ASTPrinter` prints it right after `{` only if 1) The accessor block is
for a pattern binding declaration, 2) the decl has an initializer
printed, and 3) the non-observer accessor block is being printed. In the
parser, if the block after an initializer starts with
`{ @_accessorBlock`, it's always parsed as an accessor block instead of
a trailing closure.

rdar://140943107
2025-10-16 22:16:29 -07:00
Michael Gottesman
2fa3908e94 [concurrency] Add a new type Builtin.ImplicitActor.
This is currently not wired up to anything. I am going to wire it up in
subsequent commits.

The reason why we are introducing this new Builtin type is to represent that we
are going to start stealing bits from the protocol witness table pointer of the
Optional<any Actor> that this type is bitwise compatible with. The type will
ensure that this value is only used in places where we know that it will be
properly masked out giving us certainty that this value will not be used in any
manner without it first being bit cleared and transformed back to Optional<any
Actor>.
2025-10-16 10:51:13 -07:00
Pavel Yaskevich
93961aa5a2 [AST] Implement printing suppression for ~Sendable 2025-10-09 13:45:55 -07:00
Pavel Yaskevich
1ac87e7004 [Basic] Add an experimental feature flag to guard use of ~Sendable 2025-10-09 10:41:25 -07:00
Slava Pestov
52e496dfdb ASTPrinter: Remove opaque archetype re-sugaring hack
We cannot in general assume the substitution map's replacement types
are written in terms of the generic signautre of the owner declaration.

This was only necessary because this substitution map did not
preserve type sugar, but now that it does, we no longer need
this hack.
2025-10-08 15:16:49 -04:00
Hamish Knight
954b08cae5 [AST] Remove UnresolvedType
We have now removed all uses of this type.
2025-10-03 09:50:42 +01:00
Arnold Schwaighofer
7853ba0a7f Merge pull request #84178 from aschwaighofer/inline_always
Add experimental feature `@inline(always)`
2025-10-01 07:23:24 -07:00
Arnold Schwaighofer
25a071efc8 Add experimental feature @inline(always)
The intent for `@inline(always)` is to act as an optimization control.
The user can rely on inlining to happen or the compiler will emit an error
message.

Because function values can be dynamic (closures, protocol/class lookup)
this guarantee can only be upheld for direct function references.

In cases where the optimizer can resolve dynamic function values the
attribute shall be respected.

rdar://148608854
2025-09-30 08:36:26 -07:00
Hamish Knight
0c58138a42 [Sema] Avoid using UnresolvedType in PatternTypeRequest
Return PlaceholderType instead of UnresolvedType, meaning we now
treat the following cases the same:

```
let x1 = foo
let x2: _ = foo
```
2025-09-28 15:13:55 +01:00
Alexis Laferrière
4c7a313de7 Merge pull request #84488 from xymus/c-impl-in-swiftinterfaces
ModuleInterface: Don't print `@c @implementation` functions
2025-09-26 16:09:34 -07:00
Alexis Laferrière
0eaab86219 ModuleInterface: Don't print @c @implementation functions
We don't need to print the `@c @implementation` functions in
swiftinterfaces as clients need only to see the original declaration in
the C header. Don't print `@objc @implementation` functions either, but
still print simple `@c` and `@objc` functions.
2025-09-23 16:41:34 -07:00
Egor Zhdan
4ef848701f Merge pull request #84354 from egorzhdan/egorzhdan/revert-extern-c
Revert "[cxx-interop] Import decls in extern blocks within namespaces"
2025-09-23 19:46:12 +01:00
Hamish Knight
0bfbe987b4 [AST] Print ErrorType as _
In preparation for removing UnresolvedType in favor of ErrorType,
start printing ErrorType as `_` unless we've enabled debug printing.
`<<error type>>` should never be presented to the user, instead `_`
now just consistently means "unknown type".
2025-09-21 23:19:06 +01:00
Egor Zhdan
c3a56fdc91 Revert "[cxx-interop] Import decls in extern blocks within namespaces"
This reverts commit 844787fd

Reverting because of a modularization issue in host libc++.

rdar://160536819
rdar://160536878
2025-09-17 19:17:14 +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
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
Slava Pestov
6bf5213d41 Merge pull request #84251 from slavapestov/fix-rdar151171381
Fix @_opaqueReturnTypeOf module interface syntax for parameter packs
2025-09-13 08:44:44 -04:00
Henrik G. Olsson
ea5a41ea68 [ASTPrint] Only print CustomAttr arglist if PrintExprs enabled
The argument list is going to be mostly empty if PrintExprs is not
enabled. Always trying to print the arguments also broke quite a few
tests, because it would result in a mismatch between the swift interface
before and after serialization, since CustomAttr arguments are not
serialized.
2025-09-12 12:53:59 -07:00
Slava Pestov
87cbb7d2d0 AST: New way of printing @_opaqueReturnTypeOf when parameter packs are involved
This is the ASTPrinter change to go with the Sema change.
We now print @_opaqueReturnTypeOf using the new nested
syntax when parameter packs are involved.

Fixes rdar://problem/151171381.
2025-09-12 15:43:30 -04:00
Henrik G. Olsson
149828f019 [ASTPrint] Print argument list for CustomAttr 2025-09-11 18:46:22 -07:00
Henrik G. Olsson
f2d3faefd6 [ASTPrint] Refactor CustomAttr printing (NFC)
This is a pure refactor to enable using PrintAST in the next commit.
2025-09-11 18:46:22 -07:00
Meghana Gupta
1cff471c57 Introduce ResultConvention::Guaranteed and ResultConvention::GuaranteedAddress
ResultConvention::Guaranteed will be used by borrow accessors when the storage type can be returned by value.

ResultConvention::GuaranteedAddress will be used by mutate accessors and borrow accessors when the storage type
cannot be returned by value.
2025-09-09 14:45:40 -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
Allan Shortlidge
e0eba4ed5e AST: Add printing support for #available and #_hasSymbol conditions.
Teach `ASTPrinter` to print `if #available` and `if #_hasSymbol` statements.
2025-09-05 18:34:31 -07:00
Allan Shortlidge
b047396246 AST: Use availability to control decl visibility in public swiftinterfaces.
Declarations that are unavailable at runtime because of an `@available`
attribute referencing a custom domain that was imported `@_spiOnly` should be
hidden from public swiftinterface files in `-library-level=api` modules. For
remaining declarations that do get printed in the public swiftinterface, skip
printing any `@available` attribute that refers to the domains from those
`@_spiOnly` dependencies. This allows API developers to control declaration
visibility using availability defined by another module.

Resolves rdar://156512028.
2025-09-04 12:32:19 -07:00
Hamish Knight
ff200137a8 [AST] Add ErrorType originator for PlaceholderType 2025-08-30 16:05:01 +01:00
Allan Shortlidge
441132426f ModuleInterface: Only print API-level property wrappers in swiftinterfaces.
When a function parameter has attached property wrappers (SE-0293) those
property wrappers are either considered "implementation" or "API" level.
Property wrappers that are implementation-level don't affect how the function
is called and therefore shouldn't be included in swiftinterfaces unless the
function's body is also printed.

Resolves rdar://156711817.
2025-08-27 21:35:20 -07:00
Erik Eckstein
833560f08f SIL: fix printing of dependent existential archetypes
We were missing parentheses:
```
  $@opened("...", any P2) Self.A
```
->
```
  $(@opened("...", any P2) Self).A
```
2025-08-25 19:38:26 +02:00
Egor Zhdan
f96a5e5b2b Merge pull request #83589 from egorzhdan/egorzhdan/reland-extern-namespace
Revert "Revert "[cxx-interop] Import decls in extern blocks within namespaces""
2025-08-15 18:30:51 +01:00
Egor Zhdan
a5b4975204 Revert "Revert "[cxx-interop] Import decls in extern blocks within namespaces""
This reverts commit 8f60840551.
2025-08-07 15:03:08 +01:00
Allan Shortlidge
8f60840551 Revert "[cxx-interop] Import decls in extern blocks within namespaces"
This reverts commit 844787fddb.
2025-08-06 21:50:55 -07:00
Pavel Yaskevich
53ef38e31b [AST] NFC: Rename function type isolation NonisolatedCaller to NonisolatedNonsending
This reduces the number of ways we refer to caller isolated async
functions and matches the name to the attribute spelling.
2025-08-05 17:22:10 -07:00
Egor Zhdan
844787fddb [cxx-interop] Import decls in extern blocks within namespaces
This teaches ClangImporter to import C++ decls that are declared within `extern "C" { ... }`/`extern "C++" { ... }` blocks which are nested in namespaces.

rdar://139067788
2025-08-04 19:42:43 +01:00
Allan Shortlidge
2b8ab7fbab AST: Re-baseline SendingArgsAndResults feature. 2025-07-31 10:21:55 -07:00
Allan Shortlidge
a37ce9a543 AST: Re-baseline IsolatedDeinit feature. 2025-07-31 10:21:55 -07:00
Allan Shortlidge
dd28a3e4b5 AST: Re-baseline IsolatedAny feature. 2025-07-31 10:21:55 -07:00