Commit Graph

12650 Commits

Author SHA1 Message Date
Pavel Yaskevich
fbd7949e8a Merge pull request #23194 from xedin/simplify-add-overload-set
[ConstraintSystem] Simplify `addOverloadSet`
2019-03-11 11:51:23 -07:00
Pavel Yaskevich
c2590c0dec [ConstraintSystem] Simplify addOverloadSet
- Remove whole disjunction favoring which has no effect;
- Avoid creating separate disjunction for "inner" choices,
  which is going to be flattened later anyway.
2019-03-08 18:25:32 -08:00
Rintaro Ishizaki
19e54fed78 [CodeCompletion] Fixed a crasher regarding malformed operator decl
Infix operator completion used to crash if multiple infix operators with the
same name are declared in the module.

rdar://problem/48648877
2019-03-08 16:31:31 -08:00
Rintaro Ishizaki
da45b8d765 Merge pull request #22957 from rintaro/ide-completion-initializer-rdar40944761
[CodeCompletion] Force type check pattern binding for initializer
2019-03-08 16:13:24 -08:00
Pavel Yaskevich
5235ee8e68 Merge pull request #23179 from xedin/rdar-47776586
[ConstraintSystem] Detect and diagnose missing optional unwrap in arguments
2019-03-08 13:59:58 -08:00
Rintaro Ishizaki
1038011c67 [CodeCompletion] Force type check pattern binding for initializer
Also, do not handle parsed decls in first-pass. Because they are
re-parsed, they used to case duplicated decls in AST.

rdar://problem/40944761
2019-03-08 13:42:08 -08:00
Pavel Yaskevich
3940cebebf [Diagnostics] Don't suggest unwrap with default value if type is not materializable 2019-03-08 01:07:54 -08:00
Pavel Yaskevich
39dd6306c6 [Diagnostics] Refactor missing optional unwrap diagnostic
Instead of passing all of the information available in the diagnostic
to static functions, let's bring "default value" and "force unwrap"
fix-it logic under "missing optional unwrap diagnostic" umbrella.
2019-03-07 15:39:42 -08:00
Pavel Yaskevich
a5485d8ae2 [CSSimplify] Detect missing optional unwraps in operator/call arguments 2019-03-07 14:51:55 -08:00
Suyash Srijan
52b833d543 [typechecker] remove null check as its redundant 2019-03-07 21:15:25 +00:00
Doug Gregor
719547f8df Merge pull request #23125 from DougGregor/constraint-solver-remove-sr-2505-hack
[Constraint solver] Remove a dubious hack introduced with SR-2505
2019-03-06 20:22:50 -08:00
Slava Pestov
2e2c12f9cb Merge pull request #22822 from theblixguy/fix/SR-6022
[Typechecker] Warn when casting a function type to an existential or archetype type
2019-03-06 22:16:39 -05:00
Doug Gregor
2c744b4d50 [Constraint solver] Remove a dubious hack introduced with SR-2505 2019-03-06 08:58:56 -08:00
Doug Gregor
15ac48cd4b Improve a comment regarding an constraint-favoring hack. 2019-03-05 21:59:51 -08:00
Doug Gregor
1d6cb4f28f [Constraint solver] Remove unused ConstraintSystem::getUnboundBindOverloads() 2019-03-05 21:40:48 -08:00
Doug Gregor
b83bb70bac [Constraint solver] Look through optional binding for overload sets.
When we’re trying to find the overload set corresponding to a particular
type variable, look through “optional object of” constraints that represent
the use of ? binding or ! forcing. This allows us to find overload sets
when referring to, e.g., @objc optional protocol requirements.
2019-03-05 21:40:48 -08:00
Doug Gregor
fd50d945ce [Constraint system] Move SIMD operator partitioning into disjunction partitioning
Continuing along my path to move application-independent partitioning
rules into the common disjunction partitioning code.
2019-03-05 15:01:46 -08:00
Doug Gregor
b993c6e076 [Constraint solver] Move tryOptimizeGenericDisjunction() into partitioning
This narrow favoring rule makes more sense as part of disjunction
partitioning, because it is not dependent on the use site at all and
should only kick in when other options fail.
2019-03-05 15:01:46 -08:00
Doug Gregor
fae2d1b2ac Merge pull request #23088 from DougGregor/solver-disjunction-favoring
[Constraint solver] Generalize disjunction favoring
2019-03-05 14:41:56 -08:00
Suyash Srijan
a493934c58 [typechecker] use castTo() instead of getAs() 2019-03-05 21:00:23 +00:00
Suyash Srijan
a2460b8892 Merge branch 'master' into fix/SR-6022 2019-03-05 20:57:31 +00:00
Doug Gregor
20bb077229 [Constraint solver] Use tryOptimizeGenericDisjunction() during application.
Use tryOptimizeGenericDisjunction() as part of simplifying apply
constraints.
2019-03-05 10:30:51 -08:00
Doug Gregor
d2c7c8d5ee [Constraint solver] Enable favoring of disjunction constraints during solving
Allow constraints to be favored during solving, and unwound after exiting
that particular solver scope. We're not using this yet.
2019-03-05 10:30:51 -08:00
Pavel Yaskevich
f70c43a028 Merge pull request #23085 from xedin/diag-OoO-arguments
[ConstraintSystem] Diagnose out-of-order arguments via fixes
2019-03-05 00:52:23 -08:00
Doug Gregor
4c16107365 [Constraint solver] Unify overload favoring on getEffectiveOverloadType().
The overload-favoring code had a couple of different ways in which it
tried to figure out the parameter lists of a given declaration. Have
those all depend on ConstraintSystem::getEffectiveOverloadType(),
which deals with the various member/non-member cases uniformly.
2019-03-04 20:48:48 -08:00
Doug Gregor
daf4610be1 [Constraint solver] Don't remove/reintroduce disjunction when favoring.
When favoring particular constraints in a disjunction, don't remove
the old disjunction and create a new one---it's just churn in the
constraint system. Instead, favor the constraints that need it.

