Commit Graph

3985 Commits

Author SHA1 Message Date
swift-ci
bab4706e94 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-07-30 14:03:22 -07:00
Rintaro Ishizaki
facabd8010 Merge pull request #33200 from rintaro/ide-completion-rdar66301353
[CodeCompletion] Fix issue in dependency checking for the editing file
2020-07-30 14:02:03 -07:00
Rintaro Ishizaki
2f4dcf3e2f [CodeCompletion] Fix issue in dependency checking for the editing file
'SM.getCodeCompletionBufferID()' returns the buffer ID of the previous
code completion. 'CI.getCodeCompletionFile()->getBufferID()' always
returns the original source buffer ID of the current file in the main
module. The latter is needed for excluding buffer ID for dependency checking.

rdar://problem/66301353
2020-07-30 09:27:58 -07:00
swift-ci
8724a0117b Merge remote-tracking branch 'origin/master' into master-rebranch 2020-07-29 08:10:41 -07:00
Slava Pestov
6364a99123 Merge pull request #33176 from slavapestov/apply-generic-arguments-cleanup
Clean up declaration checker's modeling of generic arguments and parameter lists
2020-07-29 11:03:14 -04:00
swift-ci
adb31a9532 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-07-28 19:23:53 -07:00
Slava Pestov
c46eb22fcd AST: Don't attach trailing where clause requirements to the GenericParamList
Previously we had two representations for the 'where' clause of a
parsed declaration; if the declaration had generic parameters of
its own, we would store them in the GenericParamList, otherwise
we would store them separately in a TrailingWhereClause instance.

Since the latter is more general and also used for protocols and
extensions, let's just use it for everything and simplify
GenericParamList in the process.
2020-07-28 02:07:16 -04:00
Slava Pestov
14dd4eef2d AST: Add a way to distinguish a parsed generic parameter list from a synthesized one
Add a new GenericContext::getParsedGenericParams(). This produces
the same value as GenericContext::getGenericParams() if the generic
parameter list was written in source. For extensions and protocols,
this returns nullptr without synthesizing anything.
2020-07-28 02:07:16 -04:00
Nathan Hawes
b0a2230860 Manually merge remote-tracking branch 'upstream/master' into merge-in-master 2020-07-27 09:25:01 -07:00
Rintaro Ishizaki
01c4df8e98 [CodeCompletion] Propagate "skipping body" flag per request basis
Instead of using a global type checker flag.
2020-07-24 10:48:51 -07:00
Rintaro Ishizaki
12762a2a30 [CodeCompletion] Only type check related statements in function body
Introduce 'TypeCheckSingleASTNode' mode that only type checks single body
element and dependent necessities (i.e. referencing ValueDecls and their
dependencies).

Renamed swift::typeCheckAbstractFunctionBodyAtLoc() to
swift::typeCheckASTNodeAtLoc(DeclContext *, SourceLoc). That type checks
innermost 'ASTNode' at the location. Also, 'TypeCheckSingleASTNode' mode
skips type checking any "body" of the node (i.e. BraceStmt elements for
function body, if statement body, closure body, etc.)

Added on-demand type checking using it:
 - VarDecl in TapExpr
 - ParamDecl in ClosureExpr
 - Return type of ClosureExpr
 - Binding value in control statements
   (e.g. ForEachStmt, SwitchStmt, DoCatchStmt, etc.)

rdar://problem/63932852
2020-07-24 10:48:51 -07:00
Rintaro Ishizaki
dab216dc49 [CodeCompletion] Use TypeContextInfo to get expected return types
If the type check return type from the context has unresolved types, it
can't be used for checking convertibility. Fallback to get
'TypeContextInfo' of the closure position.

rdar://problem/66002497
2020-07-23 14:34:54 -07:00
swift-ci
c22b1f580b Merge remote-tracking branch 'origin/master' into master-rebranch 2020-07-21 16:24:01 -07:00
Nathan Hawes
f7820f5a35 Merge pull request #33031 from nathawes/dont-synthesize-extension-members-in-subclasses
[SourceKit/DocSupport] Don't synthesize extensions for inherited protocol conformances.
2020-07-21 16:09:41 -07:00
Nathan Hawes
e68ab1da8e [SourceKit/DocSupport] Don't synthesize extensions for inherited protocol conformances.
The Base class already includes them, so don't duplicate them in its
subclasses. Also stops us including members from extensions of the base class
itself.

