Commit Graph

1645 Commits

Author SHA1 Message Date
Hamish Knight
a9d3df06b3 Merge pull request #74352 from hamishknight/complete-disjunction
[Completion] Skip `tryOptimizeGenericDisjunction` if there's a completion child
2024-06-14 09:25:19 +01:00
Doug Gregor
95e12ca584 Don't apply @Sendable to enum cases in pattern matching 2024-06-13 11:56:18 -07:00
Doug Gregor
c65264738b Treat references to enum cases with associated values as @Sendable functions
When `InferSendableFromCaptures`, make sure to treat references to enum
cases that have associated values as `@Sendable` functions.
2024-06-12 14:58:56 -07:00
Hamish Knight
09a1f0b0c1 [CS] NFC: Factor out includingParentApply 2024-06-12 19:38:09 +01:00
Tim Kientzle
1d961ba22d Add #include "swift/Basic/Assertions.h" to a lot of source files
Although I don't plan to bring over new assertions wholesale
into the current qualification branch, it's entirely possible
that various minor changes in main will use the new assertions;
having this basic support in the release branch will simplify that.
(This is why I'm adding the includes as a separate pass from
rewriting the individual assertions)
2024-06-05 19:37:30 -07:00
Doug Gregor
39f4e38027 Diagnose inout uses of 'lets' in constructors in the type checker.
Stored `let` properties of a struct, class, or actor permit
'inout' modification within the constructor body after they have been
initialized. Tentatively remove this rule, only allowing such `let`
properties to be initialized (assigned to) and not treated as `inout`.

