Commit Graph

1334 Commits

Author SHA1 Message Date
Pavel Yaskevich
5c82b57096 [CSDiagnostics] Teach missing explicit call fix to account for defaults
Currently we only produce a fix if function type doesn't have any
parameters, but it should also account for function having defaults
for all of its parameters which would still allow for nullary call.
2019-07-31 17:21:49 -07:00
Xi Ge
b6f1f0659e Merge pull request #26437 from nkcsgexi/HasDynamicMemberLookupAttributeRequest
IDE+Evaluator: refactor the sema implementation of hasDynamicMemberLookupAttribute to a request and move the function wrapper to libIDE. NFC
2019-07-31 13:39:27 -07:00
Xi Ge
9065ae93f6 IDE+Evaluator: refactor the sema implementation of hasDynamicMemberLookupAttribute as a request and move the function wrapper to libIDE. NFC 2019-07-31 11:30:25 -07:00
Pavel Yaskevich
7e1eae4a68 [ConstraintSystem] NFC: getCalleeDeclAndArgs no longer needs scratch space for argument labels 2019-07-31 00:00:50 -07:00
Pavel Yaskevich
32040ebd65 [ConstraintSystem] NFC: Refactor getArgumentInfo to accept ConstraintLocator 2019-07-31 00:00:21 -07:00
Pavel Yaskevich
d04ab92934 [ConstraintSystem] Use previous collected argument info in getCalleeDeclAndArgs 2019-07-31 00:00:21 -07:00
Pavel Yaskevich
e2dd9da5e3 [ConstraintSystem] NFC: Move argument info handling into constraint system 2019-07-31 00:00:21 -07:00
Sam Lazarus
a3b56c2790 Diagnostics: Ported tuple mismatch diagnostic to new diagnostic framework 2019-07-29 13:45:08 -04:00
Pavel Yaskevich
effd0d00c6 Merge pull request #26302 from xedin/remove-label-mismatch-from-lookup
[Diagnostics] Don't filter overload set candidates based on labels in lookup
2019-07-26 10:34:23 -07:00
Pavel Yaskevich
be470f5dd7 [ConstraintSystem] Don't attempt to optimize disjunction in diagnostic mode
Don't attempt disjunction optimization in "diagnostic mode"
because in such mode we'd like to attempt all of the available
overloads regardless of of problems related to missing or
extraneous labels and/or arguments.
2019-07-25 00:36:00 -07:00
Pavel Yaskevich
8b33cd0e2e [ConstraintSystem] Include argument labels into member name for AnyObject lookup
If we're referencing AnyObject and we have argument labels, put
the argument labels into the name: we don't want to look for
anything else, because the cost of the general search is so high.
2019-07-25 00:36:00 -07:00
Pavel Yaskevich
b5cd400262 [ConstraintSystem] De-prioritize fixes which suggest removing extraneous labels
The rule is that if there is a label it's evidence that the
intent is to reference a particular overload where that label
would match, so let's try to de-prioritize fixes for overloads
where labels didn't line up correctly and suggestion is to
remove certain labels vs. fixes when labels did line up but
types or requirements didn't.
2019-07-25 00:36:00 -07:00
Pavel Yaskevich
c85deb1a8d [ConstraintSystem] NFC: Refactor areConservativelyCompatibleArgumentLabels to accept arguments directly
Since `areConservativelyCompatibleArgumentLabels` is only used by
`simplifyAppliedOverloads` now, it's easy to pass arguments directly
instead of trying to form them from list of labels.
2019-07-25 00:36:00 -07:00
Pavel Yaskevich
d3205b202e [ConstraintSystem] Remove UR_LabelMismatch overload unavailability reason
This helps with:

- Diagnostics because solver would get more choices to work with
  in diagnostic mode;
- Avoid adding the same overload multiple times
  (retry after label mismatch and no viable candidates);
