Commit Graph

1251 Commits

Author SHA1 Message Date
Pavel Yaskevich
a4d7cbd794 [Diagnostics] Extend contextual failure diagnostic to support all basic mismatches 2019-08-13 11:55:08 -07:00
Pavel Yaskevich
075e92b182 Merge pull request #26576 from LucianoPAlmeida/SR-10597-name-lookup-failure-diagnostics
SR-10597 KeyPath dynamic member lookup
2019-08-12 18:00:45 -07:00
Luciano Almeida
1d910fb2bc Fix identation 2019-08-12 19:28:44 -03:00
Luciano Almeida
55907fbd0f Adding no corrections diagnostic for dynamic member 2019-08-12 19:25:38 -03:00
Luciano Almeida
a7b5f714e4 Apply diagnostic message suggestion 2019-08-09 23:47:42 -03:00
Luciano Almeida
df14698efd Merge branch 'SR-10597-name-lookup-failure-diagnostics' of https://github.com/LucianoPAlmeida/swift into SR-10597-name-lookup-failure-diagnostics 2019-08-09 23:39:30 -03:00
Luciano Almeida
6d40a96c0a Fixing identation 2019-08-09 23:39:25 -03:00
Luciano Almeida
a5db6bf0a5 Apply suggestions from code review
Co-Authored-By: Xiaodi Wu <xiaodi.wu@gmail.com>
2019-08-09 23:37:00 -03:00
Pavel Yaskevich
385fb0c665 [Diagnostics] Make force downcast fix contextual and move it to repairFailures
This way it covers a lot more ground and doesn't conflict with
other fixes.

Another notable change is related to check for IUO associated
with source type, that covers cases like:

```swift
func foo(_ v: NSString!) -> String {
  return v
}
```

Instead of general conversion failure check for IUO enables solver
to introduce force downcast fix.
2019-08-09 01:09:52 -07:00
Luciano Almeida
d55e1f6055 Adding diagnostic to fix SR-10597 2019-08-08 23:33:43 -03:00
Pavel Yaskevich
8ac2ef8611 [Diagnostics] Extend generic argument mismatch to cover [T] to Unsafe*Pointer<T> conversions
Example:

```swift
func foo(_ x: UnsafePointer<Int>) {}
var arr: [Float] = [0, 1, 2]
foo(&arr) // Cannot convert [Float] to UnsafePointer<Int> because of Float vs. Int
```
2019-08-07 13:16:20 -07:00
Pavel Yaskevich
a34fe9ae55 [Diagnostics] Extend missing & diagnostic to cover pointer conversions
Example:

```swift
func foo(_: UnsafePointer<Int>) {}

var x: Int = 0
foo(x) <- should suggest adding `&`
```
2019-08-06 17:52:24 -07:00
Holly Borla
caeb2a44a8 Merge pull request #26470 from hborla/autoclosure-pointer-conversion-diagnostic
[Diagnostics] Improve the diagnostic for invalid pointer conversion for an autoclosure result type.
2019-08-05 10:06:15 -07:00
Pavel Yaskevich
b148ea0a41 Merge pull request #26444 from xedin/diag-missing-call-with-defaults
[CSDiagnostics] Teach `missing explicit call` fix to account for defa…
2019-08-02 16:36:40 -07:00
Holly Borla
edcf4055d2 [Diagnostics] Use ContextualFailure and ContextualMistatch as base classes
for `AutoClosurePointerConversionFailure` and `AllowAutoClosurePointerConversion`
respectively.
2019-08-02 15:23:25 -07:00
Holly Borla
e76f5f1d0b [Diagnostics] Improve the diagnostic for invalid pointer conversion for an autoclosure result type.
Add constraint fix `AllowAutoClosurePointerConversion` and corresponding diagnostic
`AutoClosurePointerConversionFailure`. When we discover that we're trying to do an
inout-to-pointer conversion in `matchTypes`, add the constraint fix, which tries to do the
conversion as if the pointer type is a regular function argument.
2019-08-02 14:16:06 -07:00
Pavel Yaskevich
2cfcdf49dc Merge pull request #26391 from sl/port-tuple-assignment-diagnostic
[Diagnostics] Ported tuple mismatch diagnostic to new diagnostic framework
2019-08-02 13:22:52 -07:00
Slava Pestov
d3f65e7b4b AST: Remove SubscriptDecl::isSettable() 2019-07-31 21:26:02 -04:00
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
Pavel Yaskevich
5744becc34 Merge pull request #26417 from theblixguy/fix/SR-11236
[CSDiagnostics] Fix a crasher in MissingGenericArgumentsFailure
2019-07-30 16:08:45 -07:00
Suyash Srijan
2339b5f9bd [CSDiagnostics] Move check inside getDeclContext() 2019-07-30 20:27:25 +01:00
Suyash Srijan
e50050b0fb [CSDiagnostics] Don't crash if we don't have access to the generic param's decl 2019-07-30 19:47:27 +01:00
Sam Lazarus
a3b56c2790 Diagnostics: Ported tuple mismatch diagnostic to new diagnostic framework 2019-07-29 13:45:08 -04:00
Pavel Yaskevich
68d25a2f5d Merge pull request #26376 from xedin/rdar-53238058
[CSFix] Delay `missing unwrap` locator simplification until diagnostic
2019-07-29 09:25:43 -07:00
Pavel Yaskevich
795a84ae6e [CSFix] Delay missing unwrap locator simplification until diagnostic
Instead of keeping two locators in the fix let's store only the
original locator and simplify it later in process of emitting
a diagnostic. That helps to avoid some duplicate work as well
as makes sure that locators supplied to the diagnostic always
have an anchor.

