Commit Graph

28352 Commits

Author SHA1 Message Date
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
Hamish Knight
23e3f5f5de Merge pull request #77666 from hamishknight/lets-try-this-again
[AST] Remove `ModuleDecl::addFile`
2024-11-21 20:15:58 +00:00
Allan Shortlidge
afad02e393 AST: Adopt AvailableAttr::isLanguageVersionSpecific(). 2024-11-21 09:10:36 -08:00
Allan Shortlidge
36230cd9c6 AST: Use an accessor to get the PlatformKind from an AvailableAttr. 2024-11-21 09:10:36 -08:00
Hamish Knight
68648f74ef [CS] Use adjusted type for single curry thunks
This matches the double curry thunk logic and
ensures that the resulting autoclosure matches the
expected type of the reference, avoiding mismatches
with parent expressions.

rdar://140212823
2024-11-21 12:14:00 +00:00
Hamish Knight
683c7ceb31 [CS] Simplify opened types earlier in buildMemberRef
Doesn't seem to be any reason not to do this
up-front, cleans up the code a little. Should be
NFC.
2024-11-21 12:13:59 +00:00
Hamish Knight
4d668e7b42 [Sema] Respect global actors on autoclosures
Previously we would only respect global actors
set on explicit closure expressions. Respect them
on autoclosures too.
2024-11-21 12:13:59 +00:00
Slava Pestov
25252cd683 Merge pull request #77728 from slavapestov/cg-cleanup
Sema: Small ConstraintGraph cleanup
2024-11-20 19:43:42 -05:00
Slava Pestov
8b61c9b442 Merge pull request #77723 from slavapestov/too-complex-stats
Sema: Progress towards an improved "too complex" check
2024-11-20 19:43:32 -05:00
Andrew Trick
cf1a946786 Give ~Escapable _read accessors with borrow scope borrowed ownership
This applies to all _read accessors whose result depends on a borrow
of self. In this case, the coroutine defines the borrow scope, and the
~Escapable property value can only be used within that scope. This
makes it impossible to synthesize a getter. Returning the ~Escpable
value from the getter would always escape the coroutine.
2024-11-20 11:28:54 -08:00
Slava Pestov
7fef225c9f Sema: Allow turning off expression timer with -solver-expression-time-threshold=0 2024-11-20 13:46:19 -05:00
Slava Pestov
c8415aeac4 Sema: Record the trail step count in solver statistics
Also introduce two new frontend flags:

The -solver-scope-threshold flag sets the maximum number of scopes, which was
previously hardcoded to 1 million.

The -solver-trail-threshold flag sets the maximum number of trail steps,
which defaults to 64 million.
2024-11-20 13:46:19 -05:00
Slava Pestov
60d34a4162 Sema: Micro-optimize PotentialBindings
PotentialBindings is part of ConstraintGraphNode and there's no need
to store the ConstraintSystem and TypeVariableType twice.

Also it doesn't need to be optional either, because we no longer need
to reset and recompute bindings.
2024-11-20 13:35:22 -05:00
Slava Pestov
1bdf7f0192 Sema: Assert that the constraint graph node is empty before recycling 2024-11-20 13:35:22 -05:00
Slava Pestov
1a18d70f90 Sema: Remove ConstraintSystem::SolverState::isRecordingChanges()
All but two remaining call sites can be changed to just check for a
non-null solverState, because we want to assert if we're inside
of an active undo.

The two places inside binding inference can check isUndoActive()
directly.
2024-11-20 13:35:22 -05:00
Slava Pestov
24de22a078 Sema: Split off ConstraintGraph::addTypeVariable() from ::operator[]
Also, since we add a vertex immediately after introducing a new type
variable, the code path to handle the case where the type variable
had a parent or fixed type was actually dead.
2024-11-20 13:35:21 -05:00
Slava Pestov
c5de105a2b Sema: Workaround for invalid logic in Solution::simplifyTypeForCodeCompletion() 2024-11-20 13:35:21 -05:00
Slava Pestov
6ff8f55634 Sema: Fix handling of Solution::typeBindings in replaySolution() 2024-11-20 13:35:21 -05:00
Allan Shortlidge
ec8558942c Merge pull request #77720 from tshortli/remove-get-potentially-unavailable
AST: Remove `DeclAttributes::getPotentiallyUnavailable()`
2024-11-20 09:26:48 -08:00
Slava Pestov
de731b4d5d Sema: Preserve insertion order in Solution::typeBindings 2024-11-20 11:47:07 -05:00
Pavel Yaskevich
9eaad6315c Merge pull request #77689 from JanBaig/issue-65500
[CSGen] Fix compiler crash when property wrapper applied to a param lacks wrappedValue initializer
2024-11-20 08:44:49 -08:00
Pavel Yaskevich
9665b0d4e3 Merge pull request #77592 from xedin/rdar-139675914
[CSSimplify] CGFloat-Double: Fix ambiguity when assigning CGFloat to …
2024-11-20 08:44:19 -08:00
Slava Pestov
b760cfd03d Sema: Fold ConstraintGraph::lookupNode() into ::operator[]
lookupNode() returned a pair but both callers only looked at the
first element of the pair.
2024-11-20 08:23:58 -05:00
Slava Pestov
a7b1e7854c Merge pull request #77174 from slavapestov/fix-undo-order
Sema: Undo changes in chronological order in SolverTrail::undo()
2024-11-20 08:00:53 -05:00
Slava Pestov
729e3c032a Merge pull request #77690 from slavapestov/fix-rdar139238003
Sema: Downgrade nonisolated lazy error to warning until -swift-version 6
2024-11-20 00:38:43 -05:00
Slava Pestov
89529af2e3 Merge pull request #77716 from slavapestov/solution-total-memory
Sema: Cache Solution::getTotalMemory()
2024-11-20 00:06:15 -05:00
Slava Pestov
a19c92a4e0 Sema: Extract duplication from ConstraintGraph::introduceTo/retractFromInference(Type) overloads 2024-11-19 21:24:13 -05:00
Slava Pestov
eeab483cab Sema: Undo changes in chronological order in SolverTrail::undo() 2024-11-19 21:24:12 -05:00
Slava Pestov
1a60685292 Sema: Address the FIXME in ConstraintGraph::mergeNodes() 2024-11-19 21:24:12 -05:00
Slava Pestov
5690addb4e Sema: Fix ordering of constraint graph updates vs fixed type assignment 2024-11-19 21:24:12 -05:00
Slava Pestov
0d3d31599f Sema: Remove ConstraintGraph::reintroduceToInference() 2024-11-19 21:24:12 -05:00