Skip to content

[CSDiagnostics] Teach diagnoseConflictingGenericArguments about holes #65479

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
Apr 29, 2023
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
6 changes: 6 additions & 0 deletions lib/Sema/ConstraintSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4422,6 +4422,12 @@ static bool diagnoseConflictingGenericArguments(ConstraintSystem &cs,
std::tie(GP, loc) = conflict.first;
auto conflictingArguments = conflict.second;

// If there are any substitutions that are not fully resolved
// solutions cannot be considered conflicting for the given parameter.
if (llvm::any_of(conflictingArguments,
[](const auto &arg) { return arg->hasPlaceholder(); }))
continue;

llvm::SmallString<64> arguments;
llvm::raw_svector_ostream OS(arguments);

Expand Down
27 changes: 27 additions & 0 deletions validation-test/Sema/SwiftUI/rdar108534555.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// RUN: %target-typecheck-verify-swift -target %target-cpu-apple-macosx10.15 -swift-version 5 -disable-availability-checking

// REQUIRES: objc_interop
// REQUIRES: OS=macosx

import SwiftUI

struct Item: Identifiable {
var id: Int
var title: String
}

struct MyGroup<Content> {
init(@ViewBuilder _: () -> Content) {}
}

struct Test {
let s: [Item]

func test() {
MyGroup {
ForEach(s) {
Button($0.title) // expected-error {{value of type 'String' to expected argument type 'PrimitiveButtonStyleConfiguration'}}
}
}
}
}