Commit Graph

2061 Commits

Author SHA1 Message Date
Pavel Yaskevich
1d65a560d7 [AST/Sema] SE-0487: Remove @preEnumExtensibility attribute
(cherry picked from commit 0444d297b6)
2025-08-18 23:58:29 -07:00
Pavel Yaskevich
c9722333b9 [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.

(cherry picked from commit fe1ae75711)
2025-08-18 23:58:27 -07:00
Pavel Yaskevich
cefa0b2fbf [AST/Sema] Add @preEnumExtensibility attribute to downgrade warnings for extensible enums
Just like `@preconcurrency` for concurrency, this attribute is going
to allow exhaustiveness error downgrades for enums that were retroactively
marked as `@extensible`.

(cherry picked from commit 498430afaf)
2025-08-18 23:58:03 -07:00
Pavel Yaskevich
a0ab1dc40d [Frontend] Add ExtensibleAttribute to guard use of @extensible attribute
Guard against condfails when older compilers get a swift interface
that uses `@extensible` attribute. The attribute itself doesn't
have any effect in swift interfaces yet since all of the public
enums are already resilient in that mode.

(cherry picked from commit 6d89bca765)
2025-08-18 23:57:44 -07:00
Pavel Yaskevich
bcf38a1aef [AST/Sema] Add @extensible attribute on enum declarations
This attribute controls whether cross-module access to the declaration
needs `@unknown default:` because it's allowed to gain new cases even
if the module is non-resilient.

(cherry picked from commit a0ae93d3a8)
2025-08-18 23:56:49 -07:00
Egor Zhdan
782f26e726 [cxx-interop] Fix printing of namespaces declared in bridging headers
If a C++ namespace has redeclarations in a bridging header, printing AST for the namespace would crash the compiler. This is because such a redeclaration would not have an owning Clang module, and the AST printer did not account for that.

This change fixes the crash.

rdar://151715540
(cherry picked from commit cc9c51deea)
2025-06-23 18:56:19 +01:00
Meghana Gupta
58b714b968 Introduce a new suppressible experimental feature to guard @_lifetime 2025-06-11 08:03:40 -07:00
Slava Pestov
2c53876c19 ASTPrinter: Fix printing of let properties inside @objc @implementation extensions
A `let` here is really just a `var` with a `{ get }`.

Fixes rdar://problem/127120469.
2025-06-06 00:25:02 -04:00
Pavel Yaskevich
4f88004fc0 [AST] Don't print using declarations in swift interfaces
These declarations are effectively `fileprivate` at the moment
and should appear in swift interfaces.

(cherry picked from commit ad71e07cae)
2025-06-04 13:21:58 -07:00
Pavel Yaskevich
d057429e9a [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.

(cherry picked from commit aabfebec03)
2025-06-04 13:16:55 -07:00
Hamish Knight
f1c37f4e7d Change InlineArray sugar separator x -> of 2025-05-30 22:06:29 +01:00
Michael Gottesman
e92e9dff0c Make Feature a struct enum so we can put methods on it.
Just noticed this as I was looking at making other changes.

(cherry picked from commit 3ff9463957)
2025-05-14 16:07:04 -07:00
Becca Royal-Gordon
e831274256 Make @abi non-experimental
This includes changing the feature name so that compilers with the experimental feature don’t accidentally pick up content that only works in the final version.

Resolves rdar://150065196.
2025-05-08 18:28:34 -07:00
Ben Barham
464223e479 Merge pull request #81259 from bnbarham/cherry-merge-modules
[6.2][InterfaceGen] Merge exported modules with the same public name in generated interface
2025-05-08 10:17:17 -07:00
Michael Gottesman
e04e15f125 [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
(cherry picked from commit 9d59dbed17)

Conflicts:
	include/swift/AST/DiagnosticsSema.def
	include/swift/Basic/Features.def
	test/abi/macOS/arm64/concurrency.swift
	test/abi/macOS/x86_64/concurrency.swift
2025-05-06 14:12:23 -07:00
Ben Barham
d829fcf2eb Merge exported modules with the same public name in generated interface
If a module has the same `public-module-name` as the module being
generated and its import is exported, merge it into the same generated
interface.

Fix various always-imported modules from being printed while here and
update all the tests that checked for them.

Resolves rdar://137887712.

(cherry picked from commit ddddc667c8)
2025-05-02 12:52:44 -07:00
Hamish Knight
71be544585 [ASTPrinter] Add missing null check in isNonSendableExtension
The extended nominal may not be present for an invalid extension.

rdar://149032713
2025-04-23 21:13:34 +01:00
Pavel Yaskevich
fbadca2f2b [AST] ASTPrinter: Always print attributes after parameter specifiers
(cherry picked from commit 4fd4c00bc9)
2025-04-17 11:46:43 -07:00
Pavel Yaskevich
3bb3a0744f [AST] ASTPrinter: Make sure that attributes are printed as attributes and specifiers as keywords
(cherry picked from commit e302d73c87)
2025-04-17 11:46:13 -07:00
Pavel Yaskevich
24d168b1e4 [AST] ASTPrinter: Don't print '@escaping' on 'inout' parameters
All of the `inout` types are implicitly `@escaping`.

(cherry picked from commit ee38182ae2)
2025-04-17 11:44:13 -07:00
Pavel Yaskevich
9cf984a1b1 [AST] ASTPrinter: Always print nonisolated(nonsending) parameter specifier first
This avoids any possible positioning issues between specifiers
and attributes.

(cherry picked from commit 6662a48533)
2025-04-17 11:44:13 -07:00
Pavel Yaskevich
3896f8fd77 [AST] Remove ExecutionAttribute experimental feature
SE-0461 has been accepted and `@concurrent` and `nonisolated(nonsending)`
can be make generally available now.
2025-04-16 13:20:12 -07:00
Pavel Yaskevich
06f880e65c [AST/ASTGen/Sema/Serialization] Remove @execution attribute
Complete the transition from `@execution` to `@concurrent` and `nonisolated(nonsending)`
2025-04-16 13:18:52 -07:00
Allan Shortlidge
38e56fcec0 ModuleInterface: Guard declarations that use the $CustomAvailability feature. 2025-04-08 10:35:33 -07:00
Allan Shortlidge
b6cf794bb8 AST: Fix some -Wunused-but-set-variable warnings. 2025-04-01 13:11:36 -07:00
Artem Chikin
66334f8f1b Merge pull request #79290 from artemcm/ConstProtoSIL
[Compile Time Values] Implement a mandatory SIL pass to verify '@const' values
2025-04-01 00:12:27 -07:00
Becca Royal-Gordon
65dc578de6 Merge pull request #80360 from beccadax/rdar144811653 2025-03-28 19:01:01 -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
Pavel Yaskevich
2bb098c0ba Merge pull request #79560 from stzn/fix-subscript-sending-result
Add sending to subscript sending result
2025-03-28 00:26:29 -07:00
Becca Royal-Gordon
29a2d32d0e Avoid objcImpl @_hasStorage in module interfaces
If an `@objc implementation extension` had a public stored property with an observer, Swift would print `@_hasStorage` on the extension. This is Not Good because in a module interface, an objcImpl extension appears to be an ordinary extension, and properties in ordinary extensions are not supposed to have storage.

Suppress printing this attribute in objcImpl extensions to avoid this problem.

Partially fixes rdar://144811653 by suppressing emission of bad attributes.
2025-03-27 16:51:16 -07:00
Becca Royal-Gordon
7703d115db Filter bad attrs out of module interface @abis
When printing an `@abi` attribute’s decl, we now filter out any attrs that are not valid in that position. Fixes a broken test.
2025-03-26 10:47:58 -07:00
Anthony Latsis
a75b63ab6d Merge pull request #77920 from AnthonyLatsis/fissidens
AST: Rename debugger pretty printer `Type::dumpPrint` to `print`
2025-03-25 23:42:36 +00: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
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
Amritpan Kaur
978a5215d5 [Expr/AST] Add apply component to handle resolved method arguments. 2025-03-19 08:56:03 -07:00
Amritpan Kaur
0c614e09d1 [Expr/AST] Add unresolvedApply component to handle method arguments. 2025-03-19 08:56:03 -07:00
Amritpan Kaur
2583da94b2 [NFC] Generalize subscript index handling. 2025-03-19 08:53:18 -07:00
Amritpan Kaur
811d54901b [NFC] Rename unresolvedProperty to unresolvedMember
to generalize for both properties and method members.
2025-03-19 08:53:18 -07:00
Amritpan Kaur
8f71f5c780 [NFC] Rename property to member to generalize
for both properties and method members.
2025-03-19 08:53:18 -07:00
Doug Gregor
84a4a8bedb [Importer] Ensure that we can see macro-expanded declarations in C++ namespaces
Lookup into C++ namespaces uses a different path from C++ record declarations.
Augment the C++ namespace lookup path to also account for the auxiliary
declarations introduced by peer macro expansions.
2025-03-14 14:10:44 -07:00
Doug Gregor
71a516b5f7 Print isolated conformances in textual interfaces 2025-03-12 23:18:14 -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
Becca Royal-Gordon
7c867ca1da [NFC] Split DeclAttrOptions into two types
We’re running out of bits in DeclAttrOptions, so split it in two: DeclAttrRequirements contains all the `On*` options that describe the declarations allowed to have the attribute, while the other options are now DeclAttrBehaviors.

This commit also sorts the entries in DeclAttr.def by serialization code and improves the formatting of the file.
2025-03-12 14:14:16 -07:00
Tony Allevato
68876a6d4a Merge pull request #76636 from allevato/rich-identifiers
Support raw identifiers (backtick-delimited identifiers containing non-identifier characters).
2025-03-12 14:56:14 -04:00
Tony Allevato
97d9ca1a20 Preserve existing printing/mangling behavior for C++ specializations.
Imported C++ template specializations receive identifiers that contain
their type signature; e.g., `X<Y, Z>`. Since this means the identifier
contains non-identifier characters, the new behavior was trying to
escape them with backticks in ASTPrinter, ASTMangler, and the runtime
metadata. This pulls that back to preserve the current behavior for
specifically those types.
2025-03-11 17:26:26 -04:00
Tony Allevato
d94bd80c62 Add support for raw identifiers.
Raw identifiers are backtick-delimited identifiers that can contain any
non-identifier character other than the backtick itself, CR, LF, or other
non-printable ASCII code units, and which are also not composed entirely
of operator characters.
2025-03-11 17:18:43 -04:00
Erik Eckstein
d225c47d25 AST: rename OpenArchetypeType -> ExistentialArchetypeType
NFC
2025-03-11 20:21:46 +01:00
Anthony Latsis
5a92bc5e12 Merge pull request #79897 from AnthonyLatsis/danaus-plexippus-3
Small adjustments to adoption mode modeling
2025-03-11 11:47:18 +00: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