Commit Graph

28382 Commits

Author SHA1 Message Date
Pavel Yaskevich
f18b772293 [CSTrail] NFC: Make dumpActiveScopeChanges friendlier to humans
`dumpActiveScopeChanges` is used as part of `-debug-constraints`
and could be overwhelming if there are a lot of changes in the scope
because it prints every change including binding inference from
every applicable constraint.

These changes make `dumpActiveScopeChanges` more of summary of
what happened with type variables and constraints so far which
is much easier to navigate while debugging.
2024-12-04 10:36:05 -08:00
Pavel Yaskevich
08720eef82 Merge pull request #77936 from xedin/revert-void-favoring
Revert changes related to `Void` binding favoring
2024-12-04 10:24:20 -08:00
Anthony Latsis
73cabe303b Sema: Account for existential member access limitations in doesStorageProduceLValue 2024-12-04 15:03:39 +00:00
aphananthe42
f4a3a65411 Fix: Adjust the declaration positions of writtenBase and correctedBase 2024-12-04 23:30:10 +09:00
Hamish Knight
3c662c6276 [CS] Support IUOs for compound function references
This was previously an artificial limitation of the
FunctionRefKind representation, there's no reason
we shouldn't support IUOs for functions referenced
using a compound name.
2024-12-04 11:11:32 +00:00
Michael Gottesman
87495c6b83 Merge pull request #77900 from gottesmm/rdar127477211
[region-isolation] Perform checking of non-Sendable results using rbi rather than Sema.
2024-12-03 22:08:49 -08:00
Joe Groff
3c0b08dbcb Prototype an @_addressable attribute that puts an argument at a stable address.
Many APIs using nonescapable types would like to vend interior pointers to their
parameter bindings, but this isn't normally always possible because of representation
changes the caller may do around the call, such as moving the value in or out of memory,
bridging or reabstracting it, etc. `@_addressable` forces the corresponding parameter
to be passed indirectly in memory, in its maximally-abstracted representation.
[TODO] If return values have a lifetime dependency on this parameter, the caller must
keep this in-memory representation alive for the duration of the dependent value's
lifetime.
2024-12-03 20:39:23 -08:00
Hamish Knight
8d65fb3250 Merge pull request #77919 from hamishknight/remove-hack
[CS] Remove hack for rdar://139234188
2024-12-04 01:05:57 +00:00
Pavel Yaskevich
ffac97a1ee Revert "[CSBindings] Adjust hasConversions to handle Void has having not conversions"
This reverts commit 76f0bcb05c.
2024-12-03 13:15:49 -08:00
Pavel Yaskevich
8aa6280bf3 Revert "[CSBindings] Don't favor application result types before application happens"
This reverts commit bc949c3680.
2024-12-03 13:15:46 -08:00
Allan Shortlidge
ecf7ac910e Merge pull request #77907 from tshortli/semantic-decl-availability
AST: Refactor semantic unavailability queries
2024-12-03 08:30:13 -08:00
Kuba (Brecka) Mracek
8792efedf0 Merge pull request #77115 from kubamracek/embedded-mangling-prefix
[Mangling] [NFC] Prepare for a new mangling prefix for Embedded Swift: $e
2024-12-03 08:10:49 -08:00
Egor Zhdan
475e5442ed Merge pull request #77897 from swiftlang/egorzhdan/allow-nonresilient-cxx-in-overlay
[cxx-interop] Allow using non-resilient C++ symbols in resilient overlays
2024-12-03 12:57:19 +00:00
Hamish Knight
d25bdfa4a3 [CS] Remove hack for rdar://139234188
Now that "is compound" is a separate bit in
FunctionRefInfo, we can correctly track the
application level for an EnumElementPattern.
2024-12-03 11:32:11 +00:00
Hamish Knight
0fdb038fc9 Merge pull request #77896 from hamishknight/functionref-split
[AST] Split out "is compound" bit on FunctionRefKind
2024-12-03 09:53:37 +00:00
Allan Shortlidge
64f9d5b945 AST: Remove Decl::getSemanticUnavailableAttr().
Also remove the underlying `SemanticUnavailableAttrRequest`, which used memory
very inefficiently in order to cache a detailed answer to what was usually a
much simpler question.

The only remaining use of `Decl::getSemanticUnavailableAttr()` that actually
needed to locate the semantic attribute making a declaration unavailable was in
`TypeCheckAttr.cpp`. The implementation of the request could just be used
directly in that one location. The other remaining callers only needed to know
if the decl was unavailable or not, which there are simpler queries for.

 # Please enter the commit message for your changes. Lines starting
