Commit Graph

1126 Commits

Author SHA1 Message Date
Allan Shortlidge
e358cd6309 Tests: Correct invalid platform versions in @available attributes. 2025-06-10 22:11:05 -07:00
Allan Shortlidge
3f305a48c8 AST: Re-map macOS 16 aligned availability versions to 26.
- watchOS 12 -> 26
- visionOS 3 -> 26
- macos 16 -> 26
- iOS 19 -> 26
- tvOS 19 -> 26

The version numbers for `if #available(...)` queries are intentionally not
re-mapped.
2025-06-10 22:11:05 -07:00
Meghana Gupta
44e05fa858 [NFC] Update tests and diagnostics 2025-06-07 12:49:01 -07:00
John McCall
237e617fab Merge pull request #82008 from rjmccall/dont-copy-print-options
Prevent PrintOptions from being implicitly copied
2025-06-06 17:06:02 -04:00
Slava Pestov
0b3fd9eede 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-05 23:07:04 -04:00
John McCall
b3493bfa23 Prevent PrintOptions from being implicitly copied.
NFC *except* that I noticed a bug by inspection where we suppress
`@escaping` when print enum element types. Since this affects
recursive positions, we end up suppressing `@escaping` in places
we shouldn't. This is unlikely to affect much real code, but should
still obviously be fixed.

The new design is a little sketchy in that we're using `const` to
prevent direct use (and allow initialization of `const &` parameters)
but still relying on modification of the actual object.  Essentially,
we are treating the `const`-ness of the reference as a promise to leave
the original value in the object after computation rather than a
guarantee of not modifying the object. This is okay --- a temporary
bound to a `const` reference is still a non-`const` object formally
and can be modified without invoking UB --- but makes me a little
uncomfortable.
2025-06-05 12:52:01 -04:00
Pavel Yaskevich
e1e9f04398 Merge pull request #81863 from xedin/using-for-default-isolation-in-file-context
[AST/Sema] SE-0478:  Implement `using` declaration under an experimental flag
2025-06-02 09:56:29 -07:00
Pavel Yaskevich
c246a7a372 [AST/Sema] Hide using declaration behind DefaultIsolationPerFile experimental feature 2025-05-31 10:49:50 -07:00
Pavel Yaskevich
ad71e07cae [AST] Don't print using declarations in swift interfaces
These declarations are effectively `fileprivate` at the moment
and should appear in swift interfaces.
2025-05-31 10:49:50 -07:00
Anthony Latsis
0a1b8b0d50 [test] Fix misspelled FileCheck directives 2025-05-29 15:09:36 +01:00
Jan Svoboda
35e4fa8cf2 [ModuleInterface] Ignore SDKSettings.json in "sourceFiles" 2025-05-21 10:03:09 -07:00
Mishal Shah
ef74028c85 Merge pull request #81666 from rintaro/disable-rdar151740742
[Test] Disable failing test case
2025-05-20 23:04:09 -07:00
Becca Royal-Gordon
6a9e2d40d3 XFAIL clang-args-transitive-availability.swift
It is failing, probably due to swiftlang/llvm-project#10679. See rdar://151740686.
2025-05-20 21:50:30 -07:00
Rintaro Ishizaki
86e0b45efe [Test] Disable failing test case
rdar://151740742
2025-05-20 21:42:29 -07:00
Pavel Yaskevich
c050e8f75a [AST] Protect declarations with @_inheritActorContext(always) by a feature flag
This is going to avoid condfails when declarations are printed
in the swiftinterface files.
2025-05-14 20:07:59 -07:00
Ben Barham
6667471b3d Merge pull request #81115 from beccadax/abi-let-you-graduate
Finish implementing `@abi` (SE-0476)
2025-05-08 12:52:00 -07:00
Guillaume Lessard
d8c3942198 Merge pull request #81224 from glessard/override-lifetime-publicly
[stdlib] make `_overrideLifetime()` functions public
2025-05-06 19:56:11 -07:00
Guillaume Lessard
d0445f3758 [test] remove more copies of _overrideLifetime() 2025-05-06 15:19:49 -07:00
Becca Royal-Gordon
01431b87b2 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-05 13:50:51 -07:00
Anthony Latsis
17fc00f8a7 [test] IRGen: Adjust FileCheck patterns for new nuw attribute in upstream LLVM
This attribute was introduced in
7eca38ce76d5d1915f4ab7e665964062c0b37697 (llvm-project).

