2526 Commits

Author SHA1 Message Date
Holly Borla
87bb7755c2 Merge pull request #30101 from hborla/dynamic-replacement-type-erasure
[Sema] Implement type erasure for dynamic replacement.
2020-02-28 09:37:33 -08:00
Holly Borla
3cdc30ffeb [Sema] Support type erasure for dynamic replacement in function
builders.
2020-02-27 09:01:16 -08:00
Slava Pestov
9452c60b3b Sema: Remove CSApply's getNaturalArgumentCount() in favor of getNumCurryLevels() 2020-02-26 23:10:07 -05:00
Slava Pestov
90ee606de7 Sema: Refactor CSApply in preparation for curry thunks 2020-02-26 23:10:07 -05:00
Doug Gregor
031f5a4888 Merge pull request #30065 from DougGregor/function-builders-if-case-fixes
[Constraint system] Cleanups for function builders support for if let/if case let
2020-02-26 10:38:15 -08:00
Doug Gregor
c58e0aa169 [Constraint system] Make sure we set expression types on StmtCondition. 2020-02-25 22:43:21 -08:00
Doug Gregor
141f3e7f07 [Constraint system] Expand SolutionApplicationTarget to StmtConditions.
Handle StmtCondition as part of SolutionApplicationTarget, so we can
generate constraints from it and rewrite directly as part of a solution,
rather than open-coding the operation in the function builder transform.
2020-02-25 13:47:26 -08:00
Joe Groff
cf0e09d9c5 Preserve conformances for upper bound constraints when lowering SILFunctionTypes 2020-02-24 12:14:21 -08:00
Joe Groff
9c9bf567f7 SIL: Preserve upper bound constraints for substitutions into nominal types.
When extracting substitutions during type lowering, we can't discard protocol constraints
in positions where the substitution is for a nominal type's generic arguments, since associated
types on that protocol may affect the nominal type's ABI.
2020-02-24 12:14:21 -08:00
Pavel Yaskevich
8af4f2ddb3 Merge pull request #29493 from LucianoPAlmeida/SR-11421-checked-cast-diag
[SR-11421][Diagnostics] Tailored diagnostic for checked downcast with literals
2020-02-19 17:29:30 -08:00
Hamish Knight
1a9764e6d7 [CS] Remove SubExpressionDiagnostics option 2020-02-19 07:43:59 -08:00
Pavel Yaskevich
2dccdbfabf [ConstraintSystem] NFC: Remove workarounds related to (now deprecated) CSDiag 2020-02-18 10:13:09 -08:00
Pavel Yaskevich
81c3f62638 [CSGen] Validate presence of _MaxBuiltinFloatType before generating constraints for float literals 2020-02-17 16:09:11 -08:00
Pavel Yaskevich
8722530943 [CSDiag] NFC: Move diagnoseDeprecatedConditionalConformanceOuterAccess to CSApply 2020-02-17 16:09:11 -08:00
Pavel Yaskevich
48f24b02d6 Merge pull request #29866 from xedin/rdar-57356196
[CSApply] Always use `String` type for ObjC interop key path
2020-02-17 10:50:31 -08:00
Pavel Yaskevich
ae79b0d0bd [CSApply] Always use String type for ObjC interop key path
If it's possible to build an Objective-C key path for key path
expression make sure that its implicitly generated string literal
expression has a `String` type.

Resolves: rdar://problem/57356196
2020-02-15 00:04:09 -08:00
Robert Widmann
a9e871a0b1 [Sema] Warn About Tuple Shuffles
Emit a warning that tuple shuffling is deprecated across the board. In
the future, we should try to unshuffle these expressions where we can,
but that's a diagnostic improvement for another day.