2024-12-02 23:00:43 -08:00
Allan Shortlidge
b2cc10cd94 AST: Introduce Decl::isSemanticallyUnavailable().
Adopt it in a few places as a replacement for `Decl::getSemanticUnavailableAttr()`.
2024-12-02 23:00:43 -08:00
aphananthe42
022af38d17 Refactor: Replace starts_with("_") with hasUnderscoreNaming() 2024-12-03 09:54:00 +09:00
Pavel Yaskevich
8a0a083a45 Merge pull request #77797 from xedin/locatable-types
[AST/Sema]  Introduce a new type that has associated location in source
2024-12-02 16:33:43 -08:00
Kuba Mracek
9c77074cac [Mangling] Establish a new mangling prefix for Embedded Swift: $e 2024-12-02 15:01:24 -08:00
Kuba Mracek
6f4ae28520 [ASTMangler] Pass ASTContext to all instantiations of ASTMangler 2024-12-02 15:01:04 -08:00
Allan Shortlidge
e131682e19 Merge pull request #77886 from tshortli/consolidate-availability-queries-on-decl
AST: Consolidate queries for `@available` attributes on `Decl`
2024-12-02 14:21:45 -08:00
Michael Gottesman
7e05f1d562 Merge pull request #77817 from gottesmm/pr-ade4fb7f7990b00ba46cfd66429dc97a2af58c7a
[assume-mainactor] Only perform the change for items that are within the current module.
2024-12-02 16:54:56 -05:00
Michael Gottesman
cff835e061 [region-isolation] Perform checking of non-Sendable results using rbi rather than Sema.
In terms of the test suite the only difference is that we allow for non-Sendable
types to be returned from nonisolated functions. This is safe due to the rules
of rbi. We do still error when we return non-Sendable functions across isolation
boundaries though.

The reason that I am doing this now is that I am implementing a prototype that
allows for nonisolated functions to inherit isolation from their caller. This
would have required me to implement support both in Sema for results and
arguments in SIL. Rather than implement results in Sema, I just finished the
work of transitioning the result checking out of Sema and into SIL. The actual
prototype will land in a subsequent change.

rdar://127477211
2024-12-02 16:54:12 -05:00
Pavel Yaskevich
1f7b76edd3 Merge pull request #77816 from xedin/fix-property-wrapper-projected-value-applies
[CSApply] Avoid shortcutting argument conversion when parameter has a…
2024-12-02 13:52:30 -08:00
Egor Zhdan
f420456899 [cxx-interop] Allow using non-resilient C++ symbols in resilient overlays
If a Swift module built with library evolution enabled is an overlay of a C++ module, allow referring to the non-resilient C++ symbols from the Swift code.

