Commit Graph

28352 Commits

Author SHA1 Message Date
Saleem Abdulrasool
fc397de5d1 Merge pull request #78776 from compnerd/suppression
lib: simplify some pragma usage
2025-01-22 08:26:01 -08:00
Egor Zhdan
7903bf2684 Merge pull request #78783 from swiftlang/egorzhdan/enum-resilience
[cxx-interop] Assume that plain-C enums are resilient
2025-01-22 15:13:03 +00:00
Allan Shortlidge
fe138e014a AST: Track an unavailable domain instead of platform in AvailabilityContext.
Now that most of the compiler tracks availability in terms of
AvailabilityDomain, it's time to do so in AvailabilityContext as well. This
will ensure that the compiler accurately suppresses diagnostics about a decl
being unavailable in an arbitrary domain when the context of the use is already
unavailable in that domain.

With this change, most of the special-casing for the Embedded Swift availability
domain has been removed from the compiler, outside of parsing and interface
printing.
2025-01-22 06:40:11 -08:00
Allan Shortlidge
ba822d1e23 AST: Eliminate remaining direct access to AvailableAttr's fields.
Most of the compiler should use SemanticAvailableAttr instead. In contexts like
ASTDumper where a semantic attribute is unavailable use accessors on
AvailableAttr.

NFC.
2025-01-21 22:56:07 -08:00
Allan Shortlidge
0f1e301fb8 Merge pull request #78775 from tshortli/replace-unavailability-diagnostic-info
Sema: Replace UnavailabilityDiagnosticInfo with AvailabilityConstraint
2025-01-21 20:28:58 -08:00
Anthony Latsis
35f1370f6e TypeCheckType: Rework IUO diagnostics using behavior limitation
Also stop suggesting a '?' fix-it for casts, where it is not likely to
be helpful because the common intention is either to force the optional
or declare an IUO.
2025-01-21 21:41:00 +00:00
Pavel Yaskevich
798cd6843e [Diagnostics] Fix generic arguments mismatch diagnostic related to leading-dot syntax
`GenericArgumentsMismatchFailure` missed a case where location
of the failure points to a member spelled with leading-dot syntax.
2025-01-21 11:43:01 -08:00
Egor Zhdan
00e6b360d5 [cxx-interop] Assume that plain-C enums are resilient
This fixes sudden compiler errors that are emitted when trying to use CoreText.framework with C++ interop enabled.

When Swift is trying to rebuild a dependency module from its textual interface, it should not complain on usages of C enums in public Swift APIs.

This still leaves the resilience safety guardrail enabled for C++ scoped enums.

