Skip to content

[Diagnostics] Ignore warnings while diagnosing ambiguities #39209

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 9, 2021
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
8 changes: 7 additions & 1 deletion lib/Sema/ConstraintSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3989,8 +3989,14 @@ bool ConstraintSystem::diagnoseAmbiguityWithFixes(

llvm::SmallSetVector<FixInContext, 4> fixes;
for (auto &solution : solutions) {
for (auto *fix : solution.Fixes)
for (auto *fix : solution.Fixes) {
// Ignore warnings in favor of actual error fixes,
// because they are not the source of ambiguity/failures.
if (fix->isWarning())
continue;

fixes.insert({&solution, fix});
}
}

llvm::MapVector<ConstraintLocator *, SmallVector<FixInContext, 4>>
Expand Down
10 changes: 10 additions & 0 deletions test/Constraints/closures.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1163,3 +1163,13 @@ func rdar78917861() {
}()
}
}

// rdar://81228501 - type-checker crash due to applied invalid solution
func test(arr: [[Int]]) {
struct A {
init(arg: [Int]) {}
}

arr.map { ($0 as? [Int]).map { A($0) } } // expected-error {{missing argument label 'arg:' in call}} {{36-36=arg: }}
// expected-warning@-1 {{conditional cast from '[Int]' to '[Int]' always succeeds}}
}