Commit Graph

352 Commits

Author SHA1 Message Date
Pavel Yaskevich
cfea0d3d22 [TypeChecker] NFC: Add XFAIL'ed test-case for https://github.com/apple/swift/issues/67363 2023-08-14 10:06:52 -07:00
Pavel Yaskevich
64a654dc0d Revert "[CSBindings] Prefer conjunctions over closure variables without bindings"
This reverts commit 11ee82de7b.
2023-08-14 10:02:05 -07:00
Pavel Yaskevich
11ee82de7b [CSBindings] Prefer conjunctions over closure variables without bindings
If a closure doesn't have a contextual type inferred yet it should
be delayed in favor of already resolved closure conjunction because
"resolving" such a closure early could miss result builder attribute
attached to a parameter the closure is passed to.

Partially resolves https://github.com/apple/swift/issues/67363
2023-07-21 09:46:09 -07:00
Slava Pestov
1957bd6065 Sema: Reword diagnostics to say 'without a type annotation' instead of 'without more context' 2023-06-09 17:44:42 -04:00
Pavel Yaskevich
20d7642ca4 [CSGen] Allow expression pattern types to be holes 2023-04-24 10:02:00 -07:00
Cal Stephens
ee906f7ba5 Merge branch 'main' into cal--SE-3065-bad-pattern-check 2023-04-20 13:41:48 -07:00
Pavel Yaskevich
ff62be17a4 Merge pull request #65211 from calda/cal--weak-self-capture-inner-func
[SE-0365] Allow implicit self in inner functions in [weak self] closures, like with [self] closures
2023-04-19 22:48:24 -07:00
Cal Stephens
3e140286e8 Fix issue where non-pattern-binding condition would break SE-0365 unwrapped self check 2023-04-19 19:17:35 -07:00
Cal Stephens
6670639e9b Clean up implementation, add more extensive tests 2023-04-19 08:32:43 -07:00
Cal Stephens
9e55fb0ba0 Allow implicit self in inner functions in [weak self] closures, like with [self] closures 2023-04-15 09:27:20 -06:00
Cal Stephens
548456d62f Add test case for #64757 2023-04-03 18:21:02 -07:00
Anthony Latsis
14b70f306b DiagnosticVerifier: Default expected fix-it start line to the diagnostic's 2023-03-08 12:10:27 +03:00
Michael Gottesman
0ad5a18d40 Update test output. 2023-03-03 18:19:26 -08:00
Michael Gottesman
c97121d3ee [reference-binding] Add support for inout binding parsing/serialization. 2023-03-01 20:48:54 -08:00
Hamish Knight
043b192dcd [Sema] Diagnose duplicate pattern vars in pattern resolution
Unify the duplicate pattern var checking in
pattern resolution such that it is always called
no matter how we end up type-checking the pattern.
This avoids incorrectly allowing duplicate pattern
vars to compile for patterns as a part of
multi-statement closures.
2023-03-01 16:20:14 +00:00
Pavel Yaskevich
8e82f1d68b [CSGen] Detect nested out-of-scope variables in recursive declarations
Follow-up to https://github.com/apple/swift/pull/63505

Since, when the type is not stated, a variable assumes the
type of its initializer that enables out-of-scope variables
to be nested inside of some other concrete type i.e. Optional.

Resolves: https://github.com/apple/swift/issues/63455
2023-02-11 19:19:09 -08:00
Pavel Yaskevich
bffb8d9ee2 Revert "[CSGen] Handle recursive use of variable declarations" 2023-02-10 16:45:59 -08:00
Pavel Yaskevich
83dd93ad2e [CSGen] Handle recursive use of variable declarations
It's possible for out-of-scope type variable to be the type of
declaration if such declaration is recursively referenced in
the body of a closure located in its initializer expression.
In such cases type of the variable declaration cannot be connected
to the closure because its not known in advance (determined by the
initializer itself).

Resolves: https://github.com/apple/swift/issues/63455
2023-02-07 17:48:26 -08:00
Pavel Yaskevich
65e7eec62f [CSSolver] Solve multi-statement closures in source order
Currently solver picks the first conjunction it can find,
which means - the earliest resolved closure. This is not
always correct because when calls are chained closures
passed to the lower members could be resolved sooner
than the ones higher up but at the same time they depend
on types inferred from members higher in the chain.

Let's make sure that multi-statement closures are always
solved in order they appear in the AST to make sure that
types are available to members lower in the chain.
2022-12-12 10:57:21 -08:00
Allan Shortlidge
74e55ef51f Test: Temporarily disable implicit_weak_capture.swift for back_deployment_runtime configs. 2022-11-10 18:21:21 -08:00
Andrew Trick
1ecf0a5586 implicit_weak_capture test requires Concurrency
Fixes rdar://101942652 (macOS 10.14.4) (Swift in the OS)
libswift_Concurrency; Symbol not found:
_swift_task_enterThreadLocalContext)
2022-11-03 19:35:47 -07:00
Cal Stephens
c081d56cf1 Add test case that implicit self in a weak closure doesn't result in a strong capture 2022-10-27 17:50:44 -07:00
Cal Stephens
8528021f0d Change lookup behavior in ASTScope::lookupUnqualified when self has been unwrapped 2022-10-26 20:38:43 -07:00
Cal Stephens
ebcc9c2b8b Revert "Disable SE-0365 behavior for escaping closues in Swift 5 mode"
This reverts commit f8ca2937a8.
2022-10-26 17:38:01 -07:00
Cal Stephens
f8ca2937a8 Disable SE-0365 behavior for escaping closues in Swift 5 mode 2022-10-22 09:15:09 -07:00
Cal Stephens
22e43136d9 Enable SE-0365 behavior in Swift 5.8 2022-10-10 08:03:03 -07:00
Pavel Yaskevich
1a79d93121 Merge pull request #40702 from calda/cal--implicit-weak-self
[SE-0365] Allow implicit self for `weak self` captures
2022-09-30 10:30:57 -07:00
Cal Stephens
5bfdfd822c Only enable SE-0365 in Swift 6 2022-09-28 19:35:26 -07:00
Cal Stephens
cc92f76a9e Revert changes for handling SE-0365 in Swift 5
Revert "Remove properties from AST nodes"

