Skip to content

Commit 1f0ecc6

Browse files
authored
Merge pull request #31511 from LucianoPAlmeida/SR-12725-diagnostics-generic-argument
[SR-12725] Diagnose unhandled generic argument mismatch involving FunctionArgument
2 parents 11b9586 + 08be3d2 commit 1f0ecc6

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

lib/Sema/CSDiagnostics.cpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -678,10 +678,6 @@ bool GenericArgumentsMismatchFailure::diagnoseAsError() {
678678
break;
679679
}
680680

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

710706
default:
711-
return false;
707+
break;
712708
}
713709
}
714710

test/Constraints/diagnostics.swift

+7
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)