Skip to content

[Sema] Accept IgnoreCollectionElementContextualMismatch in conflict generic diagnostics #61214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/Sema/ConstraintSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4088,7 +4088,8 @@ static bool diagnoseConflictingGenericArguments(ConstraintSystem &cs,
fix->getKind() == FixKind::AllowFunctionTypeMismatch ||
fix->getKind() == FixKind::AllowTupleTypeMismatch ||
fix->getKind() == FixKind::GenericArgumentsMismatch ||
fix->getKind() == FixKind::InsertCall;
fix->getKind() == FixKind::InsertCall ||
fix->getKind() == FixKind::IgnoreCollectionElementContextualMismatch;
});
});

Expand Down
7 changes: 5 additions & 2 deletions test/Constraints/type_inference_from_default_exprs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,10 @@ struct S61061_1<T> where T:Hashable { // expected-note{{'T' declared as paramete
// expected-error@-1{{generic parameter 'T' could not be inferred}}
}

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

struct S61061_3<T> where T:Hashable {
init(x:[(T, T)] = [(1, 1)]) {} // OK
}