This reverts commit e4b8a829fe.

Revert "Suppress more false-positive 'self is unused' warnings"

This reverts commit 35e028e5c2.

Revert "fix warning annotation in test"

This reverts commit dfa1fda3d3.

Revert "Permit implicit self for weak self captures in nonescaping closures in Swift 5 (this is an error in Swift 6)"

This reverts commit 94ef6c4ab4.
2022-09-28 17:44:02 -07:00
Cal Stephens
35e028e5c2 Suppress more false-positive 'self is unused' warnings 2022-09-26 09:28:22 -07:00
Cal Stephens
dfa1fda3d3 fix warning annotation in test 2022-09-25 16:19:57 -07:00
Cal Stephens
94ef6c4ab4 Permit implicit self for weak self captures in nonescaping closures in Swift 5 (this is an error in Swift 6) 2022-09-25 14:32:19 -07:00
Cal Stephens
9dd56f9daf Move remaining logic in LookupResultEntry::getBaseDecl() to ASTScope::lookupUnqualified impl, add more extensive tests, fix failing tests 2022-09-22 11:04:08 -07:00
Pavel Yaskevich
61d3a9f786 [CSClosure] Always pre-check init targets of wrapped vars
If a variable with attached property wrapper has an initializer
expression it could be modified by implicit wrapper application,
if there is no initializer - one would be synthesized by the
compiler (without arguments). In both cases target has to be
pre-checked before constraints are generated for it.

Resolves: https://github.com/apple/swift/issues/61024
2022-09-12 16:08:36 -07:00
Pavel Yaskevich
3e791dd169 [CSClosure] Use correct type for implicit wrapper variables
Using `computeWrappedValueType` is incorrect because
that return a type of the wrapped variable and not
the *wrapper* variable (one that starts with `_`).

Resolves: https://github.com/apple/swift/issues/61017
2022-09-12 09:53:24 -07:00
Cal Stephens
9167a177cc Merge branch 'main' into cal--implicit-weak-self 2022-09-11 10:24:55 -07:00
Luciano Almeida
9e42002132 Merge pull request #60952 from LucianoPAlmeida/diag-closure 2022-09-06 13:15:57 -03:00
Luciano Almeida
7b82be5e2b [test] Opaque result is only available in 10.10 macos 2022-09-06 09:12:36 -03:00
Luciano Almeida
9c9af903bb [test] Add opaque result type cases 2022-09-05 10:29:16 -03:00
Luciano Almeida
7300fb5836 [Sema] Improve diagnostic for closure return contextual mismatch 2022-09-04 22:28:49 -03:00
Anthony Latsis
867472491f Merge pull request #60812 from AnthonyLatsis/migrate-test-suite-to-gh-issues-12
Gardening: Migrate test suite to GH issues p. 12
2022-09-02 06:06:53 +03:00
Luciano Almeida
109737551e [Sema] Handle non-function type parameters for closure arguments in ambiguity diagnositc 2022-08-27 20:42:19 -03:00
Anthony Latsis
6c615c8ead Gardening: Migrate test suite to GH issues: expr/closure 2022-08-27 05:26:00 +03:00
Pavel Yaskevich
3ebc541fd5 [CSDiagnostics] Verify that member is in collection context
`MissingMemberFailure::diagnoseInLiteralCollectionContext`
should verify that a parent (or parent of a parent) expression
is indeed a collection expression instead of checking types.

Resolves: rdar://91452726
2022-08-17 12:12:27 -07:00
Alex Hoppen
e14fa7291f [CS] Don’t fail constraint generation for ErrorExpr or if type fails to resolve
Instead of failing constraint generation by returning `nullptr` for an `ErrorExpr` or returning a null type when a type fails to be resolved, return a fresh type variable. This allows the constraint solver to continue further and produce more meaningful diagnostics.

Most importantly, it allows us to produce a solution where previously constraint generation for a syntactic element had failed, which is required to type check multi-statement closures in result builders inside the constraint system.
2022-07-20 09:46:12 +02:00
Cal Stephens
778a2fc1f5 Merge branch 'main' into cal--implicit-weak-self 2022-07-18 10:00:23 -07:00
Luciano Almeida
11877d7a1b [Sema][Revert] Revert CTP to CTP_ReturnStmt for closure result in return stmt 2022-07-15 09:31:11 -03:00
Luciano Almeida
44f4eba6c5 [Sema] Add return context valid source loc to implicit tuple expr context for diagnostic 2022-07-11 20:57:54 -03:00
Anthony Latsis
4d3aa95d59 Add regression test to close #42790 2022-06-22 22:17:30 +03:00
Pavel Yaskevich
9c8bebe4f8 [CSClosure] Detect and diagnose conflicting pattern variables in case statements
Avoid mutating case label items while solving, instead let's use types
recorded in the constraint system for each pattern variable and use
that for var reference in the case body. This also helps to detect
and diagnose type conflicts while solving.
2022-06-03 16:35:18 -07:00