Skip to content

[5.9][CSBindings] Mark type variables that represent type parameter packs … #65975

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
May 18, 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
3 changes: 2 additions & 1 deletion lib/Sema/CSBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ bool BindingSet::isDelayed() const {
bool BindingSet::involvesTypeVariables() const {
// This type variable always depends on a pack expansion variable
// which should be inferred first if possible.
if (TypeVar->getImpl().canBindToPack())
if (TypeVar->getImpl().getGenericParameter() &&
TypeVar->getImpl().canBindToPack())
return true;

// This is effectively O(1) right now since bindings are re-computed
Expand Down
23 changes: 23 additions & 0 deletions test/Constraints/casts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -718,3 +718,26 @@ func isHashable_is(_ error: Error) -> Bool {
func isHashable_composition(_ error: Error & AnyObject) -> Bool {
error is AnyHashable // OK
}

// rdar://109381194 - incorrect ambiguity while comparing collections
do {
class A : Hashable, Equatable {
func hash(into hasher: inout Hasher) {
}

static func == (lhs: A, rhs: A) -> Bool {
false
}
}

class B : A {}

func test(a: [B], b: [String: B]) {
assert(Set(a) == Set(b.values.map { $0 as A })) // ok
}

func test(a: [A], b: [B]) {
assert(Set(a) == Set(b.map { $0 as A })) // Ok
assert(Set(b.map { $0 as A }) == Set(a)) // Ok
}
}