[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.
This commit is contained in:
Pavel Yaskevich
2024-09-09 13:10:33 -07:00
parent 854298ab3b
commit 55b8d9538d
27 changed files with 105 additions and 139 deletions

View File

@@ -304,12 +304,12 @@ func test_array_to_pointer_conversion() {
void_ptr_func(&x${Size}) // Ok
const_void_ptr_func(x${Size}) // Ok
opt_void_ptr_func(x${Size})
// expected-error@-1 {{cannot convert value of type '[Int${Size}]' to expected argument type 'UnsafeMutableRawPointer?'}}
// expected-error@-1 {{cannot convert value of type '[Int${Size}]' to expected argument type 'UnsafeMutableRawPointer'}}
char_ptr_func(x${Size})
// expected-error@-1 {{cannot convert value of type '[Int${Size}]' to expected argument type 'UnsafeMutablePointer<CChar>' (aka 'UnsafeMutablePointer<Int8>')}}
opt_char_ptr_func(x${Size})
// expected-error@-1 {{cannot convert value of type '[Int${Size}]' to expected argument type 'UnsafeMutablePointer<CChar>?' (aka 'Optional<UnsafeMutablePointer<Int8>>')}}
// expected-error@-1 {{cannot convert value of type '[Int${Size}]' to expected argument type 'UnsafeMutablePointer<CChar>' (aka 'UnsafeMutablePointer<Int8>')}}
const_char_ptr_func(x${Size}) // Ok
const_opt_char_ptr_func(x${Size}) // Ok
@@ -320,9 +320,9 @@ func test_array_to_pointer_conversion() {
// expected-error@-1 {{cannot convert value of type '[Int${Size}]' to expected argument type 'UnsafeMutablePointer<UInt${Size}>'}}
opt_int_${Size}_ptr_func(x${Size})
// expected-error@-1 {{cannot convert value of type '[Int${Size}]' to expected argument type 'UnsafeMutablePointer<Int${Size}>?'}}
// expected-error@-1 {{cannot convert value of type '[Int${Size}]' to expected argument type 'UnsafeMutablePointer<Int${Size}>'}}
opt_uint_${Size}_ptr_func(x${Size})
// expected-error@-1 {{cannot convert value of type '[Int${Size}]' to expected argument type 'UnsafeMutablePointer<UInt${Size}>?'}}
// expected-error@-1 {{cannot convert value of type '[Int${Size}]' to expected argument type 'UnsafeMutablePointer<UInt${Size}>'}}
const_int_${Size}_ptr_func(x${Size}) // OK
const_uint_${Size}_ptr_func(x${Size}) // OK