Commit Graph

937 Commits

Author SHA1 Message Date
Nathan Hawes
607e2b8822 Manually merge remote-tracking branch 'upstream/master' into HEAD 2020-08-04 13:47:48 -07:00
Rintaro Ishizaki
00e4a76ef0 Revert "[Sema/Index] Resolve #keyPath components so they get handled by indexing, semantic highlighting, etc." 2020-08-04 12:51:52 -07:00
Anthony Latsis
b26310ee97 TypeLoc: Offload TypeLoc off the ASTWalker 2020-08-04 18:13:28 +03:00
Matei Oprea
f971b349b4 [NFC] Refactor manual size calculations in memory allocation (#33256) 2020-08-03 22:02:31 -07:00
Varun Gandhi
3882beb85d [NFC] Use consistent naming scheme for predicate methods. (#33265)
bool throws() -> isThrowing(), bool async() -> isAsync()
2020-08-03 16:37:29 -07:00
Nathan Hawes
4c7cd16c3f Merge pull request #33245 from nathawes/index-key-paths
[Sema/Index] Resolve #keyPath components so they get handled by indexing, semantic highlighting, etc.
2020-08-03 10:28:48 -07:00
Nathan Hawes
1d78fe1211 [Sema/Index] Resolve #keyPath components so they can be indexed
Unlike \keypath expressions, only the property components of #keypath
expressions were being resolved, so index wouldn't pick up references for their
qualifying types.

Also fixes a code completion bug where it was reporting members from the Swift
rather than ObjC side of bridged types.

Resolves rdar://problem/61573935
2020-07-31 17:11:23 -07:00
swift-ci
3a299d5a76 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-07-30 08:23:18 -07:00
Chris Lattner
8bde04cc14 [Concurrency] Implement parsing and semantic analysis of await operator
Similar to `try`, await expressions have no specific semantics of their
own except to indicate that the subexpression contains calls to `async`
functions, which are suspension points. In this design, there can be
multiple such calls within the subexpression of a given `await`.

Note that we currently use the keyword `__await` because `await` in
this position introduces grammatical ambiguities. We'll wait until
later to sort out the specific grammar we want and evaluate
source-compatibility tradeoffs. It's possible that this kind of prefix
operator isn't what we want anyway.
2020-07-29 22:08:09 -07:00
swift-ci
adb31a9532 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-07-28 19:23:53 -07:00
Rintaro Ishizaki
59196975b7 Merge pull request #32696 from rintaro/ide-completion-typecheckatloc
[CodeCompletion] Only type check target statement and related decls in function body
2020-07-28 19:12:31 -07:00
swift-ci
0202740b0a Merge remote-tracking branch 'origin/master' into master-rebranch 2020-07-28 14:24:04 -07:00
Doug Gregor
73f07a6f0f Merge pull request #33092 from DougGregor/forward-trailing-closure-matching-sourcecompat-backward-bias
[SE-0286] Forward matching of trailing closure arguments
2020-07-28 14:11:15 -07:00
Nathan Hawes
b0a2230860 Manually merge remote-tracking branch 'upstream/master' into merge-in-master 2020-07-27 09:25:01 -07:00
Doug Gregor
3f96125edc [AST] Don't compute type in ClosureExpr::capturesSelfEnablingImplictSelf
This predicate can be determined without computing the full type of
the declaration.
2020-07-24 22:32:07 -07:00
Rintaro Ishizaki
7e402e1ec4 [Sema] Stop on-demand type checking for 'VarDecl' in 'TapExpr' 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
b1eec26653 [AST] Add a enum for type checking state of ClosureExpr's body 2020-07-24 10:46:03 -07:00
Rintaro Ishizaki
0ec7a91e38 [AST] Add a pointer to parent 'TapExpr' expression in 'VarDecl'
Preparation for on-demand 'VarDecl' type checking in interpolated string
literals.
2020-07-24 10:46:03 -07:00
Doug Gregor
17669d7d5d [Trailing closures] Attempt both forward and backward scans.
To better preserve source compatibility, teach the constraint
solver to try both the new forward scanning rule as well as the
backward scanning rule when matching a single, unlabeled trailing
closure. In the extreme case, where the unlabeled trailing closure
matches different parameters with the different rules, and yet both
produce a potential match, introduce a disjunction to explore both
possibilities.

Prefer solutions that involve forward scans to those that involve
backward scans, so we only use the backward scan as a fallback.
2020-07-24 08:11:25 -07:00
swift-ci
565d852907 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-07-22 15:25:04 -07:00
Robert Widmann
cb82a46e6e [NFC] Stash Syntactic Information in EnumIsCaseExpr
After the TypeLocs were removed here, the TypeRepr from the IsExpr was
the only thing providing access to syntactic information from the parent
IsExpr. In order to support this, it was possible to construct a bizarre
ConditionalCheckedCastExpr that contained both semantic and syntactic
information. This doesn't comport with the rest of the casting nodes,
which force you to pick one or the other.

Since we're rewriting an IsExpr into a EnumIsCaseExpr, let's just stash
the syntactic information there. This unblocks a bit of cleanup.
2020-07-22 11:08:52 -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
Holly Borla
a6c33a9611 [Property Wrappers] Use autoclosure information from CSApply to compute
`VarDecl::getPropertyWrapperInitValueInterfaceType`.
2020-07-13 17:22:29 -07:00
swift_jenkins
488bc14ef3 Merge remote-tracking branch 'origin/master' into master-next 2020-06-18 19:38:41 -07:00
Suyash Srijan
b61b68d387 [AST] Look through try expressions inside open existential expression's sub expression in 'getUnwrappedCurryThunkExpr()' (#32458) 2020-06-19 03:29:25 +01:00
swift_jenkins
0b350f6562 Merge remote-tracking branch 'origin/master' into master-next 2020-06-10 11:38:51 -07:00
Robert Widmann
ca728917e1 Merge pull request #32138 from AnthonyLatsis/eliminate-typeloc
Sema: Remove TypeLoc from ExplicitCastExpr (via TypeExpr)
2020-06-10 11:28:50 -07:00
Anthony Latsis
4b4634141f Sema: Remove TypeLoc from ExplicitCast 2020-06-09 15:20:25 +03:00
Karoy Lorentey
57ea964f2c Merge commit '3eb82c183662945687f48e11c09828f551b34858' into master-next
# Conflicts:
#	include/swift/Frontend/FrontendInputsAndOutputs.h
2020-06-08 16:58:37 -07:00
Karoy Lorentey
68351d2110 Revert "Merge remote-tracking branch 'origin/master-next'"
This reverts commit 1c9b0908e6, reversing
changes made to 3eb82c1836.
2020-06-08 16:48:38 -07:00
Karoy Lorentey
1c9b0908e6 Merge remote-tracking branch 'origin/master-next'
# Conflicts:
#	include/swift/Frontend/FrontendInputsAndOutputs.h
2020-06-08 16:43:40 -07:00
Doug Gregor
a115ad9f5c [AST] Record "separately checked" in ClosureExpr.
Reverse the polarity of the "checked in context" bit for ClosureExpr
to "separately checked", which simplifies the AST walker logic (to
"should we walk separately type-checked closure bodies?") and
eliminates single-expression closures as a separate case to consider.
2020-06-05 00:05:11 -07:00
Doug Gregor
7eae5f2f0d [AST] Remove now-unused ClosureExpr::setSingleExpressionBody(). 2020-06-04 23:24:06 -07:00
Doug Gregor
ad42d477f7 [AST] Remove some pointless uses of hasSingleExpressionBody(). 2020-06-03 22:55:23 -07:00
Doug Gregor
690d6c446b [AST] Record whether a closure was type-checked in its enclosing expression
Rather than using various "applied function builder" and "is single
expression body" checks to determine whether a closure was
type-checked in its enclosing expression, record in the closure
expression whether it actually *was* type-checked as part of its
enclosing expression.
2020-06-03 22:26:20 -07:00
swift_jenkins
bec7163861 Merge remote-tracking branch 'origin/master' into master-next 2020-05-31 08:40:26 -07:00
Doug Gregor
761ee54006 [Constraint system] Use a visitor for solution application to closures.
Introduce a statement visitor that applies a particular solution to
the body of a closure. This matches the mechanism used by function
builders (and is similar to how we handle expressions in general),
simplifying the logic for handling
conversion-to-void-returning-closures and
conversion-from-Never-returning-bodies. It is a stepping stone for
type inference of multi-statement closures.
2020-05-31 00:03:56 -07:00
swift_jenkins
ff08e416e1 Merge remote-tracking branch 'origin/master' into master-next 2020-05-18 18:58:38 -07:00
Nathan Hawes
94916dee92 [AST] Restore getSourceRange() on DefaultArgumentExpr.
This restores getSourceRange() on DefaultArgumentExpr after it was removed in
https://github.com/apple/swift/pull/31184.

It was originally removed to solve the issues it was causing when computing the
source range of its parent TupleExpr. To account for trailing closures we walk
back through the tuple's arguments until one with a valid location is found,
which we use as the end location. If the last argument was a DefaultArgumentExpr
though that meant the end loc would end up being the tuple's start location, so
none of the tuple's other arguments were contained in its range, triggering an
ASTVerifier assertion. Source tooling and diagnostics don't care about default
arg expression locations as nothing can reference them, but their locations are
output in the debug info. Added a regression test to catch that in future, and
updated TupleExpr::getSourceRange() to ignore them when computing the end loc.

Resolves rdar://problem/63195504.
2020-05-18 14:52:00 -07:00
swift_jenkins
e6e25df038 Merge remote-tracking branch 'origin/master' into master-next 2020-05-06 14:35:31 -07:00
John McCall
a518e759d9 WIP for a different syntax for multiple trailing closures
that allows arbitrary `label: {}` suffixes after an initial
unlabeled closure.

Type-checking is not yet correct, as well as code-completion
and other kinds of tooling.
2020-05-06 01:56:40 -04:00
Nathan Hawes
4c4990ead4 Multiple trailing closure fixes
- Diagnose non-closure-literals after label + colon
- Form a TupleExpr, rather than a ParenExpr for a single labelled trailing closure.
2020-05-06 01:56:40 -04:00
Pavel Yaskevich
d06126da3b [Parser] Add support for multiple trailing closures syntax
Accept trailing closures in following form:

```swift
foo {
  <label-1>: { ... }
  <label-2>: { ... }
  ...
  <label-N>: { ... }
}
```

Consider each labeled block to be a regular argument to a call or subscript,
so the result of parser looks like this:

```swift
foo(<label-1>: { ... }, ..., <label-N>: { ... })
```

Note that in this example parens surrounding parameter list are implicit
and for the cases when they are given by the user e.g.

```swift
foo(bar) {
  <label-1>: { ... }
  ...
}
```

location of `)` is changed to a location of `}` to make sure that call
"covers" all of the transformed arguments and parser result would look
like this:

```swift
foo(bar,
   <label-1>: { ... }
)
```

Resolves: rdar://problem/59203764
2020-05-06 01:56:40 -04:00
Pavel Yaskevich
45ac1bcf17 [Parser] Adjust parseExprList to return multiple trailing closures
Also extend returned object from simplify being an expression to
`TrailingClosure` which has a label, label's source location and
associated closure expression.
2020-05-06 01:56:40 -04:00
Pavel Yaskevich
5cea9b9849 [AST] Add support for multiple trailing closures to the parser/expressions 2020-05-06 01:56:40 -04:00
Pavel Yaskevich
4650091efb [AST] Remove unused "trailing closure" argument from totalSizeToAlloc and initializeCallArguments 2020-05-06 01:56:40 -04:00
Pavel Yaskevich
0c9a37fcf4 [AST] Extend TupleExpr to support multiple trailing closures 2020-05-06 01:56:40 -04:00
swift_jenkins
d8595f7cda Merge remote-tracking branch 'origin/master' into master-next 2020-04-30 00:54:04 -07:00
swift_jenkins
4dc2e3c785 Merge remote-tracking branch 'origin/master' into master-next 2020-04-29 17:59:15 -07:00