Commit Graph

2038 Commits

Author SHA1 Message Date
Ian Anderson
fc628a8bfb [test][NFC] Add more keys to test SDKSettings files
Every time DarwinSDKInfo reads a new key out of SDKSettings, a boatload of test SDKSettings files need to be updated across several repositories and forks and branches. It’s tedious to be careful to update those with real values so that the tests are properly regression testing older SDKs. It’s important to be careful so that the tests are accurate, e.g. to prevent the scenario where DarwinSDKInfo starts reading a new key out of SDKSettings and assumes that it’s always available everywhere, when in reality it was only added a few releases ago and will break with older SDKs. If the test SDKSettings files continue to be updated ad hoc, it’s going to be really easy to copy/paste a default value everywhere, and then clients will see incorrect behaviors with the real SDKs, or even compiler crashes if the key is unconditionally read. Preemptively add all of the maybe-possibly-compiler relevant keys to the test SDKSettings files from the real SDKs so that the test files are an accurate representation and shouldn't need to be touched in the future. Where the test SDKSettings have intentionally doctored data, add a Comments key explaining what is changed from the real SDK, and alter the SDK name with a tag indicating the change.

rdar://168700857
2026-01-23 02:19:36 -08:00
Sam Pyankov
a0dc22e819 Merge pull request #86392 from sepy97/strict_access_check_errors
Stricter access control enforcement
2026-01-13 15:45:16 -08:00
Tim Kientzle
adec1f6cbe Merge pull request #86277 from tbkka/tbkka-rdar149303951-try1
[SE-0474] Implement final `yielding borrow`/`yielding mutate` naming for coroutine accessors
2026-01-09 08:52:21 -08:00
Sam Pyankov
b0eee67a7b Emit an errors instead of warnings access control violations that should be fixed in the future when StrictAccessControl upcoming feature is enabled 2026-01-08 14:24:35 -08:00
Kavon Farvardin
adf14929f9 Merge pull request #86337 from kavon/noncopyable-opaque-read-ownership
introduce UnderscoreOwned feature
2026-01-07 18:58:54 -08:00
Kavon Farvardin
16426758c8 make @_owned support hasAttribute 2026-01-07 09:24:24 -08:00
Kavon Farvardin
458b62c9ed introduce UnderscoreOwned feature
This experimental feature allows you to override the default behavior
of a 'get' returning a noncopyable type, so that it returns an owned
value rather than a borrow, when that getter is exposed in opaque
interfaces like protocol requirements or resilient types.

resolves rdar://157318147
2026-01-06 16:39:54 -08:00
Sam Pyankov
12e619fbba Merge pull request #86076 from sepy97/inlinable-function-private-setter
Diagnosing a private setter being accessed from the inlinable function.
2026-01-05 22:23:12 -08:00
Sam Pyankov
922874819d Diagnosing a private setter being accessed from the inlinable function.
rdar://81879146
2026-01-05 15:42:30 -08:00
Doug Gregor
fb0f48339a Make @c attribute user-accessible
This makes it available for hasAttribute(c) checks and show up in code
completion.

Fixes rdar://167554912.
2026-01-05 09:39:15 -08:00
Tim Kientzle
104dba920b [SE-0474] Implement yielding borrow and yielding mutate syntax
This does not rename all the internal variables, functions, and types
whose names were based on the old syntax.

I think it adds new syntax support everywhere it's needed while
retaining enough of the old syntax support that early adopters will
see nice deprecation messages guiding them to the new syntax.
2026-01-03 15:07:10 -08:00
Alexis Laferrière
7924c73f20 Merge pull request #86154 from xymus/exportability-nle-more
Sema: Extend exportability checking for non-library-evolution to more reasons
2025-12-22 13:58:44 -08:00
Alexis Laferrière
80149d627a Sema: Always allow on @_implementationOnly on types 2025-12-19 11:26:06 -08:00
Artem Chikin
8e97cb4d8d Implement support for unified warning group behavior queries per-diagnostic
Unified across module-wide configuration flags (`-Wwarning`, `-Werror`, etc.) and syntactic configuration attribute `@warn`.
2025-12-12 10:14:20 -08:00
Slava Pestov
459a874f00 Sema: Re-visit @specialize attribute where clause in interface resolution stage
As with all other where clauses, we must resolve the requirements twice;
first in structural stage to build the generic signature, and second in
interface stage to check that any generic types that appear within
satisfy requirements. We weren't doing the latter for @specialize, which
would result in SIL crashes if such invalid SIL types appeared therein.

