Skip to content

Commit e16e013

Browse files
authored
Merge pull request #37790 from xedin/rdar-78781552-5.5
[5.5][ConstraintSystem] Don't record a mismatch for synthesized arguments
2 parents c39c0a0 + 1609024 commit e16e013

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4460,6 +4460,10 @@ bool ConstraintSystem::repairFailures(
44604460
// a conversion to another function type, see `matchFunctionTypes`.
44614461
if (parentLoc->isForContextualType() ||
44624462
parentLoc->isLastElement<LocatorPathElt::ApplyArgToParam>()) {
4463+
// If either type has a placeholder, consider this fixed.
4464+
if (lhs->hasPlaceholder() || rhs->hasPlaceholder())
4465+
return true;
4466+
44634467
// If there is a fix associated with contextual conversion or
44644468
// a function type itself, let's ignore argument failure but
44654469
// increase a score.

test/Constraints/generics.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,3 +874,22 @@ func rdar78623338() {
874874
// expected-note@-1 {{only concrete types such as structs, enums and classes can conform to protocols}}
875875
]
876876
}
877+
878+
// rdar://78781552 - crash in `getFunctionArgApplyInfo`
879+
func rdar78781552() {
880+
struct Test<Data, Content> where Data : RandomAccessCollection {
881+
// expected-note@-1 {{where 'Data' = '(((Int) throws -> Bool) throws -> [Int])?'}}
882+
// expected-note@-2 {{'init(data:filter:)' declared here}}
883+
// expected-note@-3 {{'Content' declared as parameter to type 'Test'}}
884+
var data: [Data]
885+
var filter: (Data.Element) -> Content
886+
}
887+
888+
func test(data: [Int]?) {
889+
Test(data?.filter)
890+
// expected-error@-1 {{generic struct 'Test' requires that '(((Int) throws -> Bool) throws -> [Int])?' conform to 'RandomAccessCollection'}}
891+
// expected-error@-2 {{generic parameter 'Content' could not be inferred}} expected-note@-2 {{explicitly specify the generic arguments to fix this issue}}
892+
// expected-error@-3 {{cannot convert value of type '(((Int) throws -> Bool) throws -> [Int])?' to expected argument type '[(((Int) throws -> Bool) throws -> [Int])?]'}}
893+
// expected-error@-4 {{missing argument for parameter 'filter' in call}}
894+
}
895+
}

0 commit comments

Comments
 (0)