Commit Graph

3981 Commits

Author SHA1 Message Date
Mishal Shah
c2fd49cebb Merge pull request #39473 from apple/rebranch
Update swift:main to support llvm-project:stable/20210726 changes (Rebranch merge)
2021-10-11 09:00:51 -07:00
Andrew Trick
aace0e8e2f Cleanup unused declarations from a recent commit
Warnings in the build break my workflow
2021-10-08 11:33:20 -07:00
Zoe Carver
f189992189 Merge pull request #39431 from zoecarver/lazy-pt3-print-objc-module
[cxx-interop] Print decls in the __ObjC module.
2021-10-07 17:50:59 -07:00
swift-ci
3f8fea8508 Merge remote-tracking branch 'origin/main' into rebranch 2021-10-06 10:17:29 -07:00
Meghana Gupta
f458d9b490 Fix unnecessary one-time recompile of stdlib with -enable-ossa-flag (#39516)
* Fix unnecessary one-time recompile of stdlib with -enable-ossa-flag

This includes a bit in the module format to represent if the module was
compiled with -enable-ossa-modules flag. When compiling a client module
with -enable-ossa-modules flag, all dependent modules are checked for this bit,
if not on, recompilation is triggered with -enable-ossa-modules.

* Updated tests
2021-10-04 18:46:40 -07:00
swift-ci
c51550f30e Merge remote-tracking branch 'origin/main' into rebranch 2021-09-30 15:11:41 -07:00
Zoe Carver
4317bbd58c Merge pull request #39435 from zoecarver/lazy-pt7-clang-importer-zone
[cxx-interop][nfc] Add a ClangImporter request zone.
2021-09-30 12:28:28 -04:00
zoecarver
d706863a52 [cxx-interop][nfc] Add a ClangImporter request zone.
This is just the boilerplate for adding a request zone. I haven't actually added any requrests in this commit.
2021-09-28 17:08:48 -07:00
zoecarver
3454f903bf [cxx-interop] Print decls in the __ObjC module.
This is one change from #38675.
2021-09-23 15:27:32 -07:00
Rintaro Ishizaki
afc24dfd4b [CodeCompletion] Remove two completion options from LangOptions
"add inits to toplevel" and "call pattern heuristics" are only used in
code completion. Move them from LangOptions to CodeCompletionContext so
that they don't affect compiler arguments.
2021-09-22 16:49:50 -07:00
swift-ci
102e1cebc1 Merge remote-tracking branch 'origin/main' into rebranch 2021-09-22 15:53:25 -07:00
Rintaro Ishizaki
1656eed597 Revert "[CodeCompletion] Provide known module source file information"
This effectively reverts commit f8751d466e.
2021-09-22 10:06:19 -07:00
swift-ci
a2e0896606 Merge remote-tracking branch 'origin/main' into rebranch 2021-09-07 05:53:25 -07:00
Hamish Knight
97a1653863 Merge pull request #39159 from hamishknight/conditions-apply
[Async Refactoring] Drop bool flag parameter binding
2021-09-07 13:35:22 +01:00
Hamish Knight
72070b7d41 [Async Refactoring] Bind known bool param in fallback
Generalize the logic to handle different BlockKinds,
and add binding logic that lets us assign `true` or
`false` to the given bool success param in the
fallback case.
2021-09-06 21:25:09 +01:00
Hamish Knight
00977afc7b [Async Refactoring] Placeholder dropped params in fallback case
Make sure to convert any references to parameters
that get dropped in the fallback case to
placeholders.
2021-09-06 21:25:09 +01:00
Hamish Knight
1e34f31545 [Async Refactoring] Drop bool flag parameter binding
If we have a known bool flag parameter, drop it
from the success parameters being bound in a
refactored await call, as the async variant drops
it.

rdar://81896460
2021-09-06 21:25:08 +01:00
Hamish Knight
fa3efeefcb [Async Refactoring] Add ClosureCallbackParams
Refactor some closure parameter handling logic
into a new ClosureCallbackParams type, which lets
us clean up some of the parameters passed to
CallbackClassifier, and better distinguish between
an error param and a Result param.
2021-09-06 21:25:07 +01:00
swift-ci
cf746f047f Merge remote-tracking branch 'origin/main' into rebranch 2021-09-06 13:13:07 -07:00
Hamish Knight
9b493970aa [Aync Refactoring] Better handle comment trailing whitespace
Use `getCommentRange` to trim off the comment's
trailing whitespace, avoiding outputting
extraneous empty lines.

rdar://82072147
2021-09-06 17:51:39 +01:00
swift-ci
cb32b553de Merge remote-tracking branch 'origin/main' into rebranch 2021-09-04 11:32:57 -07:00
Hamish Knight
dc60996f89 Merge pull request #38836 from hamishknight/toil-and-tuple 2021-09-04 19:30:04 +01:00
swift-ci
0c7778f1bc Merge remote-tracking branch 'origin/main' into rebranch 2021-09-02 15:54:46 -07:00
Rintaro Ishizaki
bd5b3012f4 Merge pull request #38453 from rintaro/ide-completion-overrideannotation-rdarrdar62617558
[CodeCompletion] Annotate override completions
2021-09-02 15:50:26 -07:00
Rintaro Ishizaki
7e7b2c3557 [CodeCompletion] Annotate override completions
* "description" for override completion is now annotatable
* "description" doesn't include attributes and decl introducer, but it
  includes generic paramters, effects specifiers, result type clause,
  and generic where clauses
* "name" now only include the name and the parameter names
* "sourcetext" should be the same

rdar://63835352
2021-09-02 12:12:26 -07:00
Hamish Knight
3e28bbbd2c Update for review feedback
- Remove OriginalArguments in favor of storing the
pre-rewritten argument list, which simplifies things
nicely
- Adopt llvm::indexed_accessor_iterator
2021-09-01 18:40:29 +01:00
Hamish Knight
488e91a0ae [SyntaxModel] Clear ArgumentInfo when outside of an argument list
Track the depth and clear out the map when it
reaches 0 to save memory.
2021-09-01 18:40:28 +01:00
Hamish Knight
78d8d09b99 [IDE] Adopt ArgumentList 2021-09-01 18:40:26 +01:00
swift-ci
ebad328a4f Merge remote-tracking branch 'origin/main' into rebranch 2021-09-01 09:14:57 -07:00
Alex Hoppen
12ff361ec3 [CodeCompletion] Explicitly support enum pattern matching
Pattern matching in Swift can either be expression pattern matching by comparing two instances using the `~=` operator or using enum matching by matching the enum case and its associated types (+ tuple pattern matching, but that’s not relevant here). We currenlty only consider the expression pattern matching case for code completion. To provide enum pattern matching results, we thus need to have a `~=` operator between the code completion token and the match expression

For example, when we are completing

```swift
enum MyEnum {
  case myCase(String)
}

switch x {
case .#^COMPLETE^#
}
```
then we are looking up all overloads of `~=` and try to match it to the call arguments `(<Code Completion Type>, MyEnum)`.
The way we currently get `#^COMPLETE^#` to offer members of `MyEnum`, is that we are trying to make sure that the `~=<T: Equatable>(T, T)` operator defined in the standard library is the best solution even though it has fixes associated with it. For that we need to carefully make sure to ignore other, more favourable overloads of `~=` in `filterSolutions` so that `~=<T: Equatable>(T, T)` has the best score.

This poses several problems:
- If the user defines a custom overload of `~=` that we don't prune when filtering solutions (e.g. `func ~=(pattern: OtherType, value: MyEnum) -> Bool`), it gets a better score than `~=<T: Equatable>(T, T)` and thus we only offer members of `OtherType` instead of members from `MyEnum`
- We are also suggesting static members of `MyEnum`, even though we can't pattern match them due to the lack of the `~=` operator.

If we detect that the completion expression is in a pattern matching position, also suggests all enum members of the matched type. This allows us to remove the hack which deliberately ignores certain overloads of `~=` since we no longer rely on `~=<T: Equatable>(T, T)`. It thus provides correct results in both of the above cases.

Fixes rdar://77263334 [SR-14547]
2021-09-01 13:58:56 +02:00
swift-ci
86a715d70e Merge remote-tracking branch 'origin/main' into rebranch 2021-08-30 17:15:00 -07:00
Ben Barham
a375ffebcf Merge pull request #39084 from apple/remove-keywords
[Completion] Remove unused DocWords
2021-08-31 10:10:22 +10:00
swift-ci
5fe1881a91 Merge remote-tracking branch 'origin/main' into rebranch 2021-08-27 21:53:32 -07:00
Ben Barham
8ae8f1d204 [Completion] Remove unused DocWords
The various keyword/recommended/etc fields were parsed and added to
completions, but never actually plumbed through SourceKit. Since they're
still unused and the implementation is not particularly lightweight,
just remove for now.

Resolves rdar://82464220
2021-08-28 14:05:01 +10:00
Rintaro Ishizaki
49547a5378 [NFC][Basic] Import llvm::isa_and_nonnull to 'swift' namespace
Just for convenicence.

* Replace `llvm::isa_and_nonnull` with imported `isa_and_nonnull`
* Repalce some `EXPR && isa<T>(EXPR)` with `isa_and_nonnull<T>(EXPR)`
2021-08-27 11:36:21 -07:00
swift-ci
685c5f7ddf Merge remote-tracking branch 'origin/main' into rebranch 2021-08-23 18:33:31 -07:00
Ben Barham
9b8d9e22ef Merge pull request #38981 from apple/skip-underscore
[Refactoring] Do not try to unique '_'
2021-08-24 11:33:15 +10:00
swift-ci
79ca271751 Merge remote-tracking branch 'origin/main' into rebranch 2021-08-20 14:53:15 -07:00
Ben Barham
3b99e9079b Merge pull request #38920 from apple/show-cursor-refactorings
[Refactorings] Add cursor refactorings for the start of the range
2021-08-21 07:35:51 +10:00
swift-ci
3704130dff Merge remote-tracking branch 'origin/main' into rebranch 2021-08-20 14:33:14 -07:00
Ben Barham
6a79964ad4 [Refactoring] Do not try to unique '_'
The async refactorings should not try to unique '_' when it's used as
the parameter name. Also skip adding a let binding to the `catch` if the
error parameter is '_'.

Resolves rdar://82158389
2021-08-21 07:30:53 +10:00
Ben Barham
86c47e45f0 [Refactoring] Do not add "async" if function is already async
Convert Function to Async is available on an async function. It could be
useful to run this refactoring still, as it would attempt to convert any
completion-handler functions to their async alternatives. Keep allowing
this, but make sure not to re-add "async" to the function declaration.

Resolves rdar://82156720
2021-08-20 15:24:17 +10:00
Ben Barham
c7620fa979 [Refactorings] Add cursor refactorings for the start of the range
When a range is a single expression/statement/decl or part of
expression, also return cursor based refactorings for the start of the
range.

This is a stop gap until the available refactorings are properly fixed
to be more lenient in general - the current fix is a little odd as eg.
if all of `foo.bar()` is selected, rename will be returned as an
available refactoring for `foo`. Still an improvement over completely
missing cursor based refactorings, however.

Resolves rdar://82060063
2021-08-18 14:04:10 +10:00
swift-ci
4211b1bf1a Merge remote-tracking branch 'origin/main' into rebranch 2021-08-16 17:13:42 -07:00
Doug Gregor
d54abea922 Implement customizable Sendable conformance diagnostics.
Rework Sendable checking to be completely based on "missing"
conformances, so that we can individually diagnose missing Sendable
conformances based on both the module in which the conformance check
happened as well as where the type was declared. The basic rules here
are to only diagnose if either the module where the non-Sendable type
was declared or the module where it was checked was compiled with a
mode that consistently diagnoses `Sendable`, either by virtue of
being Swift 6 or because `-warn-concurrency` was provided on the
command line. And have that diagnostic be an error in Swift 6 or
warning in Swift 5.x.

There is much tuning to be done here.
2021-08-14 08:13:10 -07:00
swift-ci
e5ab372616 Merge remote-tracking branch 'origin/main' into rebranch 2021-08-13 16:55:57 -07:00
Ben Langmuir
c7c899ead8 Fix URL detection for "sip" and "service" schemes
We were concatenating these strings due to the missing comma. Found by
clang-tidy.
2021-08-13 12:20:11 -07:00
swift-ci
2dc6847b86 Merge remote-tracking branch 'origin/main' into rebranch 2021-08-12 15:33:38 -07:00
Ben Barham
061a8f402a Merge pull request #38855 from apple/async-refactoring-void-result
[Refactoring] Fix invalid legacy body for Result<Void, ...> handler
2021-08-13 08:33:31 +10:00
Ben Barham
5bd2d0b932 [Refactoring] Fix invalid legacy body for Result<Void, ...> handler
When adding an async alternative for a function with a
`(Result<Void, ...>) -> Void` completion handler, the legacy body was
adding a call to the handler with `.success(result)`. We don't assign to
`result` for `Void` handlers, so pass `()` instead.

Resolves rdar://81829392
2021-08-12 21:04:18 +10:00