Skip to content

Commit 23d758e

Browse files
[SR-12725] Diagnose unhandled generic argument mismatch involving FunctionArgument
1 parent ec57300 commit 23d758e

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

lib/Sema/CSDiagnostics.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -679,10 +679,6 @@ bool GenericArgumentsMismatchFailure::diagnoseAsError() {
679679
break;
680680
}
681681

682-
case ConstraintLocator::GenericArgument: {
683-
break;
684-
}
685-
686682
case ConstraintLocator::OptionalPayload: {
687683
// If we have an inout expression, this comes from an
688684
// InoutToPointer argument mismatch failure.
@@ -709,7 +705,7 @@ bool GenericArgumentsMismatchFailure::diagnoseAsError() {
709705
}
710706

711707
default:
712-
return false;
708+
break;
713709
}
714710
}
715711

test/Constraints/diagnostics.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,3 +1470,10 @@ func gericArgToParamInout(_ x: inout [[Int]]) { // expected-note {{change variab
14701470
// expected-note@-1 {{arguments to generic parameter 'Element' ('Int' and 'String') are expected to be equal}}
14711471
// expected-error@-2 {{inout argument could be set to a value with a type other than '[[Int]]'; use a value declared as type '[[String]]?' instead}}
14721472
}
1473+
1474+
// SR-12725
1475+
struct SR12725<E> {} // expected-note {{arguments to generic parameter 'E' ('Int' and 'Double') are expected to be equal}}
1476+
func generic<T>(_ value: inout T, _ closure: (SR12725<T>) -> Void) {}
1477+
1478+
let arg: Int
1479+
generic(&arg) { (g: SR12725<Double>) -> Void in } // expected-error {{cannot convert value of type '(SR12725<Double>) -> Void' to expected argument type '(SR12725<Int>) -> Void'}}

0 commit comments

Comments
 (0)