Skip to content

Commit 1cacc06

Browse files
authored
Merge pull request #61214 from LucianoPAlmeida/ambiguous-tuple
[Sema] Accept IgnoreCollectionElementContextualMismatch in conflict generic diagnostics
2 parents 77903de + be25419 commit 1cacc06

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4088,7 +4088,8 @@ static bool diagnoseConflictingGenericArguments(ConstraintSystem &cs,
40884088
fix->getKind() == FixKind::AllowFunctionTypeMismatch ||
40894089
fix->getKind() == FixKind::AllowTupleTypeMismatch ||
40904090
fix->getKind() == FixKind::GenericArgumentsMismatch ||
4091-
fix->getKind() == FixKind::InsertCall;
4091+
fix->getKind() == FixKind::InsertCall ||
4092+
fix->getKind() == FixKind::IgnoreCollectionElementContextualMismatch;
40924093
});
40934094
});
40944095

test/Constraints/type_inference_from_default_exprs.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,10 @@ struct S61061_1<T> where T:Hashable { // expected-note{{'T' declared as paramete
246246
// expected-error@-1{{generic parameter 'T' could not be inferred}}
247247
}
248248

249-
// TODO(diagnostics): Should produce a conflicting types inferred for generic argument 'T'
250249
struct S61061_2<T> where T:Hashable {
251-
init(x:[(T, T)] = [(1, "")]) {} // expected-error{{type of expression is ambiguous without more context}}
250+
init(x:[(T, T)] = [(1, "")]) {} // expected-error{{conflicting arguments to generic parameter 'T' ('String' vs. 'Int')}}
251+
}
252+
253+
struct S61061_3<T> where T:Hashable {
254+
init(x:[(T, T)] = [(1, 1)]) {} // OK
252255
}

0 commit comments

Comments
 (0)