Match it using a wildcard regex, since it is not relevant to these
tests.

This is intended to reduce future conflicts with rebranch.
2025-05-04 03:28:56 +01:00
Pavel Yaskevich
498430afaf [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`.
2025-05-02 09:07:22 -07:00
Andrew Trick
2a6a621dd8 Merge pull request #81222 from atrick/missing-markdep
Fix LifetimeDependenceInsertion: handle boxed indirect out arguments
2025-05-01 00:43:03 -07:00
Andrew Trick
9d8e8d3f05 Fix LifetimeDependenceInsertion: handle boxed indirect out arguments
Correctly generate dependency tracking for functions that return a non-Escapable
existential, such as:

func getMutableSpanWithOpaqueReturn(_ array: inout [Int]) -> any PAny & ~Copyable & ~Escapable

Previously, dependency insertion assumed that @out storage always initialized an
alloc_stack. But existentials are always boxed.

First, add a diagnostic to catch any missing dependency insertions now that
we're past the bootstrapping phase.

Then, generalize handling of dependency insertion to handle any access base as
long as it has a recognizable address source.

Fixes rdar://150388126 (Missing mark_dependence for opaque lifetime dependent
value)
2025-04-30 15:50:13 -07:00
Artem Chikin
7c5d8b24d3 [Dependency Scanning] Add a field of source-imported dependencies
For the main source module, provide info on which dependencies are directly imported into the user program, explicitly ('import' statement) or implicitly (e.g. stdlib). Thist list does not include Swift overlay dependencies, cross-import dependencies, bridging header dependencies.
2025-04-30 10:15:20 -07:00
Pavel Yaskevich
0ad7d8b590 [AST] Prevent use of @extensible without ExtensibleAttribute feature 2025-04-24 12:10:53 -07:00
Pavel Yaskevich
6d89bca765 [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.
2025-04-24 12:09:17 -07:00
Becca Royal-Gordon
97bb6b1150 Prevent #if in @abi in module interfaces
When a language feature is used inside an `@abi` attribute, we should behave as though it was used on its counterpart. This was already half-implemented—we ensured the counterpart would use the feature—but we didn’t make the ABI decl aware that the counterpart was its parent for feature detection purposes. As a result, we would print `#if` inside the `@abi` attribute, which isn’t valid.
2025-04-18 14:50:01 -07:00
Pavel Yaskevich
2f133b3827 Merge pull request #80843 from xedin/fix-printing-of-specifiers-and-attributes
[AST] ASTPrinter: Improvements to specifier and attribute printing
2025-04-16 11:04:30 -07:00
Pavel Yaskevich
4fd4c00bc9 [AST] ASTPrinter: Always print attributes after parameter specifiers 2025-04-15 16:29:20 -07:00
Pavel Yaskevich
ee38182ae2 [AST] ASTPrinter: Don't print '@escaping' on 'inout' parameters
All of the `inout` types are implicitly `@escaping`.
2025-04-15 16:29:13 -07:00
Pavel Yaskevich
6662a48533 [AST] ASTPrinter: Always print nonisolated(nonsending) parameter specifier first
This avoids any possible positioning issues between specifiers
and attributes.
2025-04-15 14:54:00 -07:00
Alejandro Alonso
42b416171a Add feature for value generic namelookup 2025-04-14 15:33:05 -07:00
Doug Gregor
3380331e7e [SE-0470] Enable isolated conformances by default
The IsolatedConformances feature moves to a normal, supported feature.
Remove all of the experimental-feature flags on test cases and such.

The InferIsolatedConformances feature moves to an upcoming feature for
Swift 7. This should become an adoptable feature, adding "nonisolated"
where needed.
2025-04-13 15:41:53 -07:00
Pavel Yaskevich
734b1f1705 [Frontend] Add a feature to guard use of @concurrent and nonisolated(nonsending) in swift interface files 2025-04-11 15:59:25 -07:00
Pavel Yaskevich
f1b3c7b604 [AST] Remove ExecutionAttribute experimental feature
SE-0461 has been accepted and `@concurrent` and `nonisolated(nonsending)`
can be make generally available now.
2025-04-11 15:59:25 -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
4b8c8e7d72 [AST/Sema] Replace @execution(concurrent) with @concurrent 2025-04-11 12:08:29 -07:00
Allan Shortlidge
10c910ed83 ModuleInterface: Guard declarations that use the $CustomAvailability feature. 2025-04-08 08:53:44 -07:00
Pavel Yaskevich
a0ae93d3a8 [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.
2025-04-03 16:30:19 -07:00
Allan Shortlidge
b6a425ab6a Sema: Avoid diagnosing required availability in swiftinterface files.
The `-require-explicit-availability` compiler flag is designed to help
developers find declarations that they've written with missing availability.
The flag is not printed in swiftinterface files, though, so if a module has
both `-library-level=api` and also has `-require-explicity-availability=ignore`
(as the Swift stdlib does) then the result is that superfluous diagnostics are
emitted when typechecking the emitted module interface that should have been
suppressed by the `ignore` flag. Suppress these diagnostics when typechecking
swiftinterface files since they are only designed to be seen by the owner of
the module when they are building the module from source and they don't have
much value in the context of interface verification.
2025-04-01 07:12:50 -07:00
Allan Shortlidge
645628f3e4 Frontend: Reinstate suppression of warnings during interface type-checking.
We're not ready to start emitting warnings when type-checking modules from
interface. It is causing performance regressions and spurious diagnostics to be
emitted.

Reverts a small part of https://github.com/swiftlang/swift/pull/80360.

Resolves rdar://148257136.
2025-03-31 20:41:24 -07:00
Becca Royal-Gordon
65dc578de6 Merge pull request #80360 from beccadax/rdar144811653 2025-03-28 19:01:01 -07:00
Karoy Lorentey
5583e6916c Merge pull request #73258 from lorentey/you-cannot-escape-optionals
[stdlib] Generalize some constructs for non-escapable types
2025-03-27 20:02:00 -07:00
Becca Royal-Gordon
ce8cc1780a Ignore bad @_hasStorage in module interfaces
An objcImpl bug previously caused `@_hasStorage` to be emitted inside some extensions in module interfaces. An earlier commit in this PR created an error for this, but for backwards compatibility, it would actually be better to simply ignore the attribute in module interfaces. Modify TypeCheckStorage to emit a warning, not an error, in this situation.

Additionally, modify the module interface loader to show warnings when you verify a module interface, but not for other module interface uses (like compiling or importing one). The assumption here is that if you’re verifying a module interface, you’re either the author of the module that created it or you’re investigating a problem with it, and in either case you’d like to be told about minor defects in case they’re related.

Fixes rdar://144811653 thoroughly.
2025-03-27 18:25:11 -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
c44284d874 Diagnose invalid @_hasStorage attributes
A bug in `@objc @implementation` is causing incorrect `@_hasStorage` attributes to be printed into module interfaces. As an initial step towards fixing this, diagnose bad `@_hasStorage` attributes and treat them as computed properties so that these malformed interfaces don’t cause compiler crashes.

Partially fixes rdar://144811653.
2025-03-27 16:24:44 -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
Alexis Laferrière
a4aaa1063a Merge pull request #80098 from xymus/upstream-swiftmodule-blocklist
Frontend: Upstream blocklist check when ignoring adjacent swiftmodule files
2025-03-26 10:28:30 -07:00
Anthony Latsis
631a04e56c Merge pull request #80159 from AnthonyLatsis/danaus-plexippus-5
Sema: Extend adoption mode for `AsyncCallerExecution` to storage declarations
2025-03-26 04:40:58 +00:00
Anthony Latsis
8ad2e02596 Sema: Allow @execution on storage declarations 2025-03-25 02:07:04 +00:00