Resolves: rdar://problem/53344815
2019-07-28 21:09:44 -07:00
Pavel Yaskevich
0a6b8106d6 [Diagnostics] NFC: Store requirement types directly in ReqirementFailure
Since all of the specific diagnostics which constitute requirement
failure now operate on types, their interfaces could be simplified
and associated requirement types could be stored in RequirementFailure.
2019-07-26 10:49:45 -07:00
Pavel Yaskevich
1b4f9c33eb [Diagnostic] In no exact match cases diagnose labeling mismatch as a note
Each candidate with incorrect labels (but everything else lined up)
gets a note on its declarationm which says what is expected and what
has been given.
2019-07-25 14:49:52 -07:00
Doug Gregor
0df29877ed [SE-0258] Fix source locations for implicitly-generated initializer calls.
Fixes rdar://problem/52969503, a crash due to missing source location
information in implicitly-generated calls.
2019-07-19 10:15:28 -07: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
3697bd55ea [Diagnostics] While restoring generic parameter types run substitution callback once per parameter 2019-07-16 16:35:07 -07:00
Pavel Yaskevich
9969582cc3 [Diagnostics] Adjust single parameter splat message to prefix substitutions with with 2019-07-16 12:58:10 -07:00
Pavel Yaskevich
760d78c48d [Diagnostics] NFC: Extract type var -> generic param type restoration into a function 2019-07-16 12:55:47 -07:00
Pavel Yaskevich
0dc863313c [Diagnostics] Extend single parameter splat diagnostic to report substitutions 2019-07-16 11:06:42 -07:00
Pavel Yaskevich
9550d10037 [Diagnostics] Add a diagnostic for single parameter tuple splat
Diagnose situation when a single "tuple" parameter is given N arguments e.g.

```swift
func foo<T>(_ x: (T, Bool)) {}
foo(1, false) // foo exptects a single argument of tuple type `(1, false)`
```
2019-07-16 11:06:42 -07:00
Pavel Yaskevich
78e2e93c6b [Diagnostics] Add a diagnostic for invalid mutating member ref on r-value base 2019-07-09 00:25:30 -07:00
Pavel Yaskevich
f0c39aa15c Merge pull request #25952 from xedin/diag-base-unwrap-for-member
[Diagnostics] NFC: Move logic related to member ref on optional witho…
2019-07-02 18:23:35 -07:00
Pavel Yaskevich
a2652ea8e1 [Diagnostics] NFC: Move logic related to member ref on optional without unwrap to new framework
Since there is already a diagnostic for this `MemberAccessOnOptionalBaseFailure`
it should incorporate all related diagnostic logic and could be used from CSDiag.
2019-07-02 16:00:36 -07:00
Pavel Yaskevich
e7b73636ef [Diagnostics] Adjust diagnostic for subscript references on type
Instead of `value of X.Type` let's say `type of X` for subscript
references on metatype.
2019-07-02 15:07:28 -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
Greg Titus
76ed0a1aad Merge pull request #25892 from gregomni/sr-10987
[Diagnostics, Crasher] Handle subscript misuse without a parent ApplyExpr
2019-06-29 20:34:35 -07:00
gregomni
0369064792 Correctly handle subscript misuse without a parent apply expr. SR-10987 2019-06-29 18:24:17 -07: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
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
Doug Gregor
446d0b3953 [SE-0258] Rename backing storage property to _foo.
In anticipation of upcoming changes to the property wrapper proposal,
rename the backing storage for a wrapped property to "foo", unconditionally.
2019-06-26 07:39:01 -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
2e31ca6daf [ConstraintSystem] Use getConstraintLocator directly 2019-06-24 22:35:34 +01:00