This technically flips the SR-139 test case from "too complex" to
being fast enough, but it's still fairly slow.
2019-03-04 20:31:06 -08:00
Pavel Yaskevich
2e14bec250 [Diagnostics] Add out-of-order argument diagnostic 2019-03-04 20:03:54 -08:00
Pavel Yaskevich
1d2c3633fb [ConstraintSystem] Fix out-of-order arguments
Detect and fix out-of-order arguments by moving them into correct
positions.
2019-03-04 20:03:48 -08:00
Pavel Yaskevich
5dd5454a75 [CSSimplify] Determine if argument is out-of-order while matching labels
Instead of rerouting out-of-order into re-labeling during diagnostics,
let's do that as part of the label matching algorithm.
2019-03-04 20:03:30 -08:00
Doug Gregor
0f31416d96 [Constraint solver] Always partition disjunctions when solving.
The disjunction partitioning logic was only used for the experimental
designated-types feature, but is generally useful. Unify the code
paths so we always do the partitioning, with only the designated-types
part being enabled/disabled by the flag.
2019-03-04 19:49:58 -08:00
swift-ci
5ec8f96fd3 Merge pull request #23077 from DougGregor/revert-common-type 2019-03-04 17:04:47 -08:00
Doug Gregor
9086b2beef [Constraint solver] Flatten the disjunction created by call favoring.
The call-favoring code was creating a two-level disjunction, when would
then immediately get flattened into a single level. Instead, create a
single-level disjunction directly.
2019-03-04 16:21:24 -08:00
Doug Gregor
ae4949d27c [Constraint solver] Remove a hand-rolled clone of getUnboundBindOverloadDisjunction
Use the real one instead.
2019-03-04 15:59:59 -08:00
Doug Gregor
c0917c90d2 [Constraint solver] Revert the "common type" optimization.
The "common type" optimization isn't really buying us anything at this
point, because we're not able to make much use of the common structure
often enough. Revert the "common type" optimization for now... I'll
bring it back when there's enough optimization infrastructure around
it to make it compelling.
2019-03-04 15:00:45 -08:00
Doug Gregor
2e2ba8fde7 [Constraint solver] Check labels of unresolved member references.
We don’t really allow overloading of case names based on labels, so we can’t
really test this, but we’re supposed to so I’ll fix the code ;)
2019-03-04 15:00:34 -08:00
Pavel Yaskevich
9c916fc2e5 Merge pull request #23072 from xedin/diag-closure-param-destructuring
[ConstraintSystem] Diagnose closure parameter destructuring via fixes
2019-03-04 14:46:11 -08:00
Pavel Yaskevich
9999a47197 [Diagnostics] Add closure parameter destructuring diagnostic 2019-03-04 11:37:43 -08:00
Pavel Yaskevich
8f85b848cc [ConstraintSystem] Fix closure parameter destructuring
Detect and fix closure parameter destructuring where
it's not currently allowed e.g. free standing closures
with contextual type `let _: ((Int, Int)) -> Void = { $0 + $1 }`
2019-03-04 11:02:15 -08:00
Joe Groff
7011f32d3a Merge pull request #22486 from theblixguy/fix/SR-7799
[Typechecker] Allow matching an enum case against an optional enum without '?'
2019-03-04 09:50:06 -08:00
Doug Gregor
8151a34f6a [Constraint solver] Merge the two areConservativelyCompatibleArgumentLabels()
The decl-based version is only used by the OverloadChoice-based version
anyway.
2019-03-03 22:51:33 -08:00
Doug Gregor
c8d7059863 Merge pull request #23012 from DougGregor/apply-filter-disjunctions
[Constraint solver] Do argument label matching during apply simplification
2019-03-02 16:09:41 -08:00
Doug Gregor
7249c92c00 Use ErrorType as a sentinel type rather than Optional<Type> 2019-03-02 10:50:51 -08:00
Doug Gregor
69ef7895a8 [Constraint solver] Match argument labels for unresolved member expressions. 2019-03-01 23:11:34 -08:00
Doug Gregor
e5613296fd [Constraint solver] Minor cleanup for @optional declarations. 2019-03-01 23:10:01 -08:00
Doug Gregor
6246e7e1db [Constraint solver] Fix effective-overload-type for constructors, dynamic Self
Implement support for querying the effective overload type for constructors
and fix a semi-related bug for methods returning dynamic Self, which I
had not accounted for.
2019-03-01 23:10:01 -08:00
Doug Gregor
603d5d6f20 [Constraint solver] Synchronize argument label setting/retrievable.
The walker that was setting argument labels was looking through ! and ?
postfix expressions, but the lookup code itself was not, leading to missed
opportunities for filtering based on argument labels. Generalize the
transformation that maps from the function expression down to the locator
for which we will retrieve argument labels.
2019-03-01 21:45:39 -08:00
Doug Gregor
233cf6ffa6 [Constraint solver] Address feedback from Pavel and Slava. 2019-03-01 20:54:48 -08:00
Slava Pestov
d68388c8c7 Sema: Move conformance checking PrettyStackTrace to a better place
Not all conformance checking goes through checkConformance() so we
were losing useful information in some backtraces.
2019-03-01 21:01:51 -05:00
Slava Pestov
2813912c48 Merge pull request #23010 from pschuh/s-5
FloatLiteralExpr now is lowered directly into SIL.
2019-03-01 17:32:23 -05:00
Doug Gregor
4097428df9 [Constraint solver] Declarations with IUOs don’t have effective overload types
A declaration with an implicitly-unwrapped optional essentially has two
effective overload types, because the result might be optional or it might
have been forced. Disable computation of the effective overload type in this
case.
2019-03-01 09:45:24 -08:00