Fixes rdar://127258363.
2024-05-14 15:59:50 -07:00
Anthony Latsis
d18a7fd073 Sema: Require CS to certify conversions associated w/ existential member accesses 2024-04-18 22:54:19 +03:00
Anthony Latsis
52d613e2c2 Sema: Fix existential member access type erasure around metatypes
The only case a singleton metatype transforms into an existential metatype is
when the instance type transforms into an existential from a non-existential.
2024-04-18 22:52:52 +03:00
Pavel Yaskevich
a7f9a689fc [ConstraintSystem] Move @Sendable inference for partially applied members to adjustFunctionTypeForConcurrency 2024-03-22 09:02:32 -07:00
Pavel Yaskevich
48e9684758 [ConstraintSystem] Move @Sendable inference for global functions to adjustFunctionTypeForConcurrency 2024-03-21 15:34:57 -07:00
Pavel Yaskevich
eb9755367c [ConstraintSystem] NFC: Switch adjustFunctionTypeForConcurrency to use FunctionType
This method is always called after the type is opened by the solver
which means that we never end up with `GenericFunctionType`.
2024-03-20 13:16:18 -07:00
Pavel Yaskevich
56d207ab1a Merge pull request #72277 from xedin/improvements-to-protocol-witness-matching
[Sema/ClangImporter] Improvements to witness matching
2024-03-19 09:36:32 -07:00
Pavel Yaskevich
38a6d88042 [ConstraintSystem] ConstraintLocator: Implement printing of decl anchors 2024-03-18 10:43:41 -07:00
Kavon Farvardin
149c052ec5 use new noncopyable types infrastructure
The infrastructure underpinning the new feature NoncopyableGenerics is
mature enough to be used.
2024-03-14 23:10:44 -07:00
Holly Borla
0a627bc44c Merge pull request #72324 from hborla/extract-function-isolation-expr
[Concurrency] Add a `.isolation` member on dynamically isolated function values.
2024-03-14 06:56:43 -07:00
Holly Borla
d9aa8697ab [Concurrency] Teach the constraint system about .isolation on dynamically
isolated function values.
2024-03-13 22:23:31 -07:00
Erik Eckstein
3c76464c1c rename withConcurrent -> withSendable
That was missed when "concurrent" was renamed to "sendable"
2024-03-13 09:58:31 +01:00
Pavel Yaskevich
279e147ae2 Merge pull request #71701 from li3zhen1/my-branch
[CSDiagnostics] Add diagnostics for holes in generic parameter packs
2024-03-06 11:58:19 -08:00
Hamish Knight
8b42107a4e [CS] Rename SyntacticElementTarget::forEachStmt -> forEachPreamble
This more closely matches what we're actually
type-checking, since we do not currently include
the body.
2024-03-04 11:56:24 +00:00
Zhen Li
e513a7a8e2 Merge branch 'apple:main' into my-branch 2024-02-27 21:56:03 -05:00
li3zhen1
00b0491676 [CSDiagnostics] Update UnableToInferGenericPackElementType to accept overloads and update test cases 2024-02-27 20:35:06 -05:00
Pavel Yaskevich
f13904bddd Merge pull request #71889 from xedin/static-members-are-always-sendable
[ConstraintSystem] Skip sendability check for static members
2024-02-27 09:37:16 -08:00
Pavel Yaskevich
7c0bb41573 [ConstraintSystem] Skip sendability check for static members
Such members only capture base metatatypes which are themselves
always sendable.
2024-02-26 11:52:38 -08:00
Ben Barham
f292ec9784 Use the new template deduction guides rather than makeArrayRef
LLVM has removed `make*ArrayRef`, migrate all references to their
constructor equivalent.
2024-02-23 20:04:51 -08:00
Pavel Yaskevich
4548b2a861 Merge pull request #71817 from xedin/rdar-122598934
[ConstraintSystem] Account for situations when witness for associated…
2024-02-23 09:20:26 -08:00
Pavel Yaskevich
239bfacee3 [ConstraintSystem] Account for situations when witness for associated type is null
In some circularity cases `getAssociatedType` would produce a `Type()`,
we need to account for that in `TypeSimplifier` to avoid crashing.
2024-02-22 10:55:33 -08:00
Li, Zhen
b44fbf60c6 [CSDiagnostics] Add diags for holes in generic parameter pack 2024-02-21 23:25:25 -05:00
Ben Barham
ef8825bfe6 Migrate llvm::Optional to std::optional
LLVM has removed llvm::Optional, move over to std::optional. Also
clang-format to fix up all the renamed #includes.
2024-02-21 11:20:06 -08:00
Holly Borla
ddf2fc44f4 [Concurrency] Allow #isolation to have a more specific contextual type. 2024-02-16 16:27:54 -08:00
Pavel Yaskevich
0db22316a2 [ConstraintSystem] Record conformances synthesized for ad-hoc distributed requirements 2024-02-12 14:26:30 -08:00
Pavel Yaskevich
95beb6cdd9 Merge pull request #71444 from xedin/remote-duplicate-entry-in-solution-total-memory
[ConstraintSystem] NFC: Remove duplicate entry from `Solution::getTot…
2024-02-08 09:30:16 -08:00
Hamish Knight
2c77947000 Merge pull request #71006 from hamishknight/implicit-last-expression
Introduce implicit last expression results
2024-02-08 10:15:01 +00:00
Pavel Yaskevich
b761e4f320 [ConstraintSystem] NFC: Remove duplicate entry from Solution::getTotalMemory 2024-02-07 12:33:07 -08:00
Hamish Knight
33cdd33f9e [CS] Account for implicit returns in closures
Avoid defaulting to Void if we have an implicit
return from which we can infer the result type.
2024-02-07 18:14:23 +00:00
Hamish Knight
1003b2f30b [CS] Remove CTP_ImpliedReturnStmt
Unify with `CTP_ReturnStmt`, and have the
SyntacticElementTarget carry the ReturnStmt for
regular type-checking, which we can use to record
implied returns.
2024-02-07 18:14:23 +00:00
John McCall
2f8a33cf0a Experimental type-checking support for @isolated(any) function types. 2024-02-06 22:54:27 -05:00
Hamish Knight
05615fa0e4 NFC: Rename TypeWalker's SkipChildren to SkipNode
For consistency with ASTWalker.
2024-02-05 15:27:25 +00:00
Hamish Knight
16cfca4186 [ASTWalker] NFC: Rename SkipChildren -> SkipNode
This better describes what the action currently
does, and allows us to re-introduce `SkipChildren`
with the correct behavior.
2024-02-05 15:27:25 +00:00
Slava Pestov
8092f18772 AST: Generalize GenericSignatureImpl::getUpperBound()
Handle inverses, and add a couple of flags (yuck!) to allow its
usage in diagnostics and code completion.
2024-02-01 23:35:33 -05:00
Hamish Knight
d9fd4c75b1 [CS] Remove isInputExpression parameter
This wasn't consistently used, and consequently
could result in some expressions getting their
parents invalidated. Instead, replace it with a
query to make sure we don't try and add an
expression we've already computed the parent info
for.
2024-01-31 20:26:20 +00:00
Hamish Knight
9b64990d24 [AST] Remove the "single expression body" bit
Remove this bit from function decls and closures.
Instead, for closures, infer it from the presence
of a single return or single expression AST node
in the body, which ought to be equivalent, and
automatically takes result builders into
consideration. We can also completely drop this
query from AbstractFunctionDecl, replacing it
instead with a bit on ReturnStmt.
2024-01-30 14:08:54 +00:00
Sima Nerush
066f253d2e Merge pull request #70196 from simanerush/nested-pack-iteration
[SE-0408] Enable nested iteration
2024-01-27 10:18:12 -08:00
Sima Nerush
0b167b55b1 [ConstraintSystem] Cache pack element generic environments associated withfor-in loops over parameter packs to apply in getPackElementEnvironment. 2024-01-27 00:12:33 -08:00
John McCall
b0fb03d8c7 Create a uniform representation for function type isolation.
Not quite NFC because apparently the representation bleeds into what's
accepted in some situations where we're supposed to be warning about
conflicts and then making an arbitrary choice.  But what we're doing
is nonsense, so we definitely need to break behavior here.

This is setting up for isolated(any) and isolated(caller).  I tried
to keep that out of the patch as much as possible, though.
2024-01-25 22:11:01 -05:00
Pavel Yaskevich
bc86b8db30 Merge pull request #71104 from xedin/rdar-121214563
[Sema] Temporary disable l-value stripping while erasing opened exist…
2024-01-24 09:46:38 -08:00
Pavel Yaskevich
3d74a397df [Sema] Temporary disable l-value stripping while erasing opened existentials
Reverts part of https://github.com/apple/swift/pull/69950 because
it causes failure in existing code.
2024-01-23 19:34:54 -08:00
Holly Borla
d60a06760b Merge pull request #71050 from hborla/global-actor-unsafe
[Concurrency] Deprecate `@GlobalActor(unsafe)` in favor of `@preconcurrency @GlobalActor`
2024-01-22 16:52:56 -08:00
Pavel Yaskevich
be39c05df2 Merge pull request #71026 from xedin/rdar-111120803
[CSSimplify] Increase impact of requirement failures in special result builder methods
2024-01-22 13:10:59 -08:00
Holly Borla
47afd21d85 [Concurrency] Remove ActorIsolation::GlobalActorUnsafe. 2024-01-21 21:05:33 -08:00
Slava Pestov
fe00f87fc0 AST: Tweak ASTContext::hadError() 2024-01-20 17:44:12 -05:00