Merge pull request #85451 from xedin/rdar-164201746

[CSOptimizer] Skip `??` if it's involved in optional chain with unres…
This commit is contained in:
Pavel Yaskevich
2025-11-12 17:30:51 -08:00
committed by GitHub
2 changed files with 41 additions and 0 deletions

View File

@@ -62,3 +62,12 @@ func test_no_incorrect_favoring(v: Int?, o: Int) {
sameType(s1, as: Int?.self)
sameType(s2, as: Int?.self)
}
extension Int {
func test() -> Int { 42 }
}
func test_optional_chaining(v: Int?, defaultV: Int) {
// CHECK: declref_expr type="(consuming Int?, @autoclosure () throws -> Int?) throws -> Int?" {{.*}} decl="Swift.(file).??
_ = (v ?? defaultV)?.test() // Ok (no warnings)
}