Skip to content

Commit 366213d

Browse files
authored
Merge pull request #65479 from xedin/rdar-108534555
[CSDiagnostics] Teach `diagnoseConflictingGenericArguments` about holes
2 parents 00c6741 + 0b7aeed commit 366213d

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4422,6 +4422,12 @@ static bool diagnoseConflictingGenericArguments(ConstraintSystem &cs,
44224422
std::tie(GP, loc) = conflict.first;
44234423
auto conflictingArguments = conflict.second;
44244424

4425+
// If there are any substitutions that are not fully resolved
4426+
// solutions cannot be considered conflicting for the given parameter.
4427+
if (llvm::any_of(conflictingArguments,
4428+
[](const auto &arg) { return arg->hasPlaceholder(); }))
4429+
continue;
4430+
44254431
llvm::SmallString<64> arguments;
44264432
llvm::raw_svector_ostream OS(arguments);
44274433

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// RUN: %target-typecheck-verify-swift -target %target-cpu-apple-macosx10.15 -swift-version 5 -disable-availability-checking
2+
3+
// REQUIRES: objc_interop
4+
// REQUIRES: OS=macosx
5+
6+
import SwiftUI
7+
8+
struct Item: Identifiable {
9+
var id: Int
10+
var title: String
11+
}
12+
13+
struct MyGroup<Content> {
14+
init(@ViewBuilder _: () -> Content) {}
15+
}
16+
17+
struct Test {
18+
let s: [Item]
19+
20+
func test() {
21+
MyGroup {
22+
ForEach(s) {
23+
Button($0.title) // expected-error {{value of type 'String' to expected argument type 'PrimitiveButtonStyleConfiguration'}}
24+
}
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)