Commit Graph

918 Commits

Author SHA1 Message Date
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
Pavel Yaskevich
a483b344ee [AST] Drop const qualifier from {get/set}Type callbacks 2020-04-29 17:03:45 -07:00
Robert Widmann
1319b53528 Hide the TypeExpr in ClosureExpr 2020-04-29 13:40:39 -07:00
Robert Widmann
19ab68db98 [NFC] Strip UnresolvedSpecializeExpr of its TypeLoc
No caller needed the type
2020-04-28 20:10:10 -07:00
swift_jenkins
91d132ebbc Merge remote-tracking branch 'origin/master' into master-next 2020-04-28 10:47:35 -07:00
Robert Widmann
a6fc9b3679 Merge pull request #31253 from CodaFi/casting-call
Strip TypeExpr of its TypeLoc
2020-04-28 09:45:53 -07:00
swift_jenkins
a6085e72a6 Merge remote-tracking branch 'origin/master' into master-next 2020-04-27 22:17:56 -07:00
Nathan Hawes
0a0b9f7853 Merge pull request #31352 from nathawes/fix-assertion-hit-in-getUnwrappedCurryThunkExpr
[AST] Fix assertion hit in AutoClosureExpr::getUnwrappedCurryThunkExpr()
2020-04-27 22:09:43 -07:00
Nathan Hawes
f78c93009d [AST] Fix assertion hit in AutoClosureExpr::getUnwrappedCurryThunkExpr()
For DoubleCurryThunk cases it’s expecting an ApplyExpr directly within the
OpenExistentialExpr, but in some cases it contains an ErasureExpr (implicit
conversion) that wraps the ApplyExpr. This updates the method to look
through implicit conversions.

Resolves rdar://problem/61885996
2020-04-27 15:30:04 -07:00
Robert Widmann
0c4bef421f [NFC] Fixup references to TypeExpr::getInstanceType 2020-04-24 16:31:57 -07:00
swift_jenkins
71686f9984 Merge remote-tracking branch 'origin/master' into master-next 2020-04-24 12:58:09 -07:00
Robert Widmann
7ed188216e Remodel the Interface for Implicit TypeExprs
Make it slightly easier to enforce the invariant that implicit TypeExpr
nodes have a contextual type set.
2020-04-23 17:04:38 -07:00
Robert Widmann
09db2902d2 Strip TypeExpr of its TypeLoc
Remove duplication in the modeling of TypeExpr. The type of a TypeExpr
node is always a metatype corresponding to the contextual
type of the type it's referencing. For some reason, the instance type
was also stored in this TypeLoc at random points in semantic analysis.

Under the assumption that this instance type is always going to be the
instance type of the contextual type of the expression, introduce
a number of simplifications:

1) Explicit TypeExpr nodes must be created with a TypeRepr node
2) Implicit TypeExpr nodes must be created with a contextual type
3) The typing rules for implicit TypeExpr simply opens this type
2020-04-23 17:04:38 -07:00
Anthony Latsis
74252028ca AST: Rename getFullName -> getName on ValueDecl & MissingMemberDecl 2020-04-23 05:16:55 +03:00
swift_jenkins
ff72ecb3b8 Merge remote-tracking branch 'origin/master' into master-next 2020-04-14 10:55:35 -07:00
Holly Borla
65105f3a26 [Property Wrappers] Introduce a new Expr node for the property wrapper
wrapped value placeholder in an init(wrappedValue:) call that was previously
injected as an OpaqueValueExpr. This commit also restores the old design of
OpaqueValueExpr.
2020-04-09 16:00:57 -07:00
swift_jenkins
ed201da7a9 Merge remote-tracking branch 'origin/master' into master-next 2020-03-27 01:39:50 -07:00
marcrasi
f6562d3a67 [AutoDiff upstream] differentiable function conversion pipeline (#30660)
Add the `@differentiable` function conversion pipeline:

- New expressions that convert between `@differentiable`,
  `@differentiable(linear)`, and non-`@differentiable` functions:
  - `DifferentiableFunction`
  - `LinearFunction`
  - `DifferentiableFunctionExtractOriginal`
  - `LinearFunctionExtractOriginal`
  - `LinearToDifferentiableFunction`
- All the AST handling (e.g. printing) necessary for those expressions.
- SILGen for those expressions.
- CSApply code that inserts these expressions to implicitly convert between
  the various function types.
- Sema tests for the implicit conversions.
- SILGen tests for the SILGen of these expressions.

Resolves TF-833.
2020-03-27 01:27:39 -07:00
swift_jenkins
fb50e1beee Merge remote-tracking branch 'origin/master' into master-next 2020-03-18 11:38:03 -07:00
Slava Pestov
4caa6d7003 IDE: Fix indexing for Sema-built curry thunks 2020-03-17 19:03:03 -04:00