Resolves rdar://problem/50960433
2020-07-21 11:53:06 -07:00
Nathan Hawes
9d4ed5f39c Manually merge remote-tracking branch 'upstream/master' into manually-merge-master-to-master-rebranch 2020-07-20 16:09:55 -07:00
Suyash Srijan
58a84ea4c1 [NFC] Cleanup some code to use 'swift::getParameterList(ValueDecl)' to fetch parameter lists (#32979) 2020-07-20 19:50:37 +01:00
Brent Royal-Gordon
4394e92c3f Merge pull request #32700 from brentdax/magical-and-evolutionary
Revise #file changes from SE-0274
2020-07-17 01:57:23 -07:00
Rintaro Ishizaki
f7fc1ed7b5 [CodeCompletion] Fix a crash in CCExprRemover
- Handle cases where getArgumentLabelLocs().size() == 0
- Add some assertions to verify invariants
- Explicit handling of 'llvm::Optional' for 'getUnlabeledTrailingClosureIndex()'
- Avoid walking into nodes after the removing happens

rdar://problem/65556791
2020-07-15 09:56:20 -07:00
Brent Royal-Gordon
9a838bb654 Differentiate between Swift 5 and “Swift 6” #file
In -swift-version 5 and earlier, #file will continue to be a synonym for #filePath; in a future -swift-version (“Swift 6 mode”), it will become a synonym for #fileID. #file in libraries will be interpreted according to the language mode the library was compiled in, not the language mode its client uses.

Implement this behavior, tied to a frontend flag instead of a language version. We do so by splitting the old `MagicIdentifierLiteralExprKind::File` into two separate cases, `FileIDSpelledAsFile` and `FilePathSpelledAsFile`, and propagating this distinction throughout the AST. This seems cleaner than looking up the setting for the module the declaration belongs to every time we see `File`.

This doesn’t handle module interfaces yet; we’ll take care of those in a separate commit.
2020-07-13 14:06:55 -07:00
Brent Royal-Gordon
acc01aea03 [NFC] Add MagicIdentifierKinds.def
Extracts the list of magic identifier literal kinds into a separate file and updates a lot of code to use macro metaprogramming instead of naming half a dozen cases manually. This is a complicated change, but it should be NFC.
2020-07-13 14:05:13 -07:00
Brent Royal-Gordon
672bd40866 Enable #filePath code completion (and fix a bug)
The meaning of EnableConcisePoundFile is going to shift slightly, so it makes sense to always include #filePath in completions. Also, @rintaro confirmed that this should be using KeywordKind::pound_filePath, not KeywordKind::pound_file.
2020-07-13 14:05:13 -07:00
Rintaro Ishizaki
5cd5a18ffe Merge pull request #32806 from rintaro/ide-completion-rdar61765124
[CodeCompletion] Safer getEquivalentDeclContextFromSourceFile()
2020-07-10 10:43:47 -07:00
Rintaro Ishizaki
185317f722 Merge pull request #32779 from rintaro/ide-completion-closureplaceholder-rdar63607976
[PlaceholderExpansion] Omit return type in closure signature
2020-07-09 21:20:25 -07:00
Rintaro Ishizaki
09f461bdbd [CodeCompletion] Safer getEquivalentDeclContextFromSourceFile()
There seems to be case where parentDC->getAsDecl() returns nullptr.
I haven't been able to find a reproducer.

rdar://problem/61765124
2020-07-09 19:18:35 -07:00
Nathan Hawes
962e0bbd56 Merge pull request #32606 from nathawes/prefer-macOS-to-OSX-spelling-when-printing-platform
[AST] Prefer the 'macOS' spelling over 'OSX' when printing the platform kind.
2020-07-09 17:11:27 -07:00
Rintaro Ishizaki
17be66c3d6 [PlaceholderExpansion] Omit return type in closure signature
Return type in the closure signature is often redundant when expanding
placeholders, because the type of the clossures are usually inferred
from the context (i.e. calling function), users don't need to write the
return type explicitly.

They are not only redundant, but also sometimes harmful when the return
type is a generic parameter or its requirement. Actually, there is no
correct spelling in such cases.

So omit the return type and the parentheses around the parameter clause.

rdar://problem/63607976
2020-07-09 14:37:17 -07:00
Nathan Hawes
244dc4a768 [AST] Rename PlatformKind::OSX to PlatformKind::macOS
Because the names are coming from a .def file used for printing too, this
simplifies the printing logic as well.
2020-07-08 16:29:31 -07:00
Rintaro Ishizaki
a778f517d1 [CodeCompletion] Remove redundant entries from possible callee analysis
This used to cause duplicated results in call signature completions.
i.e.:

  AlertViewController(#^HERE^# // 2 x (coder: NSCoder)

rdar://problem/65081358
2020-07-08 14:30:32 -07:00
Nathan Hawes
9bcb54910e [AST] Prefer the 'macOS' spelling over 'OSX' when printing the platform kind.
This affects module interfaces, interface generation in sourcekitd, and
diagnostics. Also fixes a fixit that was assuming the 'OSX' spelling when
computing the source range to replace.

Resolves rdar://problem/64667960
2020-07-08 13:51:25 -07:00
swift_jenkins
465eae8559 Merge remote-tracking branch 'origin/master' into master-next 2020-06-30 08:58:09 -07:00
Hamish Knight
5c27465a86 Merge pull request #32601 from hamishknight/not-yet-over-and-out 2020-06-30 08:49:53 -07:00
Hamish Knight
7bc5440d17 [Frontend] Internalize createDependencyTracker
Expand the FrontendOptions to allow the enabling
of the dependency tracker for non-system
dependencies, and switch the previous clients of
`createDependencyTracker` over to using this
option. This ensures that the dependency tracker
is now set only during `CompilerInstance::setup`.
2020-06-29 15:26:26 -07:00
swift_jenkins
3c4e9533a0 Merge remote-tracking branch 'origin/master' into master-next 2020-06-29 15:19:28 -07:00
Nathan Hawes
f24571797c [SourceKit/CodeFormat] Fix multi-line array literal elements not indenting relative to their first line.
doStuffWithList([
    firstItem
    .map { $0 }       // This line should be indented further.
    .append(\.foo),   // And so should this one.
    secondItem
])

Resolves rdar://problem/64834040
2020-06-26 21:18:19 -07:00
swift_jenkins
f7b349f97e Merge remote-tracking branch 'origin/master' into master-next 2020-06-24 13:59:28 -07:00
Nathan Hawes
603ca955ad Merge pull request #32513 from nathawes/fix-indentation-after-incomplete-func-decl
[SourceKit/Indentation] Fix over-indent after function decl with no param list or body.
2020-06-24 13:47:57 -07:00
swift_jenkins
f503f422cc Merge remote-tracking branch 'origin/master' into master-next 2020-06-24 09:39:10 -07:00
Rintaro Ishizaki
f50b66689e [CodeCompletion] Fallback to nominal member completion after trailing closure
After trailing closure, we perform "Labeled trailing closure" completion
and fall back to other completion depending on the position.

If the completion happens at a newline position, it used to fallback to
global expression completion, but in type context, we should do override
completion instead.

Also, we didn't use to propagate 'hasCodeCompletion()' status properly.

rdar://problem/64650782
2020-06-24 01:04:33 -07:00
Nathan Hawes
436d47518a [SourceKit/Indentation] Fix over-indent after function declaration with no param list or body. 2020-06-23 13:22:08 -07:00
swift_jenkins
75bea14185 Merge remote-tracking branch 'origin/master' into master-next 2020-06-23 10:39:14 -07:00
Robert Widmann
0da060e95e Merge pull request #32447 from martinboehme/option-set-initializer-list
Give OptionSet an initializer_list constructor
2020-06-23 10:36:57 -07:00
Martin Boehme
d806ba53f6 Give OptionSet an initializer_list constructor.
This makes it easier to specify OptionSet arguments.

Also modify appropriate uses of ModuleDecl::ImportFilter to take
advantage of the new constructor.
2020-06-22 06:57:29 +02:00
swift_jenkins
518bbb3d40 Merge remote-tracking branch 'origin/master' into master-next 2020-06-17 16:39:22 -07:00
Rintaro Ishizaki
6a8d2920b8 Merge pull request #32440 from rintaro/ide-completion-platform-rdar64379019
[CodeCompletion] Suggest 'macOS' instead of 'OSX'
2020-06-17 16:27:30 -07:00
Rintaro Ishizaki
d4da603960 [CodeCompeltion] Suggest 'macOS' instead of 'OSX'
'macOS' is the preferred name for specifying the platform. Since 'OSX'
is deprecated, we don't need to suggest 'OSX' variants.

rdar://problem/64379019
2020-06-17 14:09:25 -07:00
swift_jenkins
cecdf896a7 Merge remote-tracking branch 'origin/master' into master-next 2020-06-17 13:38:42 -07:00
Suyash Srijan
b1b60fbbda [Refactoring] Create 'AddEquatableContext' with extension only when there is an extended nominal declaration (#32435) 2020-06-17 21:33:22 +01:00
swift_jenkins
9cb4f90b57 Merge remote-tracking branch 'origin/master' into master-next 2020-06-16 13:58:29 -07:00
Rintaro Ishizaki
5db0f1a40b [CodeCompletion] Typecheck without CodeCompletionExpr
when falling back to "postfix expression completion" after labeled
trailing closure completion.

rdar://problem/64176730
2020-06-15 21:40:40 -07:00