Commit Graph

27454 Commits

Author SHA1 Message Date
Allan Shortlidge
9796d1b1f3 Merge pull request #78832 from tshortli/downgrade-more-available-than-enclosing-for-different-domain
Sema: Loosen the decl more available than enclosing diagnostic
2025-01-23 00:24:02 -08:00
Allan Shortlidge
3b7ff19630 Sema: Loosen the decl more available than enclosing diagnostic.
Downgrade the `cannot be more available than enclosing scope` error to a
warning when the attribute making the decl too available is specified for a
less specific platform.

Resolves rdar://143423070.
2025-01-22 17:02:37 -08:00
Allan Shortlidge
2908520841 AST: Introduce SemanticAvailableAttrRequest.
This request will finish type checking an AvailableAttr by resolving its domain
and then enforcing any restrictions that the domain has on the attribute, like
disallowing version specifications.

This change just introduces the request and plumbs it through. NFC.
2025-01-22 16:01:19 -08:00
Pavel Yaskevich
ab8b1cd869 Merge pull request #78789 from xedin/fix-generic-arg-mismatch-with-leading-dot-syntax
[Diagnostics] Fix generic arguments mismatch diagnostic related to le…
2025-01-22 14:32:05 -08:00
Anthony Latsis
499146df88 Merge pull request #78739 from AnthonyLatsis/hatzegopteryx
TypeCheckType: Rework IUO diagnostics using behavior limitation
2025-01-22 19:12:02 +00:00
Allan Shortlidge
190779ecd4 Merge pull request #78797 from tshortli/availability-context-unavailable-domain
AST: Track an unavailable domain instead of platform in AvailabilityContext
2025-01-22 10:31:51 -08:00
Joe Groff
5d0fe0a156 Merge pull request #78705 from jckarter/explicit-conditional-invertible-extension-requirements
Require explicit statement of all `Copyable`/`Escapable` requirements for conditional `Copyable`/`Escapable` conformances.
2025-01-22 09:52:26 -08:00
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
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
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