Commit Graph

28352 Commits

Author SHA1 Message Date
Allan Shortlidge
0ac8cd35d2 Sema: Allow resilient modules to add enum elements without breaking clients.
In the implementation of https://github.com/swiftlang/swift/pull/73472,
warnings about uncovered cases were upgraded to errors in switches covering
enums with an `@unknown default` case. This change was a mistake; it should not
be source breaking for a resilient library to add new cases to a non-frozen
enum.

Resolves rdar://138488976.
2024-10-23 12:41:31 -07:00
nate-chandler
b7fd4e140d Merge pull request #77179 from nate-chandler/general-coro/20241017/1
[CoroutineAccessors] Permit read requirement.
2024-10-23 11:17:43 -07:00
Allan Shortlidge
3934f78ecd Merge pull request #77180 from tshortli/consolidate-availability-typechecking 2024-10-23 08:34:48 -07:00
Joe Groff
8242110bbe Merge pull request #76831 from jckarter/builtin-vector
Builtin.FixedArray
2024-10-23 05:20:21 -10:00
Allan Shortlidge
05b95b858c Sema: Reduce unnecessary exposure of availability checking helpers.
Make refactoring the availability checker easier by making functions that are
only called by `TypeCheckAvailability.cpp` static in that file.
2024-10-22 21:21:25 -07:00
Nate Chandler
f2e3e8e857 [Sema] Permit read requirement.
Along with `get` and `set`, permit `read` to be required.  When a type
defines `read`, the read impl is that `read`.
2024-10-22 18:02:30 -07:00
Slava Pestov
8beaa7b231 Sema: Fix matchExistentialType() handling of ProtocolCompositionType containing ParameterizedProtocolType
This fixes a soundness hole. We can't just match up the primary
associated types of different protocols.
2024-10-22 20:14:44 -04:00
Slava Pestov
3400022c63 Sema: Remove ConstraintKind::SelfObjectOfProtocol 2024-10-22 20:14:43 -04:00
Slava Pestov
54168849b0 Sema: Don't split up pack types in matchExistentialTypes() 2024-10-22 20:14:43 -04:00
Slava Pestov
c728c2aa8b Sema: Simplify doesStorageProduceLValue() 2024-10-22 20:14:43 -04:00
Slava Pestov
6c02529cf8 Sema: Simplify ConstraintSystem::getUnopenedTypeOfReference() 2024-10-22 20:14:43 -04:00
Slava Pestov
338ad3062d Sema: Tighten an invariant in ConstraintGraph
These functions are never called while undoing a change; so
we want to assert if we have an active undo instead of
silently not recording the change.
2024-10-22 20:14:43 -04:00
Slava Pestov
53794d3b6a Sema: Rename ConstraintSystem::generateConstraints() to ConstraintSystem::generateOverloadConstraints() 2024-10-22 20:14:43 -04:00
Slava Pestov
b44bff26b5 Sema: Fold Constraint::createFixedChoice() into Constraint::createBindOverload() 2024-10-22 20:14:42 -04:00
Slava Pestov
2eaec5a97f Sema: Remove Constraint::clone() 2024-10-22 20:14:42 -04:00
Slava Pestov
0de8428f34 Sema: Tail-allocate Constraint::Overload::Choice
OverloadChoice is rather large, 40 bytes.
2024-10-22 20:14:42 -04:00
Slava Pestov
a48591d71d Sema: Tail-allocate Constraint::TheFix
Most constraints don't have a fix, so we can tail-allocate the fix.
This saves 16 bytes per constraint, because it also eliminates some
padding.
2024-10-22 20:14:42 -04:00
Joe Groff
a184782a38 Introduce a Builtin.FixedArray type.
`Builtin.FixedArray<let N: Int, T: ~Copyable & ~Escapable>` has the layout of `N` elements of type `T` laid out
sequentially in memory (with the tail padding of every element occupied by the array). This provides a primitive
on which the standard library `Vector` type can be built.
2024-10-22 16:21:45 -07:00
Allan Shortlidge
cd25c00eb3 Merge pull request #77159 from tshortli/adopt-availability-context-in-export-context
Sema: Adopt AvailabilityContext in ExportContext
2024-10-22 13:13:09 -07:00
Pavel Yaskevich
6754918b08 Merge pull request #77153 from xedin/issue-77003
[CSBindings] Limit `BindingSet::isViable` binding skipping to stdlib …
2024-10-22 11:11:48 -07:00
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