File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -128,8 +128,14 @@ static bool isSupportedDisjunction(Constraint *disjunction) {
128128 if (choice->getKind () != ConstraintKind::BindOverload)
129129 return false ;
130130
131- if (auto *decl = getOverloadChoiceDecl (choice))
131+ if (auto *decl = getOverloadChoiceDecl (choice)) {
132+ // Cannot optimize declarations that return IUO because
133+ // they form a disjunction over a result type once attempted.
134+ if (decl->isImplicitlyUnwrappedOptional ())
135+ return false ;
136+
132137 return decl->getInterfaceType ()->is <FunctionType>();
138+ }
133139
134140 return false ;
135141 });
Original file line number Diff line number Diff line change 1+ // RUN: %target-typecheck-verify-swift -target %target-swift-5.1-abi-triple
2+
3+ func test1( v: Int ! ) -> [ Any ] ! { nil }
4+ // This is important because it defeats old solver hack that
5+ // checked the number of matching overloads purely based on
6+ // how many parameters there are.
7+ func test1( v: Int ! ) async throws -> [ Int ] ! { nil }
8+ func test1( v: Int ! , other: String = " " ) throws -> [ Int ] { [ ] }
9+
10+ func test2( v: Int ! ) -> [ Any ] ! { nil }
11+ func test2( v: Int ! , other: String = " " ) throws -> [ Int ] { [ ] }
12+
13+ func performTest( v: Int ! ) {
14+ guard let _ = test1 ( v: v) as? [ Int ] else { // Ok
15+ return
16+ }
17+
18+ guard let _ = test2 ( v: v) as? [ Int ] else {
19+ // expected-error@-1 {{call can throw, but it is not marked with 'try' and the error is not handled}}
20+ // expected-warning@-2 {{conditional cast from '[Int]' to '[Int]' always succeeds}}
21+ return
22+ }
23+ }
You can’t perform that action at this time.
0 commit comments