Commit Graph

29 Commits

Author SHA1 Message Date
Pavel Yaskevich
f032b9c57c [CSFix] Attempt to replace .subscript(...) with subscript operator
If there are no members named "subscript" available, let's try to
replace it with subscript operator with might be what was intended.
2019-01-08 12:06:40 -08:00
Pavel Yaskevich
9818b55266 [CSDiagnostics] Add MissingCall failure
It's used to diagnose cases when function/method are used as
a property instead of being called.
2018-12-11 18:44:41 -08:00
Pavel Yaskevich
f086d41094 [CSFix] Call a function/member which is incorrectly used as a property
If the base type for the member lookup is a function, let's try to
use its result type as a base instead, maybe there is just a call
missing.
2018-12-11 16:58:43 -08:00
Pavel Yaskevich
202234f325 [CSDiagnostics] Diagnose invalid optional unwrap via fixes
Detect and fix situations when (force) unwrap is used on
a non-optional type, this helps to diagnose invalid unwraps
precisely and provide fix-its.

Resolves: [SR-8977](https://bugs.swift.org/browse/SR-8977)
Resolves: rdar://problem/45218255
2018-12-05 08:10:07 -08:00
Pavel Yaskevich
e043e2b2b3 [CSFix] Add a fix to remove invalid optional unwrap
If the base type is not optional, trying to unwrap it is
incorrect. Introduce a fix to make it look like base was
an optional type which leads solver to move forward
towards possible solution.
2018-12-04 18:40:04 -08:00
Pavel Yaskevich
07e5d54855 [CSDiagnostics] Add custom diagnostic for invalid @autoclosure forwarding
Suggest to add `()` (form a call) to correctly forward argument function
originated from `@autoclosure` parameter to function parameter itself
marked as `@autoclosure`.
2018-11-21 12:17:25 -08:00
Pavel Yaskevich
f9dae942f8 [CSFix] Add fix to track invalid @autoclosure forwarding 2018-11-21 12:17:25 -08:00
Pavel Yaskevich
66a79301b4 [CSDiagnostics] Diagnose contextual closure result mismatches via fixes
Let's keep track of type mismatch between type deduced
for the body of the closure vs. what is requested
contextually, it makes it much easier to diagnose
problems like:

```swift
func foo(_: () -> Int) {}
foo { "hello" }
```

Because we can pin-point problematic area of the source
when the rest of the system is consistent.

Resolves: rdar://problem/40537960
2018-11-07 14:28:50 -08:00
Pavel Yaskevich
81afed9700 [Diagnostics] Add asNote flag to ConstraintFix 2018-08-24 11:20:49 -07:00
Pavel Yaskevich
fa45b3b675 [Diagnostics] NFC: ConstraintFix::{print, dump} no longer need SourceManager passed-in
Since `ConstraintFix` references `ConstraintSystem` directly now,
we can get `SourceManager` from `ASTContext` associated with that
`ConstraintSystem` instead of passing it in every time.
2018-08-22 00:15:24 -07:00
Pavel Yaskevich
3eeab38606 [Diagnostics] NFC: Attach ConstraintSystem to ConstraintFix directly
There is no longer any reason to attach solution to `ConstraintFix`
because solution applied to the constraint system before any of the
related fixes are diagnosed, so instead let's attach `ConstraintSystem`
to `ConstraintFix` directly, because it would have all of the required
information.
2018-08-22 00:07:34 -07:00
Pavel Yaskevich
cc436e313a [Diagnostics] Decouple FailureDiagnostic from Solution 2018-08-21 23:45:17 -07:00
Pavel Yaskevich
16dfa6be72 [Diagnostics] Add superclass requirement fix/diagnostic
Extend new requirement failure diagnostics by adding "superclass"
generic requirement failures.
2018-08-21 00:39:21 -07:00
Pavel Yaskevich
3cc613497c [ConstraintSystem] Add same-type requirement fix/diagnostic
Extend new requirement failure diagnostics by adding "same-type"
generic requirement failures.
2018-08-18 13:05:32 -07:00
gregomni
eaf8c6d232 Conflict resolution and conversion to ConstraintFix class 2018-08-16 18:21:43 -07:00
Pavel Yaskevich
dd9c28b456 [ConstraintSystem] Add proper printing (name + locator) for fixes 2018-08-13 18:10:50 -07:00
Pavel Yaskevich
1983431591 [ConstraintSystem] Make it so re-labeling fix holds correct labels as trailing objects 2018-08-13 18:09:01 -07:00
Pavel Yaskevich
8f9631bf6c [ConstraintSystem] Add unwrap optional base with optional result fix kind 2018-08-13 01:23:28 -07:00
Pavel Yaskevich
c3ac038a66 [ConstraintSystem] Add anchor expression accessor to ConstraintFix 2018-08-13 01:23:28 -07:00
Pavel Yaskevich
c005e0084d [ConstraintSystem] Allocate constraint fixes using constraint system
Since constraint fix life span is tightly coupled with particular
constraint system, it makes sense to allocate fixes using the same
allocator as used for constraints.
2018-08-13 01:23:28 -07:00
Pavel Yaskevich
df9614177a [ConstraintSystem] Add 'missing conformance' fix 2018-08-13 01:23:28 -07:00
Pavel Yaskevich
8221354ce5 [ConstraintSystem] Add 're-label arguments' fix 2018-08-13 01:23:27 -07:00
Pavel Yaskevich
a1651f9b3c [ConstraintSystem] Add 'mark explicitly @escaping' fix 2018-08-13 01:23:27 -07:00
Pavel Yaskevich
2ced603bc3 [ConstraintSystem] Add 'replace as with as!' fix 2018-08-13 01:23:27 -07:00
Pavel Yaskevich
48c4eb4539 [ConstraintSystem] Add 'add address-of' fix 2018-08-13 01:23:27 -07:00
Pavel Yaskevich
a17c1cb409 [ConstraintSystem] Add 'unwrap optional base' fix 2018-08-13 01:23:27 -07:00
Pavel Yaskevich
6fc5ce36fd [ConstraintSystem] Add 'force optional' fix 2018-08-13 01:23:27 -07:00
Pavel Yaskevich
428e9b5926 [ConstraintSystem] Add 'force downcast' fix 2018-08-13 01:23:27 -07:00
Pavel Yaskevich
ac0509729a [ConstraintSystem] Introduce ConstraintFix abstraction
A fix is related to one of the constraints through its locator,
and contains information required to "fix" a failure associated with
given constraint, each of the fixes also includes diagnostic.
2018-08-13 01:23:27 -07:00