File tree Expand file tree Collapse file tree 2 files changed +61
-0
lines changed
validation-test/Sema/type_checker_crashers_fixed Expand file tree Collapse file tree 2 files changed +61
-0
lines changed Original file line number Diff line number Diff line change @@ -4862,6 +4862,27 @@ bool ConstraintSystem::repairFailures(
48624862 case ConstraintLocator::ApplyArgToParam: {
48634863 auto loc = getConstraintLocator(locator);
48644864
4865+ // If this type mismatch is associated with a synthesized argument,
4866+ // let's just ignore it because the main problem is the absence of
4867+ // the argument.
4868+ if (auto applyLoc = elt.getAs<LocatorPathElt::ApplyArgToParam>()) {
4869+ if (auto *argumentList = getArgumentList(loc)) {
4870+ // This is either synthesized argument or a default value.
4871+ if (applyLoc->getArgIdx() >= argumentList->size()) {
4872+ auto *calleeLoc = getCalleeLocator(loc);
4873+ auto overload = findSelectedOverloadFor(calleeLoc);
4874+ // If this cannot be a default value matching, let's ignore.
4875+ if (!(overload && overload->choice.isDecl()))
4876+ return true;
4877+
4878+ if (!getParameterList(overload->choice.getDecl())
4879+ ->get(applyLoc->getParamIdx())
4880+ ->getTypeOfDefaultExpr())
4881+ return true;
4882+ }
4883+ }
4884+ }
4885+
48654886 // Don't attempt to fix an argument being passed to a
48664887 // _OptionalNilComparisonType parameter. Such an overload should only take
48674888 // effect when a nil literal is used in valid code, and doesn't offer any
Original file line number Diff line number Diff line change 1+ // RUN: %target-typecheck-verify-swift
2+
3+ public enum APIError {
4+ case unknown
5+ case message
6+ }
7+
8+ struct NewItemResponse { }
9+
10+ protocol Publisher {
11+ associatedtype Output // expected-note {{protocol requires nested type 'Output'; do you want to add it?}}
12+ }
13+
14+ extension Publisher {
15+ func sink( receiveCompletion: @escaping ( ( Int ) -> Void ) , receiveValue: @escaping ( ( Self . Output ) -> Void ) ) { fatalError ( ) }
16+ // expected-note@-1 {{'sink(receiveCompletion:receiveValue:)' declared here}}
17+ }
18+
19+ func fetchFile< T> ( name: String ) -> MyPublisher < T , APIError > {
20+ fatalError ( )
21+ }
22+
23+ struct ReplaceError < Upstream> : Publisher { // expected-error {{type 'ReplaceError<Upstream>' does not conform to protocol 'Publisher'}}
24+ typealias Output = Upstream . Output // expected-error {{'Output' is not a member type of type 'Upstream'}}
25+ typealias Failure = Never
26+ }
27+
28+ struct MyPublisher < Output, Failure> : Publisher {
29+ init < P> ( _ publisher: P ) { fatalError ( ) }
30+
31+ func replaceError( with output: Self . Output ) -> ReplaceError < Self > { fatalError ( ) }
32+ }
33+
34+ public class Items {
35+ func test( ) {
36+ _ = fetchFile ( name: " abc " )
37+ . replaceError ( with: NewItemResponse ( ) )
38+ . sink { [ weak self] items in } // expected-error {{missing argument for parameter 'receiveValue' in call}}
39+ }
40+ }
You can’t perform that action at this time.
0 commit comments