Skip to content

Commit eba9e5b

Browse files
authored
Merge pull request swiftlang#39209 from xedin/rdar-81228501
[Diagnostics] Ignore warnings while diagnosing ambiguities
2 parents f2f8bac + 396a93b commit eba9e5b

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3990,8 +3990,14 @@ bool ConstraintSystem::diagnoseAmbiguityWithFixes(
39903990

39913991
llvm::SmallSetVector<FixInContext, 4> fixes;
39923992
for (auto &solution : solutions) {
3993-
for (auto *fix : solution.Fixes)
3993+
for (auto *fix : solution.Fixes) {
3994+
// Ignore warnings in favor of actual error fixes,
3995+
// because they are not the source of ambiguity/failures.
3996+
if (fix->isWarning())
3997+
continue;
3998+
39943999
fixes.insert({&solution, fix});
4000+
}
39954001
}
39964002

39974003
llvm::MapVector<ConstraintLocator *, SmallVector<FixInContext, 4>>

test/Constraints/closures.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,3 +1163,13 @@ func rdar78917861() {
11631163
}()
11641164
}
11651165
}
1166+
1167+
// rdar://81228501 - type-checker crash due to applied invalid solution
1168+
func test(arr: [[Int]]) {
1169+
struct A {
1170+
init(arg: [Int]) {}
1171+
}
1172+
1173+
arr.map { ($0 as? [Int]).map { A($0) } } // expected-error {{missing argument label 'arg:' in call}} {{36-36=arg: }}
1174+
// expected-warning@-1 {{conditional cast from '[Int]' to '[Int]' always succeeds}}
1175+
}

0 commit comments

Comments
 (0)