Commit Graph

1230 Commits

Author SHA1 Message Date
Holly Borla
ea7c13e506 [Diagnostics] For now, don't diagnose layout requirement failures
in MissingConformanceFailure::diagnoseTypeCannotConform.
2019-10-18 14:00:18 -07:00
Holly Borla
0d95a84e91 [Diagnostics] Improve the error message for when a type fails to satisfy
`AnyObject` layout requirement.
2019-10-18 11:27:21 -07:00
Pavel Yaskevich
8d05192204 Merge pull request #27728 from xedin/port-extraneous-args
[Diagnostics] Diagnose extraneous argument(s) via fixes
2019-10-18 10:42:56 -07:00
Holly Borla
ec864fcd9c [ConstraintFix] Don't pass along the RequirementKind to the MissingConformance
constraint fix. Instead, get the kind from the locator.
2019-10-18 09:03:06 -07:00
Pavel Yaskevich
14d9011c2b Merge pull request #27759 from xedin/port-keypath-diags
[Diagnostics] Port more key path related failures to new framework
2019-10-18 01:02:43 -07:00
Holly Borla
f998349815 [Diagnostics] Add a tailored note for when the Wrapped type of an
optional satisfies a failed requirement.
2019-10-17 19:59:07 -07:00
Pavel Yaskevich
0d07cd87ac [ConstraintSystem] Detect and diagnose contextual mismatches in key path components 2019-10-17 13:52:00 -07:00
Robert Widmann
56b6e53dae Remove raw references to PatternBindingEntry APIs
Switch most callers to explicit indices.  The exceptions lie in things that needs to manipulate the parsed output directly including the Parser and components of the ASTScope.  These are included as friend class exceptions.
2019-10-17 13:31:14 -07:00
Holly Borla
ef0ecc41e5 [ConstraintSystem] Diagnose missing AnyObject conformance using
the MissingConformance constraint fix.
2019-10-16 20:38:00 -07:00
Luciano Almeida
d022c98e68 Returning false for unhandled expr in GenericArgumentsMismatchFailure 2019-10-16 22:55:04 -03:00
Pavel Yaskevich
d69a1a5eee [CSDiagnostics] Attach extra argument ambiguity note to the overload choice 2019-10-16 10:19:26 -07:00
Pavel Yaskevich
b214b8a2bf [Diagnostics] Introdduce multiple extraneous arguments diagnostic 2019-10-16 10:19:26 -07:00
Pavel Yaskevich
02688a9091 [Diagnostics] Tailored diagnostic for missing arguments in contextual conversion 2019-10-16 10:19:26 -07:00
Pavel Yaskevich
43f95a3e25 [Diagnostics] NFC: Adopt new getArgumentListExprFor API 2019-10-16 10:19:26 -07:00
Pavel Yaskevich
40ac874616 [Diagnostics] Diagnose extraneous arguments in a nullary call 2019-10-16 10:19:26 -07:00
Pavel Yaskevich
c97603f5d4 [CSDiagnostics] Diagnose extraneous arguments 2019-10-16 10:19:25 -07:00
Luciano Almeida
73dcc4b5e8 Merge branch 'master' of https://github.com/apple/swift into force-downcast-fix-explicit-coercion 2019-10-15 19:18:46 -03:00
Pavel Yaskevich
d90117bb8a [Diagnostics] Remove argument handling from conformance failures
Argument-to-Parameter mismatch handles conformance failures
related to arguments, so the logic in `MissingConformanceFailure`
which wasn't entirely correct is now completely obsolete.