- Unify overload handling/filtering in `simplfyAppliedOverloads`.
2019-07-25 00:36:00 -07:00
Doug Gregor
8355f3d270 [Constraint graph] Move constraint uniquing into gatherConstraints().
Simplify the interface to gatherConstraints() by performing the
uniquing within the function itself and returning only the resulting
(uniqued) vector of constraints.
2019-07-25 02:26:49 -04:00
Suyash Srijan
afa14713e9 Merge branch 'master' into fix/SR-11074 2019-07-17 08:40:49 +01:00
Suyash Srijan
1a1bff46d8 [CS] Don't crash when using magic literals as default arg
Squash all commits into one
2019-07-17 01:20:25 +01:00
Pavel Yaskevich
eb627085e7 [CSFix] Adjust tuple splat fix attempt to record a fix and return a boolean 2019-07-16 11:06:42 -07:00
Pavel Yaskevich
9c196eb981 [ConstraintSystem] Add a fix to allow tuple splat for calls with single tuple parameter 2019-07-16 11:06:42 -07:00
Pavel Yaskevich
cd07652f22 [ConstraintSystem] Don't attempt dynamic member lookup on invalid base
If `subscript(dynamicMember:)` is unviable because it's either
an instance method referenced on type or static method
referenced on an instance of type, attempting dynamic
member lookup would be incorrect since it's unclear
what is intended.

Resolves: rdar://problem/48994658
2019-07-11 15:57:17 -07:00
Pavel Yaskevich
22fb079373 [ConstraintSystem] Don't let conditional conformances shadow members accessible through dynamic lookup
Currently if there is a conditional conformance to a type marked
as `@dynamicMemberLookup` with member that shadows one accessible
through dynamic lookup we'd report an error if that conformance
has not been satisfied.

Better behavior would be to consider dynamic member lookup and
if that fits let the expression type-check.

Resolves: rdar://problem/52779809
2019-07-10 15:31:24 -07:00
Pavel Yaskevich
0316bb1cce [CSFix] NFC: Fix a typo orRValueBase -> onRValueBase 2019-07-09 11:00:14 -07:00
Pavel Yaskevich
1e8ae99008 [CSFix] Add a fix for invalid reference to mutating member on immutable base 2019-07-09 00:25:30 -07:00
Pavel Yaskevich
133e85bec5 [CSFix] NFC: Extract common base class for all invalid member refs 2019-07-09 00:25:30 -07:00
Pavel Yaskevich
626b93cca2 [ConstraintSystem] Make sure that property wrapper diagnostics don't consider invalid declarations 2019-07-04 20:01:19 -07:00
Pavel Yaskevich
1c161e7109 [Diagnostics] Extend property wrapper diagnostics to support subscript refs
Previously unintended property wrapper unwrap diagnostics supported only
dot expressions, let's extend it to cover subscripts as well.
2019-07-03 22:13:31 -07:00
Pavel Yaskevich
b8c25db47e [ConstraintSystem] Add keypath subscript choice only if argument has an expected label
Currently only valid way to form keypath subscript is to use `keyPath:`
label in subscript invocation, so let's avoid adding keypath overload
choice to every subscript lookup and instead only add it when it could
potentially match.

