[CSSimplify] Fix handling of holes by OptionalObject constraint

When "optional type" is a hole the simplification logic has to
simplify "object type" and mark all of its unresolved components
are potential holes, otherwise hole propagation won't work since
sometimes there is no other contextual information for such types
but "optional type".

Resolves: rdar://117871338
This commit is contained in:
Pavel Yaskevich
2023-11-03 10:13:09 -07:00
parent b74e4a2e20
commit 8b5e3848a1
2 changed files with 24 additions and 2 deletions

View File

@@ -150,3 +150,25 @@ func fallthrough_not_last(i: Int) {
break
}
}
// rdar://117871338 - incorrect diagnostic - type of expression is ambiguous when member is missing.
func test_invalid_optional_chaining() {
func test(_: (E) -> Void) {
}
enum E {
case a
case b
}
struct S {
var prop: E
}
test {
switch $0.prop? { // expected-error {{value of type 'E' has no member 'prop'}}
case .a: break
case .b: break
}
}
}