Commit Graph

483 Commits

Author SHA1 Message Date
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
Sam Lazarus
0fa9ec3c22 Diagnostics: Changed tuple mismatch fix constraint generation to use matchTupleTypes 2019-08-02 13:52:24 -04: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
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
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
760d78c48d [Diagnostics] NFC: Extract type var -> generic param type restoration into a function 2019-07-16 12:55:47 -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
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
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
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
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
swift-ci
a1b281135a Merge pull request #25359 from hamishknight/five-minute-argument 2019-06-18 10:36:10 -07:00
Sam Lazarus
1701ea1adc Sema: Changed GenericArgumentsMismatch to use trailing objects 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
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
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
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
Pavel Yaskevich
c30845fa74 [ConstraintSystem] Detect and diagnose missing generic arguments
Introduce a fix to detect and diagnose situations when omitted
generic arguments couldn't be deduced by the solver based on
the enclosing context.

Example:

```swift
struct S<T> {
}

_ = S() // There is not enough context to deduce `T`
```

Resolves: rdar://problem/51203824
2019-05-29 16:39:41 -07:00
Pavel Yaskevich
44536fe2e0 [Diagnostics] Improve missing generic argument diagnostic notes
Emit separate notes for generic parameters found in operator, initializer
and function declarations. As well as clarify types of `declared in type`
note.
2019-05-29 10:26:05 -07:00
Pavel Yaskevich
e97955e7c7 [Diagnostics] Add a new diagnostic for missing generic arguments 2019-05-29 10:26:04 -07:00
Pavel Yaskevich
866e8f51fa [Diagnostics] Let invalid member ref carry member declaration instead of looking it up
All places where `invalid member ref` fix/diagnostic is used already
have a reference to the potential member choice declaration, which
diagnostic could take advantage of.
2019-05-21 11:49:03 -07:00
Pavel Yaskevich
48688241c3 [Diagnostics] Add known member declaration to invalid member ref diagnostic
This is useful for `CSDiag` when it detects that all
overload choices have the same problem. Since there
are going to be no solutions, choice declaration could
be supplied to `invalid ref` diagnostic directly.

Resolves: rdar://problem/50467583
Resolves: rdar://problem/50682022
Resolves: rdar://problem/50909555
2019-05-20 17:29:15 -07:00
Pavel Yaskevich
1499811add [Diagnostics] Fix incorrect metatype check which leads to crashes
Incorrect member reference diagnostic tailed for protocols
should cover existential metatypes as well.

rdar://problem/50679161
2019-05-20 12:52:53 -07:00
Pavel Yaskevich
ada6ab599a [ConstraintSystem] Use missing conformance fix to diagnose contextual failures
Extend use of `missing protocol conformance` fix to cover contextual
failures, such as:

- Assignment mismatches, where destination requires source to conform
  to certain protocol (or protocol composition);
- Incorrect returns where returned type doesn't conform to the
  protocol specified in the signature.
2019-05-17 12:53:22 -07:00
Pavel Yaskevich
ace86e81cf [ConstraintSystem] Switch "missing conformance" fix/diagnostic to use protocol type
Switch type allows "missing conformance" diagnostic to be
used not only for protocols by for protocol compositions as well.
2019-05-17 12:52:15 -07:00
Pavel Yaskevich
d4e8d583ae Revert "[ConstraintSystem] Use missing conformance fix to diagnose contextual failures" 2019-05-17 12:45:55 -07:00
Pavel Yaskevich
5fb3a8ba30 Merge pull request #24754 from xedin/diag-missing-contextual-conformances
[ConstraintSystem] Use `missing conformance` fix to diagnose contextual failures
2019-05-17 11:40:49 -07:00
Hamish Knight
894a1e50bf [CS] Consolidate logic forming locators to callees
This commit adds `ConstraintSystem::getCalleeLocator`, which forms a
locator that describes the callee of a given expression. This function
is then used to replace various places where this logic is duplicated.

This commit also changes the conditions under which a ConstructorMember
callee locator is formed. Previously it was formed for a CallExpr with a
TypeExpr function expr. However, now such a locator is formed if the
function expr is of AnyMetatypeType. This allows it to be more lenient
with invalid code, as well as work with DotSelfExpr.

Resolves SR-10694.
2019-05-16 12:07:40 +01:00
Pavel Yaskevich
577e6291a6 [ConstraintSystem] Use missing conformance fix to diagnose contextual failures
Extend use of `missing protocol conformance` fix to cover contextual
failures, such as:

- Assignment mismatches, where destination requires source to conform
  to certain protocol (or protocol composition);
- Incorrect returns where returned type doesn't conform to the
  protocol specified in the signature.
2019-05-15 14:49:17 -07:00
Pavel Yaskevich
a23bc3e189 [ConstraintSystem] Switch "missing conformance" fix/diagnostic to use protocol type
Switch type allows "missing conformance" diagnostic to be
used not only for protocols by for protocol compositions as well.
2019-05-15 14:21:37 -07:00