Commit Graph

28382 Commits

Author SHA1 Message Date
Allan Shortlidge
ac98262798 Sema: Adopt AvailabilityContext in ExportContext.
Query for an AvailabilityContext instead of computing availability with a
DeclContext traversal when forming an ExportContext.
2024-10-22 08:39:30 -07:00
Allan Shortlidge
536e666aba Sema: Introduce TypeChecker::availabilityAtLocation().
Implement a query that returns the `AvailabilityContext` for a given
`SourceLoc` and `DeclContext`. Re-implement the existing type checker query
that just returns an `AvailabilityRange` on top of the new query.
2024-10-22 08:39:30 -07:00
Allan Shortlidge
f0a5a5ebaf Sema: Fix TypeRefinementNode kind for unavailable/deprecated decls. 2024-10-22 08:39:30 -07:00
Allan Shortlidge
eedb63493a Sema: Always query abstract syntax decls for availability attributes. 2024-10-22 08:39:29 -07:00
Allan Shortlidge
009ff8ab69 Merge pull request #77144 from tshortli/expand-availability-context
AST: Refactor AvailabilityContext into a value type
2024-10-21 22:59:16 -07:00
Slava Pestov
1cbd7d3163 Merge pull request #77152 from slavapestov/fix-issue-77008
Sema: Give constraints a more dignified retirement
2024-10-21 22:10:05 -04:00
Allan Shortlidge
b346385544 AST: Refactor AvailabilityContext into a value type.
Make the pointer to uniqued storage an implementation detail of an
`AvailabilityContext` value. This way clients of `AvailabilityContext` don't
need to think about pointers and can have access to mutating operations on a
context when appropriate.
2024-10-21 15:16:08 -07:00
Pavel Yaskevich
2b11ecbec9 [CSBindings] Limit BindingSet::isViable binding skipping to stdlib collection types
This is follow-up to https://github.com/swiftlang/swift/pull/76487

It's reasonable to coalesce bindings of different kind if they don't
allow implicit conversions like stdlib collection types do.

Resolves: https://github.com/swiftlang/swift/issues/77003
2024-10-21 14:48:45 -07:00
Slava Pestov
65def070dc Sema: Remove similar weirdness from ~ConjunctionStep 2024-10-21 17:21:09 -04:00
Slava Pestov
e0b6a96f0e Sema: Retire disjunctions in trail instead of restoring in ~DisjunctionStep
Fixes https://github.com/swiftlang/swift/issues/77008.
2024-10-21 17:19:33 -04:00
Slava Pestov
58a6a64647 Sema: SolverTrail::Change::RetiredConstraint now remembers the position 2024-10-21 17:19:01 -04:00
Allan Shortlidge
47e41855d0 AST/Sema: Adopt AvailabilityContext in TypeRefinementContext.
Begin using `AvailabilityContext` as the availability representation in
`TypeRefinementContext`, instead of only storing platform introduction
availability ranges.