Overlays are usually built and shipped along with the C/C++ modules, so library evolution is less of a concern there. A developer providing a Swift overlay for a C++ library would expect to be able to refer to the symbols from the C++ library within the overlay.
2024-12-02 19:44:32 +00:00
Anton Korobeynikov
8e53ccd671 [AutoDiff] Peel off @sendable implicit conversion when checking for unsupported differentiable function conversion (#77869) 2024-12-02 10:29:37 -08:00
Rintaro Ishizaki
30cf6472af Merge pull request #77813 from rintaro/member-chain-specialize
[PreCheckTarget] Consider UnresolvedSpecializeExpr a chain expression
2024-12-02 09:33:38 -08:00
Allan Shortlidge
d8c946d186 AST: Introduce Decl::getActiveAvailableAttrForCurrentPlatform(). 2024-12-02 07:35:58 -08:00
Allan Shortlidge
5cdcb5d116 AST: Introduce Decl::getNoAsyncAttr(). 2024-12-02 07:35:58 -08:00
Allan Shortlidge
c5398e17d3 AST: Introduce Decl::getDeprecatedAttr().
It replaces `DeclAttr::getDeprecated()` as the designated way to query for the
attribute that makes a decl deprecated.
2024-12-02 07:35:58 -08:00
Allan Shortlidge
3e50a90c45 AST: Introduce Decl::getUnavailableAttr().
It replaces `DeclAttr::getUnavailable()` and `AvailableAttr::isUnavailable()`
as the designated way to query for the attribute that makes a decl unavailable.
2024-12-02 07:35:58 -08:00
Allan Shortlidge
2358712870 AST/Sema: Remove DeclAttr::isUnavailable().
Update callers to use `Decl::isUnavailable()` instead.
2024-12-02 07:35:58 -08:00
Allan Shortlidge
1dc7aa5b7b AST: Introduce Decl::isUnavailable().
Replace calls to `AvailableAttr::isUnavailable()` with `Decl::isUnavailable()`.
2024-12-02 07:35:58 -08:00
Allan Shortlidge
94f4b0598a Sema: Remove unnecessary parameter from getUnsatisfiedAvailabilityConstraint().
The `DeclContext` was unused.
2024-12-02 07:35:58 -08:00
Allan Shortlidge
669930e5d7 Merge pull request #77818 from tshortli/renamed-decl-requestification 2024-12-02 07:33:05 -08:00
Hamish Knight
73fb36f371 [AST] Split out "is compound" bit on FunctionRefInfo
FunctionRefKind was originally designed to represent
the handling needed for argument labels on function
references, in which the unapplied and compound cases
are effectively the same. However it has since been
adopted in a bunch of other places where the
spelling of the function reference is entirely
orthogonal to the application level.

Split out the application level from the
"is compound" bit. Should be NFC. I've left some
FIXMEs for non-NFC changes that I'll address in a
follow-up.
2024-12-02 14:11:33 +00:00
Hamish Knight
a4d51419ba [AST] NFC: Rename FunctionRefKind -> FunctionRefInfo 2024-12-02 14:11:32 +00:00
Allan Shortlidge
cd13d7d777 AST: Remove AvailableAttr::RenameDecl.
The renamed decl is now stored exclusively in the split request evaluator
storage, which is more efficient since most availability attributes do not
specify a renamed decl.
2024-11-29 10:35:02 -05:00
Anthony Latsis
1ce0aeefd2 Sema: Compute existential member access limitations for storage declarations 2024-11-25 14:16:07 +00:00
Anthony Latsis
01c899b31c SelfReferenceInfo: Collect references at all kinds of variance positions 2024-11-25 14:15:28 +00:00
Pavel Yaskevich
be1c9ad3eb [CSApply] CurryThunks: Add an assert to make sure that all applied property wrappers are used 2024-11-22 15:04:20 -08:00
Michael Gottesman
ade4fb7f79 [assume-mainactor] Only perform the change for items that are within the current module.
I also added a small runtime test just as a sanity check. We do not change any
codegen here since the change is at the Sema level... but I thought it would be
prudent to at least have a small smoke test.

rdar://140439795
2024-11-22 14:11:30 -08:00
Pavel Yaskevich
44908acd75 [CSApply] Avoid shortcutting argument conversion when parameter has an external property wrapper
The check to see whether argument matches the parameter exactly
causes two problems: prevents projected value initialized injection;
and, if there are multiple parameters with property wrappers,
would apply incorrect wrapper to other locations because the wrapper
application index wasn't incremented.

Resolves: rdar://140282980
2024-11-22 14:02:06 -08:00
Rintaro Ishizaki
bee4cfe3e5 [PreCheckTarget] Consider UnresolvedSpecializeExpr a chain expression
Optional chain and unresolved member chain should consider
a generic specialization as a chain expression.

rdar://140378864
2024-11-22 12:08:19 -08:00
Hamish Knight
746135b4d7 [CS] Add a narrow hack for rdar://139234188
Currently we set `FunctionRefKind::Compound` for
enum element patterns with tuple sub-patterns to
ensure the member has argument labels stripped. As
such, we need to account for the correct application
level in `getNumApplications`. We ought to be
setting the correct FunctionRefKind and properly
handling the label matching in the solver though.
We also ought to consider changing FunctionRefKind
such that "is compound" is a separate bit from the
application level.

rdar://139234188
2024-11-22 13:43:58 +00:00
Pavel Yaskevich
df6950af5d [CSSimplify] Fix locator of pack expansion pattern conformance constraint 2024-11-21 15:48:28 -08:00
Pavel Yaskevich
e3b1f341f0 [CSDiagnostics] Adjust conformance failure diagnostic to check for locatable types
If conformance failure is associated with a `LocatableType`, use
its location to anchor the failure.
2024-11-21 14:13:16 -08:00
Pavel Yaskevich
e61bf2089c [ConstraintSystem] Make types of implicit result builder variables locatable
This would aid `FailureDiagnostic` in anchoring conformance failures to `View`.
2024-11-21 14:12:57 -08:00
Allan Shortlidge
ad7383499b Merge pull request #77758 from tshortli/available-attr-conveniences
AST: `AvailableAttr` cleanup
2024-11-21 13:03:07 -08:00