Commit Graph

1216 Commits

Author SHA1 Message Date
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
Hamish Knight
061ab18297 Add FailureDiagnostic::resolveInterfaceType
This allows a raw type to be resolved using generic parameters where
possible.
2019-06-13 13:51:49 +01:00
Doug Gregor
f2db4078a5 [Type checker] Collapse some duplicate code. Thanks, Pavel! 2019-06-11 17:34:44 -07:00
Doug Gregor
b634f594a0 [Function builders] Create a FailureDiagnostic for unhandled constructs. 2019-06-11 17:34:44 -07:00
Pavel Yaskevich
4bd5a1e4e1 [Diagnostics] Clarify requirement failure source when it's anchored at assignment
While trying to fetch owner type for generic requirement failures
anchored at assignment expression, use assignment source as an anchor
because that's where requirements come from - conversion from source
type to destination.

Resolves: rdar://problem/51587755
2019-06-11 11:59:46 -07:00
Pavel Yaskevich
6cdd981ee1 Merge pull request #25080 from owenv/improve_subscript_assignment_diag
[Diagnostics] Clarify diagnostic for failed type conversion in subscript assignment
2019-06-04 19:33:23 -07:00
Pavel Yaskevich
2f3809c5b3 Merge pull request #25149 from xedin/diag-missing-generic-args
[ConstraintSystem] Detect and diagnose missing generic arguments
2019-05-31 13:04:00 -07:00
Sam Lazarus
dc886ebe47 Sema: Move call to getRValueType inside of getBaseType 2019-05-30 19:07:25 -04:00
Sam Lazarus
147280ac3b Sema: Renamed invalid member ref on existential fix, and refactored inheritance 2019-05-30 18:48:58 -04:00
Sam Lazarus
0714dfe607 Sema: Convert to rvalue type before diagnosing protocol type member failure 2019-05-30 18:35:20 -04:00
Pavel Yaskevich
da799ebe51 [Diagnostics] Add a note if missing parameter is associated with generic subscript 2019-05-30 14:43:37 -07:00
Pavel Yaskevich
5e35c3e445 [Diagnostics] Replace CSDiag logic for diagnosing missing generic arguments with new diagnostic 2019-05-30 12:38:17 -07:00
Pavel Yaskevich
d0a956098b [Diagnostics] Move findArgumentLocations logic from fix to diagnostic 2019-05-30 11:27:20 -07:00
Sam Lazarus
6af91cc08d Sema: Removed unnecessary ValueDecl from AllowProtocolTypeMember
Additionally removed the same unnecessary ValueDecl from
AllowProtocolTypeMemberFailure allowing it to extend MissingMemberFailure.
2019-05-30 01:03:46 -04:00
Sam Lazarus
049ec0f851 Sema: Port member access on existentials diagnostic to new diagnostic framework 2019-05-30 00:32:01 -04:00