Fixes rdar://165909327.
2025-12-05 09:53:46 -05:00
Doug Gregor
020b69d4b6 [SE-0497] Implement @export attribute syntax
Implement the @export(implementation) and @export(interface) attributes
to replace @_alwaysEmitIntoClient and @_neverEmitIntoClient. Provide a
warning + Fix-It to start staging out the very-new
@_neverEmitIntoClient. We'll hold off on pushing folks toward
@_alwaysEmitIntoClient for a little longer.
2025-11-07 22:00:40 -08:00
Alexis Laferrière
1e1361f4ee Merge pull request #85369 from xymus/exportability-nle-classes-and-structs
Sema: Exportability check enums and classes in non-library-evolution mode
2025-11-07 09:19:25 -08:00
Alexis Laferrière
5bffd70452 Sema: Accept @_implementationOnly on enums and classes 2025-11-06 11:30:43 -08:00
Doug Gregor
a10194c0e3 Ensure that we don't diagnose the lack of initializer for @_extern variables 2025-11-06 11:20:57 -08:00
Doug Gregor
5b642f548f Extend @_extern to global and static variables
Allow external declaration of global variables via `@_extern(c)`. Such
variables need to have types represented in C (of course), have only
storage (no accessors), and cannot have initializers. At the SIL
level, we use the SIL asmname attribute to get the appropriate C name.

While here, slightly shore up the `@_extern(c)` checking, which should
fix issue #70776 / rdar://153515764.
2025-11-06 11:09:31 -08:00
Allan Shortlidge
3b77e2e64a AST: Introduce experimental support for an anyAppleOS availability domain.
`anyAppleOS` represents a meta-platform for availability checks that can be
used to check availability across all of Apple's operating systems. It
supports versions 26.0 and up since version 26.0 is the first OS version number
that is aligned accross macOS, iOS, watchOS, tvOS, and visionOS.

Apple platform-specific availability specification take precedence over
`anyAppleOS` availability specifications when specified simultaneously.

Resolves rdar://153834380.
2025-10-31 15:21:30 -07:00
Alexis Laferrière
94113f4a83 SE-496: Remove references to features CDecl and CImplementation 2025-10-29 17:31:20 -07:00
Alexis Laferrière
000c2604b0 SE-495: Make @c an official feature 2025-10-29 11:55:41 -07:00
Alexis Laferrière
74ea47a159 Merge pull request #84489 from xymus/c-identifier-only
Parser: Reject `@c` attributes using the string format
2025-10-27 09:17:31 -07:00
Hamish Knight
b5627c9337 Merge pull request #85145 from a7medev/autodiff-comma-fix-its
[Diagnostics] Add missing fix-its for unexpected/expected comma in attribute arguments
2025-10-27 09:08:16 +00:00
Ahmed Mahmoud
d0c2d8b317 [Diagnostics] Add fix-its for unexpected/expected comma in auto-diff attributes 2025-10-26 23:47:19 +03:00
Alexis Laferrière
7ec1d36215 Parser: Reject @c attributes using the string format
Reject `@c` attributes in the format of `@c("customName")` to accept
only `@c(customName)` and of course the bare `@c`.
2025-10-24 11:55:34 -07:00
Alexis Laferrière
659692e834 Tests: Update all uses of @c to use the identifier format 2025-10-24 11:55:34 -07:00
Kuba Mracek
b47227b57b Remaining test a code fixes for @_section->@section rename 2025-10-23 08:43:42 -07:00
Kuba Mracek
adeb40f261 SE-0492: Stabilize @_section/@_used into @section/@used
Removes the underscored prefixes from the @_section and @_used attributes, making them public as @section and @used respectively. The SymbolLinkageMarkers experimental feature has been removed as these attributes are now part of the standard language. Implemented expression syntactic checking rules per SE-0492.