See also https://forums.swift.org/t/deprecating-tuple-shuffles-round-2/16884/30
2020-02-13 17:29:03 -08:00
Doug Gregor
d4cd5e0ebc Merge pull request #29801 from DougGregor/constraint-solver-rewrite-target
[Constraint system] Factor out application to a SolutionApplicationTarget
2020-02-12 20:24:41 -08:00
Luciano Almeida
968a37d221 [Diagnostics] Tailored diagnostic message for conditional downcast involving literals that can be statically coerced 2020-02-13 01:04:15 -03:00
Doug Gregor
7f9029071d [Constraint system] Adopt rewriteTarget for function builder transform.
When applying a function builder to a closure to produce the final,
type-checked closure, use the new rewriteTarget() so it’s performed on
a per-target basis. Use this to eliminate some duplicating in the handling
of return types.
2020-02-12 17:51:47 -08:00
Doug Gregor
efd357e7c7 [Constraint system] Factor out application to a SolutionApplicationTarget.
Pull out the core operation of rewriting a given SolutionApplicationTarget
into into a method on the ExprWalker that does the overall rewrite, so it
can be called multiple times within application.
2020-02-12 17:51:47 -08:00
Doug Gregor
8b5a639769 Merge pull request #29778 from DougGregor/more-sinking
[Constraint system] Sink optional “some” pattern handling into constrain generation
2020-02-11 20:13:38 -08:00
Doug Gregor
a308a7e53c [Constraint system] Sink down debug logging.
This way we’ll see constraints whenever they’re generated, and remove some
of the expression-centric nature of the top-level solve() and solveImpl().
2020-02-11 17:33:08 -08:00
Doug Gregor
151fc79264 Merge pull request #29770 from DougGregor/builder-transform-node-types
[Constraint solver] Fix handling of node types for function builder application
2020-02-11 17:21:16 -08:00
marcrasi
565b0e17fd change "new" to "malloc" because it gets "free"d later (#29767) 2020-02-11 16:03:32 -08:00
Doug Gregor
3508dfb0ea [Constraint system] Use hash table lookup appropriately.
It’s pointlessly inefficient to do an O(n) scan through a hash table to match
keys!
2020-02-11 15:14:44 -08:00
Doug Gregor
f5b9517552 [Constraint system] Simplify and improve handling of node tyoes.
Rather than having separate dense maps for the type mappings of each
node type (expression, type location, variable declaration, pattern) that
a TypedNode can be, have a single such map. Sometimes we end up
setting a particular node's type more than once, so cope with that
by restoring the prior type.
2020-02-11 15:14:44 -08:00
Doug Gregor
a1932f10e5 [Constraint solver] Sink remaining logic from typeCheckBinding.
Move the remaining logic of typeCheckBinding, which consists of applying
the solution to the pattern, down into the normal solution application
path. typeCheckBinding() is now a thin shell over the normal
typeCheckExpression() convenience function.
2020-02-10 22:01:37 -08:00
Doug Gregor
364770e658 [Constraint system] Remove typeCheckBinding’s ExprTypeCheckListener.
Sink the solution-application code from typeCheckBinding’s
ExprTypeCheckListener subclass into normal solution application, allowing
us to eliminate this subclass entirely. Down to one…
2020-02-10 22:01:37 -08:00
Doug Gregor
c1c7112110 Remove some unused code and fix a test 2020-02-10 22:01:37 -08:00
Doug Gregor
4d1de7fd3d [Constraint solver] Sink down initialization pattern constraint generation.
Sink the constraint generation for initialization patterns, including all
of the logic for property wrappers, from the high-level entry point
`typeCheckBinding` down into the lower-level constraint generation for
solution application targets.
2020-02-10 22:01:37 -08:00
swift-ci
08dca4666e Merge pull request #29635 from DougGregor/simplify-solution-target 2020-02-04 02:36:15 -08:00
Doug Gregor
9569714334 Clarify method names in SolutionApplicationTarget. 2020-02-03 22:11:03 -08:00
Doug Gregor
36366bc3e4 [Constraint solver] One SolutionApplicationTarget instance to rule them all.
Capture the peculiarities of contextual types vs. types used to generate
conversion constraints, as well as the behavior of “optional some” patterns
as used by if let / while let, within SolutionApplicationTarget. This allows
us to use a single target throughout setup / solving / application, rather
than mapping between two similar-but-disjoint targets.
2020-02-03 22:02:21 -08:00
Argyrios Kyrtzidis
b6b67c4e0c Merge pull request #29585 from akyrtzi/fix-missing-reference
[Sema/CSApply] Make sure that the member type references created for a `type(of: x).A` expression are visible to the `SourceEntityWalker`
2020-02-03 14:54:31 -08:00
Doug Gregor
3b761dcae1 [Constraint system] Add a SolutionApplicationTarget-based typeCheckExpression
Rework most of typeCheckExpression() to use SolutionApplicationTarget,
folding more information into that data structure and sinking more
expression-checking behavior down into the more general solver and
solution-application code.
2020-02-01 23:46:13 -08:00
Argyrios Kyrtzidis
60522887d9 [Sema/CSApply] Make sure that the member type references created for a type(of: x).A expression are visible to the SourceEntityWalker
For code like

```
  _ = type(of: x).A.self
```

the `A` type reference is written explicitely by the user, but the AST created using `TypeExpr::createImplicitHack` is hiding such a reference,
making the reference invisible to semantic functionality like 'rename'.

rdar://56885871
2020-02-01 01:26:07 -08:00
Doug Gregor
e0702d9f2e [Constraint solver] Generalize solve() for arbitrary solution targets.
Start cleaning up the main “solve” entry point for solving an expression
and applying the solution, so it handles arbitrary solution targets.
This is another small step that doesn’t do much on its own, but will help
with unifying the various places in the code base where we run the solver.
2020-01-30 22:01:12 -08:00
Doug Gregor
eb2862ec1e [Constraint system] Collapse applySolutionImpl() into applySolution().
Now that we have a unified notion of a SolutionApplicationTarget, use it
to collapse 3 applySolution-ish functions into one.
2020-01-30 22:01:12 -08:00
Doug Gregor
e3124dcb5f [Constraint system] Expand SolutionApplicationTarget for expressions.
Add the final conversion type and the flag indicating whether a given
expression is discarded to SolutionApplicationTarget, rather than 
separating the arguments to the solver implementation.
2020-01-30 22:01:12 -08:00
Doug Gregor
98db6e6422 [Constraint solver] Don’t mark a moved-from instance as “diagnosed”. 2020-01-30 22:01:12 -08:00
Doug Gregor
ad1ad43c6e Generalize SolutionApplicationTarget and use it more widely.
Make this type suitable for representing the result of solution application,
and do so.
2020-01-30 22:01:12 -08:00
Doug Gregor
d752f414d3 [Constraint solver] Rework solveImpl(Expr*) to return SolutionResult.
SolutionResult better captures what can happen when solving a constraint
system for the given expression occurs than the ad hoc SolutionKind return
& small vector of Solution results. Also, try to make this logic less
convoluted.
2020-01-26 12:05:43 -08:00
Doug Gregor
133439dcbb [Constraint solver] Request contextual type information per expression.
When requesting information about the contextual type of a constraint
system, do so using a given expression rather than treating it like
the global state that it is.
2020-01-23 11:46:17 -08:00
Doug Gregor
8283a67648 Revert "Revert "Reimplement function builders as statement transformations."" 2020-01-21 10:07:20 -08:00
Doug Gregor
86c13d3c74 Revert "Reimplement function builders as statement transformations." 2020-01-17 15:52:49 -08:00
Doug Gregor
9853926cb2 [Function builders] Make sure we contextualize closures with builders applied.
We used to get this contextualization "for free" because closures that
had function builders applied to them would get translated into
single-expression closures. Now, we need to check for this explicitly.
2020-01-16 13:19:21 -08:00
Doug Gregor
3a51d5b9b2 [WIP] Reimplement function builders as statement transformations. 2020-01-16 13:18:33 -08:00
Pavel Yaskevich
cf2cad0cd5 [ConstraintSystem] Add more information retrieval callbacks to getCalleeLocator
`getCalleeLocator` has to be able to:

- Retrieve type for given expression via `getType`;
- Simplify given type via `simplifyType`; and
- Retrieve a selected overload choice for a given locator via `getOverloadFor`.
2020-01-14 00:09:33 -08:00
Pavel Yaskevich
8f68a68c70 [ConstraintSystem] Augment getCalleeLocator with getType callback
This is necessary for ambiguity diagnostics because none of the
solutions are applied back to the constraint system which means
that `getCalleeLocator` needs an ability to query information
from different sources e.g. constraint system and/or solution.
2020-01-14 00:09:32 -08:00