This among other things greatly helps diagnostics because sometimes
`keypath application` becomes the only choice even although it's
not really viable, which impedes member reference diagnostics.
2019-07-03 00:48:04 -07:00
Pavel Yaskevich
7a0b8950cc Merge pull request #25904 from xedin/dont-fix-wrapper-if-generic-args-didnt-line-up
[ConstraintSystem] Don't try fixes while matching types for property …
2019-07-01 11:19:50 -07:00
Pavel Yaskevich
84a6103128 Merge pull request #25844 from xedin/diagnose-instance-method-on-metatype
[Diagnostics] Diagnose all invalid references to instance methods
2019-07-01 00:33:54 -07:00
Pavel Yaskevich
f7913f869e [ConstraintSystem] Don't try fixes while matching types for property wrapper diagnostics
While trying to figure out whether there is a missing or extraneous
property wrapper reference, let's not try to fix any generic argument
mismatches associated with wrapper or wrapped types, otherwise the
fix is going to be incorrect.
2019-07-01 00:27:38 -07:00
Sam Lazarus
0cf1bf2b7e [Diagnostics]: Add diagnostics for incorrect property wrapper references in function args (#25889) 2019-06-30 12:42:53 +02:00
Pavel Yaskevich
25629bed20 [Diagnostics] Enhance property wrapper diagnostics with member kind 2019-06-28 14:37:21 -07:00
Sam Lazarus
70bdcfd370 Sema: Add handling for fixes when member is present on $$ version of decl 2019-06-28 12:09:50 -07:00
Sam Lazarus
bd54febb37 Sema: Change property wrappers fixit to always remove the correct number of '$' 2019-06-28 12:09:50 -07:00
Sam Lazarus
55b17feac1 Sema: Handle storage wrappers correctly in diagnostics 2019-06-28 12:09:49 -07:00
Sam Lazarus
6ec03da6b0 Sema: Add property wrapper diagnostic for unnecessary $ in member access
Additionally, refactor some of the logic for the original add $ diagnostic
so that a lot of logic can be shared between the two. Also rename the
original fix and diagnostic to better reflect their purpose.
2019-06-28 12:09:49 -07:00
Pavel Yaskevich
c118c383d8 [Diagnostics] Diagnose all invalid references to instance methods
Extend use of "instance member on type" fix to cover potentially
invalid partial applications, references to instance members on
metatypes, and remove related and now obsolete code from `CSDiag`.

Resolves: [SR-9415](https://bugs.swift.org/browse/SR-9415)
2019-06-27 16:09:07 -07:00
Pavel Yaskevich
b72b3cbf0d Merge pull request #25721 from theblixguy/fix/SR-10992
[ConstraintSystem] Fix crash on function conversion reliant on conditional conformance
2019-06-24 16:52:35 -07:00
Suyash Srijan
aaacd29b68 [ConstraintSystem] Adds the new overload to FailureDiagnostic as well and remove other instances of 0 summary flags 2019-06-24 22:33:38 +01:00
Suyash Srijan
7a63586f34 [ConstraintSystem] Use the new getConstraintLocator overload 2019-06-24 21:58:23 +01:00
Sam Lazarus
ebcbaca968 [Diagnostics] Add a diagnostic for inserting a $ to remove an extraneous property wrapper unwrap (#25507) 2019-06-20 20:28:25 -04:00
Hamish Knight
e1f8af2389 Merge remote-tracking branch 'upstream/master' into a-couple-of-tangents 2019-06-18 19:09:06 +01:00
Slava Pestov
c365ef32c6 Sema: Handle protocol compositions containing type variables in matchTypes()
We would previously fail to match something like (C<$T1> & P) against
(C<Int> & P) when the constraint kind was <= Subtype, because we would
fall back to a type equality test in that case.

However, this was only valid for protocol compositions without superclass
constraints since the superclass could contain a type variable on one
side of the constraint.

Fix this by adding support for protocol composition types to
matchDeepEqualityTypes().
2019-06-17 18:40:31 -04:00
Sam Lazarus
ff950a419f Sema: Refactor logic for excluding arrays / optionals out of closure 2019-06-14 12:37:13 -04:00
Sam Lazarus
64b1186cb7 Sema: Change closure passed to matchDeepTypeArguments to return if it recorded anything 2019-06-14 12:35:32 -04:00
Sam Lazarus
cc8c2b1724 Sema: Fix how matchDeepEqualityType failures are handled 2019-06-14 12:35:32 -04:00
Sam Lazarus
de7851b0e9 Test: Update tests to reflect change to generic mismatch note locations 2019-06-14 12:35:32 -04:00
Sam Lazarus
1701ea1adc Sema: Changed GenericArgumentsMismatch to use trailing objects 2019-06-14 12:35:31 -04:00
Sam Lazarus
81dc5460c9 Sema / Test: Fix tests broken by introduction of GenericArgumentsMismatchFailure
Additionally, fixed a crash caused by the change relating to opaque types.
2019-06-14 12:35:31 -04:00
Sam Lazarus
dc5ccd1349 Test: Add tests for the new generic arguments mismatch diagnostic 2019-06-14 12:35:31 -04:00