Commit Graph

1487 Commits

Author SHA1 Message Date
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
Cal Stephens
4abca2bc9e Merge tag 'swift-DEVELOPMENT-SNAPSHOT-2022-09-12-a' of github.com:apple/swift into cal--implicit-weak-self
Tag build swift-DEVELOPMENT-SNAPSHOT-2022-09-12-a
2022-09-20 06:58:38 -07:00
Pavel Yaskevich
5ffe84765f Merge pull request #61052 from xedin/closure-property-wrapper-fixes
[CSClosure] Fix property wrapper handling
2022-09-13 09:23:15 -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
Pavel Yaskevich
149e57a0cb Merge pull request #60893 from calda/cal--warn-redundant-comparison-to-optional.none-case
Add warning when comparing a non-optional value to `Optional.none`
2022-09-12 00:36: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
Anthony Latsis
5b245b42cd Merge pull request #60836 from AnthonyLatsis/migrate-test-suite-to-gh-issues-13
Gardening: Migrate test suite to GH issues p. 13
2022-09-02 06:06:14 +03:00
Cal Stephens
c3e74e06b4 Use a single warning, but dynamically specify 'nil' or 'Optional.none' 2022-09-01 09:10:01 -07:00
Cal Stephens
c2bf0f943e Revert "Combine the two diagnostics"
This reverts commit 2e7656218e.
2022-09-01 08:11:46 -07:00
Cal Stephens
1b224bd945 Add a test that verifyies comparing to a .none case that isn't Optional.none still works 2022-09-01 06:38:50 -07:00
Cal Stephens
2e7656218e Combine the two diagnostics 2022-09-01 06:23:42 -07:00
Cal Stephens
88b65f406f Update tests 2022-08-31 20:14:41 -07:00
Anthony Latsis
d911aad234 Gardening: Migrate test suite to GH issues: expr/unary 2022-08-30 00:31:18 +03:00
Anthony Latsis
65663b0b5d Gardening: Migrate test suite to GH issues: expr/primary 2022-08-30 00:31:18 +03:00
Anthony Latsis
2a220d5d1b Gardening: Migrate test suite to GH issues: expr/postfix 2022-08-30 00:31:18 +03:00
Anthony Latsis
8cd1df47ce Gardening: Migrate test suite to GH issues: expr/delayed-ident 2022-08-30 00:31:18 +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
Anthony Latsis
5324bf9773 Gardening: Migrate test suite to GH issues: expr/cast 2022-08-27 03:15:21 +03:00
Anthony Latsis
45f5f08fa0 Gardening: Migrate test suite to GH issues: expr 2022-08-26 22:20:52 +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
Sima Nerush
f608802cfe Sema: Emit diagnostics when walking into collection literals with defaulted types
Resolves https://github.com/apple/swift/issues/60011

Gardening: clean up `checkTypeDefaultedCollectionExpr` function
2022-08-15 22:45:21 -06: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
15acfa9a5b Merge pull request #59535 from AnthonyLatsis/close-issues-1
Add regression tests to close some issues
2022-06-23 20:43:51 +03:00
Anthony Latsis
4d3aa95d59 Add regression test to close #42790 2022-06-22 22:17:30 +03:00
Pavel Yaskevich
566e00c057 Merge pull request #59305 from xedin/rdar-94360230
[ConstraintSystem] Use '# of overloads' as a tie-breaker in ambiguities
2022-06-17 12:20:07 -07:00
Pavel Yaskevich
7ba07ae3ba Merge pull request #59210 from xedin/conflicting-patterns-in-case
[Diagnostics] Diagnose conflicting pattern variables
2022-06-14 11:30:34 -07:00
Pavel Yaskevich
8f69b9f2e0 [ConstraintSystem] Use '# of overloads' as a tie-breaker in ambiguities
The deepest expression is the one that introduced the ambiguity into
the chain, so depth and index should be deciding factors and number of
overloads - a tie-breaker, while choosing what to diagnose.

Resolves: rdar://94360230
2022-06-07 15:53:13 -07:00
Serena
e05f68c822 Change diagnostic error thrown for when string interpolations aren't closed by a parenthesis (#58882)
[Parse] Diagnose unclosed string interpolations
2022-06-04 19:32:41 +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
Pavel Yaskevich
1099cca050 Merge pull request #59238 from xedin/rdar-92757114-test
[CSClosure] NFC: Add a test-case for rdar://92757114
2022-06-03 16:28:04 -07:00
Pavel Yaskevich
c581497bd4 [CSClosure] NFC: Add a test-case for rdar://92757114
Used to produce a fallback `type of expression ...` diagnostic
2022-06-03 12:21:06 -07:00
Pavel Yaskevich
df1e38ff36 [TypeChecker] NFC: Add test-case for rdar://93061432 2022-05-30 23:17:41 -07:00