Commit Graph

9 Commits

Author SHA1 Message Date
Pavel Yaskevich
f7b264583d [Diagnostic] Don't fix partial mismatch for sub-types associated with optional conversion
If mismatch detected by `repairFailures` is related to a complex
wrapped value of optional type formed from optional-to-optional
or value-to-optional conversion let's not try to fix it directly
but let `simplifyRestrictedConstraintImpl` record a top-level fix
for more context.

Resolves: rdar://problem/59703585
2020-03-03 00:24:34 -08:00
Pavel Yaskevich
0cd44a83a7 [ConstraintSystem] Don't record general contextual mismatch if there are restrictions present
If there are any conversion restrictions present while trying to repair
failures related to contextual type, let's give `simplifyRestrictedConstraintImpl`
a chance to run and fix the problem.

Resolves: rdar://problem/59773317
2020-03-02 11:07:31 -08:00
Pavel Yaskevich
62b2da803c [ConstraintSystem] Improve @escaping parameter diagnostics
Detect difference in escapiness while matching function types
in the solver and record a fix that suggests to add @escaping
attribute where appropriate.

Also emit a tailored diagnostic when non-escaping parameter
type is used as a type of a generic parameter.
2019-05-02 00:40:30 -07:00
Slava Pestov
31ab93b82c Remove Swift 3-specific tests 2018-07-02 21:14:22 -07:00
Pavel Yaskevich
79b14c8916 [Sema] Improve diagnostics for non-escaping function types
Allow certain bindings and conversions involving non-escaping
function types to succeed in "diagnostic" mode to gather fixes
and diagnose such problems better, expecially related to
conversions to 'Any' and generic parameters.

Resolves: rdar://problem/38648760
2018-03-20 17:57:03 -07:00
Mark Lacey
cb674efaa4 Fixes for uses of noescape functions.
Disallow noescape functions from being inferred as escaping functions,
or passed as Any.

Fixes rdar://problem/24097075.
2018-03-18 22:01:55 -07:00
Pavel Yaskevich
66e13bcc85 [ConstraintSolver] Avoid unnecessarily increasing score when matching function types
Remove function-to-function type match score increase, which should only
happen contextually in presence of other restrictions, this used to fix
the case related to matching of arrays of functions with and w/e `throws`
as function parameters which used to be ambigious, and now handled by
collection-upcast conversion score.

Resolves: rdar://problem/35142121
2017-10-31 23:14:35 -07:00
Slava Pestov
06bd16c071 Sema: Fix another SE-0110 issue
The formal type of methods should be (Type) -> (Args...) -> (),
not Type -> (Args...) -> ().

This only matters in Swift 4 mode, where it was preventing the
newly-added test case from type checking.

Fixes <rdar://problem/31725325>.
2017-05-09 22:27:52 -07:00
Slava Pestov
8a1062dedd Sema: Try harder to preserve ParenType sugar when when performing upcasts
This fixes a case where we would allow a function conversion
in Swift 3 mode, but not in Swift 4. We were incorrectly stripping
off ParenTypes, which was OK in Swift 3, but with the implementation
of SE-0110 this resulted in a type mismatch.

Fixes <rdar://problem/31969605>.
2017-05-07 22:03:17 -07:00