Commit Graph

15 Commits

Author SHA1 Message Date
Anthony Latsis
2cd90bdd69 AST: Quote attributes more consistently in DiagnosticsSema.def 2025-04-22 18:23:36 +01:00
Pavel Yaskevich
55b8d9538d [CSSimplify] Rework how/when mismatches between optional types are fixed
- Don't attempt to insert fixes if there are restrictions present, they'd inform the failures.

  Inserting fixes too early doesn't help the solver because restriction matching logic would
  record the same fixes.

- Adjust impact of the fixes.

  Optional conversions shouldn't impact the score in any way because
  they are not the source of the issue.

- Look through one level of optional when failure is related to optional injection.

  The diagnostic is going to be about underlying type, so there is no reason to print
  optional on right-hand side.
2024-09-10 10:35:05 -07:00
Anthony Latsis
7fc8377e1c Gardening: Migrate test suite to GH issues: Constraints (1/5) 2022-08-17 15:21:51 +03:00
Luciano Almeida
5802f2ebfc Add regression tests to SR-14869 2021-07-05 20:05:15 -03:00
Luciano Almeida
0519dd7cab [Sema] Adjustments on implementation and diagnostic message for SR-14720 2021-06-30 06:39:04 -03:00
Luciano Almeida
51ee1de6f9 [Sema] Adjust escapeness function parameter diagnostic to use decl description 2021-06-30 06:39:04 -03:00
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