Commit Graph

1230 Commits

Author SHA1 Message Date
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
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
Pavel Yaskevich
ef96e8904f Merge pull request #25638 from xedin/rdar-51576862
[Diagnostics] Don't suggest argument destructuring fix-it if closu…
2019-06-21 12:32:44 -07: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
Pavel Yaskevich
ebe0e42461 [Diagnostics] Don't suggest argument destructuring fix-it if closure is malformed
If closure expression is malformed don't try to suggest a fix-it
about destructuring, because there is no way to figure out where
it would actually go in the source.

Resolves: rdar://problem/51576862
2019-06-20 12:35:26 -07:00
Jordan Rose
9e471e4124 Don't offer a fix-it to convert to a 'some' type (#25619)
There's no way to spell an opaque type in a cast, and that means
there's no way to force the conversion today (even if you know the
types are dynamically the same).

Part of rdar://problem/50346954
2019-06-19 19:17:32 -07:00
Pavel Yaskevich
379d88cb12 Merge pull request #25575 from xedin/rdar-51784793
[Diagnostics] Guard against missing parent initializer in missing unw…
2019-06-19 10:54:55 -07:00
Pavel Yaskevich
fca8106f95 [Diagnostics] Guard against missing parent initializer in missing unwrap diagnostic
While trying to diagnose missing optional unwrap for single use
vars guard against it not having a parent initializer.

Unfortunately there is no test-case for this but we have
received multiple reports about `offerDefaultValueUnwrapFixIt`
crashing trying to access locator on passed in `expr`.

Resolves: rdar://problem/51784793
2019-06-18 14:23:35 -07:00
swift-ci
a1b281135a Merge pull request #25359 from hamishknight/five-minute-argument 2019-06-18 10:36:10 -07:00
Sam Lazarus
122a68c217 Sema: Change generic argument mismatch diags to reuse existing ones 2019-06-14 12:35:32 -04:00
Sam Lazarus
0a7cdb8ded Sema: Handle CTP_SubscripAssignSource in GenericArgumentsMismatch::getDiagnosticFor 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
Sam Lazarus
7719b0f461 Sema: Add a more descriptive diagnostic for generic argument mismatches 2019-06-14 12:35:31 -04:00
Hamish Knight
e285916ab1 Simplify implementation of resolveInterfaceType a little 2019-06-13 21:58:44 +01:00
Hamish Knight
6c00d89a87 Assert when we expect to resolve a callee overload
This helps ensure we don't miss cases where `getChoiceFor` was meant to
return a callee overload but doesn't.
2019-06-13 13:51:51 +01:00
Hamish Knight
ebc2ff5bd5 Use getFunctionArgApplyInfo in missing-unwrap diagnostic 2019-06-13 13:51:50 +01:00
Hamish Knight
179c81d437 Use getFunctionArgApplyInfo in escaping diagnostics
This simplifies the implementation and fixes a compiler crasher.

Resolves SR-10811.
2019-06-13 13:51:49 +01:00
Hamish Knight
a84cdbc31e Add FailureDiagnostic::getFunctionArgApplyInfo
This allows failure diagnostics to retrieve information about the
application of an argument to a parameter at their locator.
2019-06-13 13:51:49 +01:00