There should be no functional changes since this just changes the
representation of the existing information stored by `TypeRefinementContext`.
However, in the future `AvailabilityContext` will be expanded to represent
additional availability constraints.
2024-10-17 17:32:05 -07:00
Sophia Poirier
84eaee474c [Concurrency] fix erroneous "@preconcurrency import" diagnostic when protocol sendability conformance diagnostic has been suppressed under minimal concurrency checking (resolves #74904) 2024-10-16 16:18:21 -07:00
Allan Shortlidge
6cb338222d Sema: Fix source ranges for string literals in TypeRefinementContext.
Since string literals are only a single token from the perspective of the
parser, the source range for a pattern binding decl that is initialized with a
string literal expression only extends to the beginning of the string literal.
To ensure the TypeRefinementContext for a pattern binding decl includes the
entire contents of the init expression we must calculate the character source
range of the decl instead.

Resolves rdar://110952225 and https://github.com/swiftlang/swift/issues/77050.
2024-10-16 14:24:32 -07:00
Allan Shortlidge
7819dd7833 AST/Sema: Remove unnecessary ASTContext parameters from availability APIs.
Many of the methods on `AvailabilityInference` take both a `Decl` and an
`ASTContext`, which is redundant.
2024-10-14 17:46:53 -07:00
Pavel Yaskevich
f6a0f5527d Merge pull request #76952 from xedin/void-has-no-subtype-conversions
[CSBindings] Adjust `hasConversions` to handle `Void` has having not …
2024-10-14 22:15:16 +09:00
Gábor Horváth
a9d59034b3 Merge pull request #76956 from swiftlang/gaborh/treat-c-struct-as-resilient
[cxx-interop] Consider extern "C" structs as resilient
2024-10-14 12:31:16 +01:00
Rintaro Ishizaki
231e3334e7 Merge pull request #76981 from rintaro/precheck-optional-eval-expr
[Parse/Sema] Move OptionalEvaluationExpr wrapping to PreCheckTarget
2024-10-13 07:29:40 -07:00
Rintaro Ishizaki
ffeaa719ef [Sema] Ensure postfix operator is not a part of implicit member chain
But a part of optional chain.
2024-10-12 17:24:08 -07:00
Holly Borla
2f33d875d9 Merge pull request #76988 from hborla/init-checking-order
[Sema] Fix an issue with the ordering of effects checking and actor isolation checking.
2024-10-12 11:21:33 -07:00
Hamish Knight
7c3f965578 Merge pull request #76979 from hamishknight/regex-request
Requestify regex pattern parsing
2024-10-12 19:19:09 +01:00
Allan Shortlidge
6c18bf2932 Merge pull request #76989 from tshortli/remove-trc-explicit-availability 2024-10-11 21:42:39 -07:00
Holly Borla
e1bf19822d [Sema] Put effects checking behind a request for experimental lazy
type checking.
2024-10-11 20:33:38 -07:00
Allan Shortlidge
6bc9cf5e43 AST: Remove ExplicitAvailabilityInfo from TypeRefinementContext.
This field was complicating initialization of `TypeRefinementContext` and
bloating its storage just to make it slightly more convenient to look up
information that is pretty easy to derive on-demand when it is actually needed.
2024-10-11 17:10:38 -07:00
Holly Borla
55e9f374de [Concurrency] Clean up code that determines whether a closure is an actor
isolation inference boundary.
2024-10-11 16:51:09 -07:00
nate-chandler
249831f9f3 Merge pull request #76942 from nate-chandler/general-coro/20240927/1
[CoroutineAccessors] SIL represents callee alloc.
2024-10-11 16:39:53 -07:00
Holly Borla
7de7eafd22 [Concurrency] Don't walk into sending closures when computing the
required isolation of a default value expression.
2024-10-11 16:04:58 -07:00
Holly Borla
dad0027d39 [Sema] Run effects checking after actor isolation checking.
Effects checking for `async` requires actor isolation to have been
computed. This change removes effects checking out of the contextualize
initializers request, because effects checking isn't needed for
secondary files. Instead, effects checking is done in the primary decl
checker after actor isolation checking.
2024-10-11 15:31:46 -07:00
Rintaro Ishizaki
8e8e4d0193 [Parse/Sema] Move OptionalEvaluationExpr wrapping to PreCheckTarget
This simplify the Parser diagnostics and some type checker logic.
2024-10-11 13:12:48 -07:00
Hamish Knight
6a435960b7 Requestify regex pattern parsing
Instead of doing the pattern parsing in both the
C++ parser and ASTGen, factor out the parsing into
a request that returns the pattern to emit, regex
type, and version. This can then be lazily run
during type-checking.
2024-10-11 19:25:58 +01:00
Anthony Latsis
8519334b89 Merge pull request #76749 from AnthonyLatsis/amanita-muscaria 2024-10-11 18:02:36 +00:00
Nate Chandler
df1c4f6b25 [CoroutineAccessors] Add new SILFnTy CoroKind.
For `modify` and `read` coroutines, produce SILFunctionType's whose
coroutineKind is ::YieldOnce2.
2024-10-11 08:25:02 -07:00
Allan Shortlidge
4acfd20f04 Merge pull request #76972 from tshortli/trc-expansion-request-side-effect 2024-10-10 22:59:27 -07:00
Slava Pestov
9e37df77fe Merge pull request #76965 from slavapestov/type-of-reference
Sema: Split off TypeOfReference.cpp from ConstraintSystem.cpp
2024-10-10 22:28:02 -04:00
Allan Shortlidge
5440dcef92 AST: Make ExpandChildTypeRefinementContextsRequest a side effectful request.
While returning the actual child vector from
`ExpandChildTypeRefinementContextsRequest` is a nice idea, it is both
inefficient (the vector gets copied in and out) and kind of inaccurate, since
the vector remains mutable after the initial expansion and may gain additional
children as macros are lazily expanded.
2024-10-10 18:06:39 -07:00
Anthony Latsis
41adfec8da [NFC] AST, Sema: Move TypeChecker::findReturnStatements into AnyFunctionRef
Also rename it to `getExplicitReturnStmts` for clarity and have it
take a `SmallVector` out parameter instead as a small optimization and
to discourage use of this new method as an alternative to
`AnyFunctionRef::bodyHasExplicitReturnStmt`.
2024-10-11 03:57:43 +03:00
Anthony Latsis
e31e8773d5 [NFC] Sema: Reimplement ReturnStmtFinder as a function with a callback
A callback enables the caller to control whether to abort the walk. This
is handy for `BraceHasExplicitReturnStmtRequest`.
2024-10-11 03:46:35 +03:00
Anthony Latsis
244185c4f4 [NFC] AST: Rename BraceHasReturnRequest to BraceHasExplicitReturnStmtRequest 2024-10-11 03:44:43 +03:00
Anthony Latsis
c7ea672463 [NFC] AST, Sema: Internalize BraceHasReturnRequest evaluation in AnyFunctionRef method 2024-10-11 03:44:43 +03:00
Anthony Latsis
3742da743c Sema: Result builder inference from dynamically replaced decl should look at getter, not storage 2024-10-11 03:44:42 +03:00
Anthony Latsis
5de14cb5a1 [NFC] Sema: Add more comments to inferResultBuilderType 2024-10-11 03:44:42 +03:00
Anthony Latsis
16f97d7ccf Sema: Result builder inference from protocol req should look at getter, not storage 2024-10-11 03:44:42 +03:00
Anthony Latsis
c99657308c Sema: Result builder inference always favors explicit attr on storage decl 2024-10-11 03:44:42 +03:00
Slava Pestov
61bd58d5ef Sema: Split off TypeOfReference.cpp from ConstraintSystem.cpp 2024-10-10 17:53:12 -04:00
Slava Pestov
3a4de0b953 Sema: Optimize computeConnectedComponents()
If there is only one connected component, we don't actually have
to form the array of components at all. Re-organize the code so
that we can short-circuit this decision as soon as possible.
2024-10-10 17:05:30 -04:00
Gabor Horvath
625f45a928 [cxx-interop] Consider extern "C" structs as resilient
Changing the members of these structs are still API and ABI breaking
changes but they are not as fragile as C++ classes where adding/removing
virtual functions or doing other changes can also result in breaking the
ABI.

rdar://119319825
2024-10-10 17:58:09 +01:00
Gábor Horváth
b5a85ed8dc Merge pull request #76907 from swiftlang/gaborh/assume-resilient-cxx-types
[cxx-interop] Add flag to assume C++ types are resilient
2024-10-10 17:15:15 +01:00
Pavel Yaskevich
76f0bcb05c [CSBindings] Adjust hasConversions to handle Void has having not conversions
Tuples in general do have conversions but an empty tuple or `Void`
doesn't, which means that if a type variable has a subtype binding
to `Void` it should be safe to prioritize.
2024-10-10 23:35:53 +09:00
Rintaro Ishizaki
f7e62d892f Merge pull request #76937 from rintaro/swift-macro-evaluation-rdar137448282
[ASTGen] Rename 'swiftMacros' module to 'swiftMacroEvaluation'
2024-10-09 19:15:34 -07:00
Slava Pestov
04f48db7f2 Merge pull request #76932 from slavapestov/cstrail-part-6
Sema: Small SolverTrail cleanups
2024-10-09 20:39:09 -04:00