rdar://143215914
2025-01-21 18:57:10 +00:00
Joe Groff
a0a26b8330 Require explicit statement of all Copyable/Escapable requirements for conditional Copyable/Escapable conformances.
As specified by the SE-0446 acceptance, extensions that declare a type's
conditional `Copyable` or `Escapable` ability must reiterate explicitly all
of the `Copyable` and/or `Escapable` requirements, whether required or not
required (by e.g. `~Copyable`) that were suppressed in the original
type declaration.
2025-01-21 09:36:39 -08:00
Saleem Abdulrasool
42af06051d lib: simplify some pragma usage
When suppressing a warning for a single line, prefer to use `suppress`
to avoid the push/pop dance.
2025-01-21 09:15:07 -08:00
Pavel Yaskevich
82e111a276 Merge pull request #78704 from xedin/rdar-142920095
Implement experimental`@execution(concurrent | caller)` attribute
2025-01-21 09:04:39 -08:00
Allan Shortlidge
31fa5fc347 Sema: Replace UnavailabilityDiagnosticInfo with AvailabilityConstraint.
AvailabilityConstraint models a superset of UnavailabilityDiagnosticInfo and
will become the currency type for unsatisfied availability everywhere. NFC.
2025-01-21 08:51:29 -08:00
Allan Shortlidge
fdb182b1a5 Sema: Pass rename to diagnoseExplicitUnavailability() lambda.
This ensures that it doesn't need to be recomputed, which introduces an
opportunity for inconsistency. NFC.
2025-01-21 08:51:29 -08:00
Pavel Yaskevich
d4143ed9bb Merge pull request #78721 from xedin/downgrade-noasync-to-warning-on-preconcurrency-decls
[TypeChecker] Downgrade `noasync` availability to warnings on `@preco…
2025-01-20 15:05:28 -08:00
Allan Shortlidge
691f6fc646 AST: Model Embedded Swift availability with a domain.
Remove the bit on AvailableAttr that previously modeled this.

Resolves rdar://138802876.
2025-01-19 08:52:53 -08:00
Anthony Latsis
6c9bb2a283 Merge pull request #78593 from AnthonyLatsis/cocos-nucifera
OpenedExistentials: Do not attempt to erase existential metatypes wit…
2025-01-19 03:35:22 +00:00
Cal Stephens
8557e234ee Merge branch 'main' into cal--fix-nested-weak-self-issue 2025-01-18 18:36:24 -08:00
Cal Stephens
e6a2230fdf Fix issue where implicit self was unexpectedly not allowed in nested weak self closure in Swift 6 mode 2025-01-18 18:25:23 -08:00
Pavel Yaskevich
c89ba5f58c [Sema] Diagnose clash between inferred global actor isolation and @execution(concurrent) 2025-01-17 15:40:01 -08:00
Pavel Yaskevich
b1e30b22b9 [Sema] Impliment initial validation of @execution(concurrent) attribute 2025-01-17 15:40:01 -08:00
Pavel Yaskevich
00fe5632d7 [TypeChecker] Downgrade noasync availability to warnings on @preconcurrency declarations
This change helps to stage in new `async` overloads in Swift 6 language mode
if `@preconcurrency` declaration is not available from async contexts.
2025-01-17 14:01:34 -08:00
Allan Shortlidge
87308e37f1 AST: Avoid creating duplicate AvailabilityScopes under SequenceExprs.
Since availability scopes may be built at arbitrary times, the builder may
encounter ASTs where SequenceExprs still exist and have not been folded, or it
may encounter folded SequenceExprs that have not been removed from the AST.

To avoid a double visit, track whether a SequenceExpr is folded and then
customize how ASTVisitor handles folded sequences.

Resolves rdar://142824799 and https://github.com/swiftlang/swift/issues/78567.
2025-01-17 10:21:22 -08:00
Michael Gottesman
2adc68b36b Merge pull request #78665 from gottesmm/pr-054dfe289af455d0471eefd8e16ff4496a45c2f9
[concurrency] Inherit caller isolation inheriting when inferring isolation from a nominal type context for a method on the nominal type.
2025-01-16 10:41:02 -08:00
Saleem Abdulrasool
0e77477147 Merge pull request #78553 from compnerd/well-known-imports
IRGen: further generalise runtime function generation
2025-01-16 09:25:54 -08:00
Slava Pestov
d1d2411bf3 Merge pull request #78267 from slavapestov/incremental-bindings-part-0
Sema: Some small cleanups in CSBindings.cpp and related code
2025-01-16 09:03:32 -05:00
Anthony Latsis
99c3802e02 Merge pull request #78669 from AnthonyLatsis/andromeda
[NFC] Add some unit tests for diagnostic behaviors
2025-01-16 06:30:56 +00:00
Slava Pestov
9a48fed9c7 Sema: Add BindingSet::operator==
This will be used for debugging.
2025-01-15 22:30:34 -05:00
Slava Pestov
bed95dd1a4 Sema: Simplify PotentialBindings updates a little 2025-01-15 22:30:34 -05:00
Slava Pestov
340a60b0b9 Sema: Add PotentialBindings::dump() and improve BindingSet::dump() 2025-01-15 22:30:33 -05:00
Slava Pestov
cfcc73f164 Sema: Add -solver-disable-splitter flag for debugging
We're not planning on removing the splitter because it is a big win
in some cases, but we want to run it less often since it can also
be a source of overhead. This flag allows us to compare performance
to understand the tradeoffs better.
2025-01-15 22:30:33 -05:00
Slava Pestov
1aff26eaa6 Sema: Store BindingSet inside the ConstraintGraphNode
Building the DenseMap in determineBestBindings() is extremely
expensive.

Also rename getCurrentBindings() to getPotentialBindings().
2025-01-15 22:30:32 -05:00
Anthony Latsis
87cf1179ff [NFC] Sema: Add Solution::getCalleeOverloadChoice 2025-01-16 02:35:26 +00:00
Michael Gottesman
26512720db [concurrency] Inherit caller isolation inheriting when inferring isolation from a nominal type context for a method on the nominal type.
rdar://142790025
2025-01-15 14:41:26 -08:00
Saleem Abdulrasool
ec70054c93 IRGen: further generalise runtime function generation
This adjusts the runtime function declaration handling to track the
owning module for the well known functions. This allows us to ensure
that we are able to properly identify if the symbol should be imported
or not when building the shared libraries. This will require a
subsequent tweak to allow for checking for static library linkage to
ensure that we do not mark the symbol as DLLImport when doing static
linking.
2025-01-15 13:54:34 -08:00
Chris Miles
73b184df24 Merge pull request #78564 from swiftlang/eng/chrismiles/playground-transform-crash-parsing-nested-generic-func
Fixes crash instrumenting generic func body nested in another func.

The crash was caused by attempting to add logging expressions that capture generic variables while using the outer func decl context that was not the generic decl context of the inner (generic) func.

The fix "pushes" the current func decl context while instrumenting the body. Rather than always using the top-level func decl context for all nested func bodies.
2025-01-15 10:05:25 -08:00
Pavel Yaskevich
1932d07fe7 Merge pull request #78650 from xedin/rdar-142567811
[Sema] Emit dynamic actor isolation checks for derived protocol witnesses
2025-01-15 09:39:01 -08:00
Pavel Yaskevich
a30bcffcac [Sema] Emit dynamic actor isolation checks for derived Codable protocol witnesses 2025-01-14 17:05:37 -08:00
Pavel Yaskevich
04fd5a2c2a [Sema] Emit dynamic actor isolation checks for derived Equatable/Hashable protocol witnesses 2025-01-14 17:05:31 -08:00
Pavel Yaskevich
f10a4819fd [Sema] NFC: Add a variant of addNonIsolatedToSynthesized that checks for @preconcurrency conformances
If derived conformance is marked as `@preconcurrency` instead of
marking synthesized members as `nonisolated` the compiler should
insert dynamic checks.
2025-01-14 15:44:57 -08:00
Anthony Latsis
8dd7669816 Merge pull request #78592 from AnthonyLatsis/meganeura-monyi
Sema: Specify compatibility margin for `access_control_non_objc_open_member`
2025-01-14 20:52:08 +00:00
Chris Miles
f2846ce2cb Fixes crash while instrumenting generic func body embedded in another func.
The crash was caused by attempting to add logging expressions that capture generic variables while using the outer func decl context that was not the generic decl context of the inner (generic) func.

The fix "pushes" the current func decl context while instrumenting the body. Rather than always using the top-level func decl context for all nested func bodies.
2025-01-14 11:19:27 -08:00
Anthony Latsis
fba8095144 Merge pull request #78602 from AnthonyLatsis/gyromitra-esculenta
ConformanceChecker: Make `actor_isolated_witness` call out the protocol
2025-01-14 19:08:06 +00:00
Anthony Latsis
e626887dcc Sema: Improve requirement indicator note for actor_isolated_witness
`x declared here` is not helpful and clear enough, especially when there
are other notes attached. Swap it for a new note that says
`requirement x declared here`.
2025-01-14 14:52:41 +00:00
Anthony Latsis
f85eb97337 ConformanceChecker: Make actor_isolated_witness call out the protocol 2025-01-14 14:49:22 +00:00
Alexis Laferrière
aa75341b20 Sema: Accessors's SPI are tied to the attributes on the storage
Recent changes started using SPIGroupRequest on accessors specifically
to verify access to the wrappedValue of PropertyWrappers within the
direct access logic on variables using the property wrapper. Update
SPIGroupRequest to support this request and the type-checking logic to
accept the @_spi attribute on internal usable from inline accessors.

rdar://141964200
2025-01-13 17:02:40 -08:00
Slava Pestov
5f79319c45 Merge pull request #78559 from slavapestov/fix-rdar141968103
Sema: Relax primary associated type matching in matchExistentialTypes()
2025-01-13 12:04:57 -05:00
Pavel Yaskevich
84c7188219 Merge pull request #78526 from xedin/issue-78371
[CSOptimizer] Literal arguments should cause score reset only for operators
2025-01-13 08:59:36 -08:00
Alejandro Alonso
09d122af7c Merge pull request #76438 from Azoy/vector
[stdlib] Slab
2025-01-12 10:36:25 -08:00
Anthony Latsis
75953d2b51 OpenedExistentials: Do not attempt to erase existential metatypes with invariant Self
The non-metatype case was never supported. The same should hold for the
existential metatype case, which used to miscompile and now crashes
because the invariant reference is deemed OK but the erasure expectedly
fails to handle it:

```swift
class C<T> {}
protocol P {
  associatedtype A

  func f() -> any P & C<A>
  func fMeta() -> any (P & C<A>).Type
}

do {
  let p: any P
  let _ = p.f() // error
  let _ = p.fMeta() // crash
}
```
2025-01-12 17:47:52 +00:00
Anthony Latsis
6a0834f2fc Sema: Minor improvements to access_control_non_objc_open_member message
* Use the '%kindonly' specifier.
* Make the object and its modifier agree on grammatical number.
* 'in extension' → 'declared in extension'.
2025-01-12 15:28:00 +00:00