Major parts:
- Renamed @_section to @section and @_used to @used
- Removed the SymbolLinkageMarkers experimental feature
- Added parsing support for the old underscored names with deprecation warnings
- Updated all tests and examples to use the new attribute names
- Added syntactic validation for @section to align with SE-0492 (reusing the legality checker by @artemcm)
- Changed @DebugDescription macro to explicitly use a tuple type instead of type inferring it, to comply with the expression syntax rules
- Added a testcase for the various allowed and disallowed syntactic forms, `test/ConstValues/SectionSyntactic.swift`.
2025-10-22 16:05:39 -07:00
Allan Shortlidge
463bf91f68 AST: Rename Swift runtime availability domain to StandaloneSwiftRuntime.
This name will distinguish the standalone Swift runtime availability domain
from the domain for the built-in Swift runtime on supported targets.
2025-10-21 21:55:25 -07:00
Allan Shortlidge
16dee385bf AST/Basic: Introduce the StandaloneSwiftAvailability experimental feature.
This experimental feature will be used to force the compiler to treat `Swift`
runtime availability as separate from platform availability when compiling for
targets that have the Swift runtime built-in.
2025-10-21 21:55:24 -07:00
Mads Odgaard
c92e5b47f3 Merge pull request #84574 from madsodgaard/android-availability 2025-10-20 10:40:37 +09:00
Hamish Knight
a83ea3c8bb Merge pull request #84745 from hamishknight/fishmonger
[Evaluator] Enforce consistent results for cyclic requests
2025-10-09 17:08:04 +01:00
Allan Shortlidge
1a86cd9c26 AST: Introduce a Swift runtime availability domain.
Add support for the `Swift` availability domain, which represents availability
with respect to the Swift runtime. Use of this domain is restricted by the
experimental feature `SwiftRuntimeAvailability`.
2025-10-08 17:31:57 -07:00
Allan Shortlidge
2d8465b043 AST: Introduce the SwiftLanguageMode availability domain spelling.
Require `-enable-experimental-feature SwiftRuntimeAvailability` to use this new
spelling.
2025-10-08 15:46:34 -07:00
Hamish Knight
e7c7239587 [Sema] Insert ErrorType same-type constraints for placeholder signatures
This helps avoid producing more downstream errors. This changes
`GenericSignature::forInvalid` to produce the same signature as e.g
`<T where T == Undefined>`. This subsumes the need to introduce
conformance requirements for invertible protocols.
2025-10-08 21:16:02 +01:00
Henrik G. Olsson
cbc0ec3b88 Add -verify-ignore-unrelated where necessary (NFC)
These are tests that fail in the next commit without this flag. This
does not add -verify-ignore-unrelated to all tests with -verify, only
the ones that would fail without it. This is NFC since this flag is
currently a no-op.
2025-10-04 14:19:52 -07:00
Alexis Laferrière
e5a9b6463d Merge pull request #84381 from xymus/rename-cdecl-to-c
Parser: Rename the experimental attribute `@cdecl` to the shorter `@c`
2025-09-23 14:58:46 -07:00
Doug Gregor
6e6dc4b063 Merge pull request #81054 from DataCorrupted/FixTypedThrow
[Sema] @objc functions shall not have typed throw
2025-09-22 18:21:52 -07:00
Alexis Laferrière
9ec824c20b Parser: Rename the experimental attribute @cdecl to @c
There's no users of `@cdecl` yet so we can do a direct rename. The
legacy `@_cdecl` remains unaffected.
2025-09-19 11:55:07 -07:00
Allan Shortlidge
0647da5416 AST: Introduce an "always enabled" custom availability domain kind.
An always enabled availability domain is implicitly available in all contexts,
so uses of declarations that are marked as `@available` in the domain are never
rejected. This is useful for an availability domain representing a feature flag
that has become permanently enabled.

Partially resolves rdar://157593409.
2025-09-11 14:39:05 -07:00
Gabor Horvath
7ac9a81b1e [cxx-interop] Add attribute to hide Swift declarations from interop
This can help work around problems when the names of a C++ declaration
and a Swift declaration would collide, or to temporarily work around
compiler bugs.

rdar://152838988&140802127&158843666
2025-09-01 12:29:34 +01:00
Pavel Yaskevich
a7ecd309d4 [AST] SE-0487: Promote NonexhaustiveAttribute to a language feature
The proposal [has been accepted](https://forums.swift.org/t/accepted-se-0487-nonexhaustive-enums/81508)
which makes the feature experimental no longer.
2025-08-20 00:39:51 -07:00
Allan Shortlidge
5ae0ad6a8f AST: Allow obsoletion in Swift version to disambiguate overloads consistently.
It must be possible to disambiguate overloads using the module-wide Swift
language version, even in contexts that are themselves obsolete in the current
Swift language version.

Resolves rdar://158620835.
2025-08-18 17:20:42 -07:00
Hamish Knight
114ea293c4 Merge pull request #82058 from a7medev/feat/access-control-set-fix-it
[Diagnostics] Add fix-its for missing `set` and `)` after access modifier
2025-08-16 18:42:28 +01:00
Ahmed Mahmoud
66a12352e4 [Test] Remove expected-error for invalid declaration after expected 'set' fix-it 2025-08-15 18:15:12 +03:00
Allan Shortlidge
db117bfefe Sema: Don't apply access level fix-it to @dynamicMemberLookup subscript.
The adjusted access level for the subscript shouldn't be fixed automatically
since sometimes the diagnostic is a warning and other times automatically
applying the fix-it immediately causes other errors, which can be confusing.

Resolves rdar://158261884.
2025-08-13 23:13:07 -07:00
Ahmed Mahmoud
edacf85aea [Test] Test no fix-it for access-control set in place of unrelated code 2025-08-10 02:16:12 +03:00
Ahmed Mahmoud
9df52be469 [Diagnostics] Add tests for accessibility expected set fix-its 2025-08-10 01:41:08 +03:00