[CSSimplify] Detect and diagnose conformance failures related to AnyHashable conversion

Failure of an argument to AnyHashable parameter to conform to Hashable
protocol should be detected in `simplifyConformsToConstraint` and fixed
there.

Doing so requires impact assessment adjustment because regular conformance
requirements have default impact of 1, this is going to have argument
impact of 2 not avoid clashing with other failures.
This commit is contained in:
Pavel Yaskevich
2023-05-08 16:16:30 -07:00
parent 143b0160d2
commit 5f8e3eb6f6
2 changed files with 35 additions and 3 deletions

View File

@@ -661,10 +661,7 @@ example21890157.property = "confusing" // expected-error {{value of optional ty
struct UnaryOp {}
_ = -UnaryOp() // expected-error {{unary operator '-' cannot be applied to an operand of type 'UnaryOp'}}
// expected-note@-1 {{overloads for '-' exist with these partially matching parameter lists: (Double), (Float)}}
// <rdar://problem/23433271> Swift compiler segfault in failure diagnosis
func f23433271(_ x : UnsafePointer<Int>) {}
@@ -1551,3 +1548,12 @@ func rdar86611718(list: [Int]) {
String(list.count())
// expected-error@-1 {{cannot call value of non-function type 'Int'}}
}
// rdar://108977234 - failed to produce diagnostic when argument to AnyHashable parameter doesn't conform to Hashable protocol
do {
struct NonHashable {}
func test(result: inout [AnyHashable], value: NonHashable) {
result.append(value) // expected-error {{argument type 'NonHashable' does not conform to expected type 'Hashable'}}
}
}