Resolves: rdar://problem/56234611
2019-10-14 00:34:37 -07:00
Luciano Almeida
30ffe13cba Merge branch 'master' of https://github.com/apple/swift into force-downcast-fix-explicit-coercion 2019-10-13 11:09:37 -03:00
Luciano Almeida
171d6ec87d Adjusting tests under test/Constraints/bridging-nsnumber-and-nsvalue.swift.gyb 2019-10-13 00:42:22 -03:00
Luciano Almeida
d896968d2c clang-format 2019-10-12 22:39:12 -03:00
Luciano Almeida
05cea3a7b7 Fix issue with dictionary_downcast tests 2019-10-12 16:49:36 -03:00
Luciano Almeida
f39ff88113 Initial implementation of moving the checks 2019-10-12 15:22:16 -03:00
Luciano Almeida
21c179d46f Removing fixed CoerceToCheckedCast constraint and letting repairFailures handle the diagnostics 2019-10-12 11:38:59 -03:00
Robert Widmann
7770564f1a Merge pull request #27624 from CodaFi/in-locale-parentis
Downgrade The TypeLoc in VarDecl to a TypeRepr
2019-10-11 14:53:10 -07:00
Pavel Yaskevich
8e16aa4b8d [Diagnostics] Extend argument-to-parameter mismatch note to cover inout parameters 2019-10-11 12:38:11 -07:00
Robert Widmann
2516089cb6 Clean up the pseudo-clone-constructor for ParamDecl 2019-10-11 11:51:50 -07:00
Robert Widmann
060cbb293f [NFC] Downgrade The TypeLoc in VarDecl to a TypeRepr
TypeCheckPattern used to splat the interface type into this, and
different parts of the compiler would check one or the other.   There is
now one source of truth: The interface type.  The type repr is now just
a signal that the user has written an explicit type annotation on
a parameter.  For variables, we will eventually be able to just grab
this information from the parent pattern.
2019-10-11 11:15:51 -07:00
Pavel Yaskevich
773ac24bc9 [ConstraintSystem] Detect and diagnose type mismatch failures of inout parameters
Currently absence of `subtyping` is the only problem detected and diagnosed specifically
for `inout` parameters, but there could be type mismatches in `inout` positions as well
 and we can use `argument-to-parameter mismatch fix to detect and diagnose them.
2019-10-10 17:06:13 -07:00
Pavel Yaskevich
51476cde58 [Diagnostics] Clarify tuple splat message when single parameter is generic parameter
Since it's hard to say whether tuple use is really intended, let's
add `did you mean to pass a tuple?` note to the error message.
2019-10-09 10:58:31 -07:00
Pavel Yaskevich
c62c2890f8 [Diagnostics] Fix fix-it location for labeled tuple splat
In situations like this:

```swift
func foo(x: (Int, Int) {}
foo(x: 0, 0)
```

Left paren to form a missing tuple should be placed after
the label because belongs to the parameter and not the tuple.
2019-10-08 18:12:17 -07:00
Luciano Almeida
12f98d7922 Merge branch 'master' into force-downcast-fix-explicit-coercion 2019-10-06 13:35:44 -03:00
Hamish Knight
e2096ae34d [CSDiagnostics] Tweak candidate note text for arg mismatch
Number the parameters starting at 1 in order to
match other diagnostics such as
diag::missing_argument_positional, and change the
text to make it explicit that we're referring to
the parameter position (rather than argument
position).
2019-10-03 15:26:31 -07:00
Hamish Knight
f03d210be9 Make getFunctionArgApplyInfo more lenient with CSDiag 2019-10-03 15:26:31 -07:00
Hamish Knight
ec45b24b63 Use hasAppliedSelf in getFunctionArgApplyInfo
`callee->hasCurriedSelf()` isn't the correct check
here when we have an argument mismatch for the
self parameter in a curried application.
2019-10-03 15:26:31 -07:00
Hamish Knight
b5a0d58dc0 Have ArgumentMismatchFailure store FunctionArgApplyInfo
And define members in order to allow the easy
access of relevant information about the failure.
2019-10-03 15:26:31 -07:00
Hamish Knight
c108dae5d9 [CSDiagnostics] Find argument lists for key path subscripts
This commit changes `getArgumentExprFor` to take
a ConstraintLocator argument from which to find
the argument list. This lets us properly handle
the case where we have a key path subscript
locator. In addition, this commit renames the
member to `getArgumentListExprFor` to make it
clear we're returning the argument list expression
rather than a single argument.

Resolves SR-11562.
2019-10-02 08:00:14 -07:00
Luciano Almeida
980ff05972 Add ForceDownCast fix for coercion expr to avoid fall-through into CSDiag 2019-10-01 20:25:15 -03:00
Robert Widmann
75670c1727 Merge pull request #27436 from CodaFi/signed-sealed-delivered
[NFC] Adopt TypeBase-isms for GenericSignature
2019-09-30 15:50:42 -07:00
Robert Widmann
5a8d0744c3 [NFC] Adopt TypeBase-isms for GenericSignature
Structurally prevent a number of common anti-patterns involving generic
signatures by separating the interface into GenericSignature and the
implementation into GenericSignatureBase.  In particular, this allows
the comparison operators to be deleted which forces callers to
canonicalize the signature or ask to compare pointers explicitly.
2019-09-30 14:04:36 -07:00
Hamish Knight
6d8b798789 [CS] Have isLastElement take a locator path elt class
This makes it consistent with `getLastElementAs`
and `castLastElementTo`.
2019-09-29 14:19:56 -07:00
Pavel Yaskevich
cc2c868522 [Diagnostics] Produce a tailored diagnostic for multiple missing arguments 2019-09-24 22:05:14 -07:00
Pavel Yaskevich
2120a31cf0 [Diagnostics] Correctly diagnose misplaced missing argument
Due to the fact that `matchCallArgument` can't and
doesn't take types into consideration while matching
arguments to parameters, when both arguments are
un-labeled, it's impossible to say which one is missing:

func foo(_: Int, _: String) {}
foo("")

In this case first argument is missing, but we end up with
two fixes - argument mismatch (for #1) and missing argument
(for #2), which is incorrect so it has to be handled specially.
2019-09-24 10:24:21 -07:00
Pavel Yaskevich
9406edc017 [Diagnostics] Tailored diagnostic for missing argument in property wrapper init 2019-09-23 13:00:37 -07:00
Pavel Yaskevich
60bcc94575 [Diagnostics] Implement single missing argument diagnosis
If call is missing a single argument we can provide a tailored
diagnostic and suggest a fix-it to add it at the appropriate
position.
2019-09-23 13:00:37 -07:00
Pavel Yaskevich
ee8c78eef5 [Diagnostics] Tailored diagnostic when single tuple used instead of N distinct arguments
Diagnose cases when instead of multiple distinct arguments
call got a single tuple argument with expected arity/types:

```swift
func foo(_: Int, _: Int) {}
foo((0, 1)) // expected 2 arguments, got 1 tuple with 2 elements
```
2019-09-23 13:00:37 -07:00
Pavel Yaskevich
881f521958 [Diagnostics] Diagnose missing arguments in relation to contextual type
Function type has fewer arguments than expected by context:

```swift
func foo() {}
let _: (Int) -> Void = foo // expected 1 argument, got 0
```
2019-09-23 13:00:37 -07:00
Pavel Yaskevich
e30612e8cd [Diagnostics] Diagnose missing argument(s) in argument positions
Diagnose situation when parameter type expects N arguments
but argument has `M` where `M` < `N`, e.g.:

```swift
func foo(_: (Int) -> Void) {}
func bar() -> Void {}

foo(bar) // expected 1 argument, got 0
```
2019-09-23 13:00:37 -07:00
Pavel Yaskevich
4203c2f9f3 [Diagnostics] Store synthesized arguments in missing arguments diagnostic
Since we are about to start diagnosing more than just closures,
we need information about what synthesized arguments look like.
2019-09-23 12:59:27 -07:00
Pavel Yaskevich
96598d8ebf Merge pull request #26207 from owenv/new-vararg-conversion-diag
[Diagnostics] Improve diagnostic when attempting to pass an Array to a variadic argument
2019-09-23 12:57:44 -07:00