Skip to content

Commit e4ec78c

Browse files
authored
Merge pull request #65962 from xedin/rdar-109381194
[CSBindings] Mark type variables that represent type parameter packs as "involving type variables"
2 parents 23c1933 + 1728cca commit e4ec78c

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

lib/Sema/CSBindings.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ bool BindingSet::isDelayed() const {
150150
bool BindingSet::involvesTypeVariables() const {
151151
// This type variable always depends on a pack expansion variable
152152
// which should be inferred first if possible.
153-
if (TypeVar->getImpl().canBindToPack())
153+
if (TypeVar->getImpl().getGenericParameter() &&
154+
TypeVar->getImpl().canBindToPack())
154155
return true;
155156

156157
// This is effectively O(1) right now since bindings are re-computed

test/Constraints/casts.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,3 +718,26 @@ func isHashable_is(_ error: Error) -> Bool {
718718
func isHashable_composition(_ error: Error & AnyObject) -> Bool {
719719
error is AnyHashable // OK
720720
}
721+
722+
// rdar://109381194 - incorrect ambiguity while comparing collections
723+
do {
724+
class A : Hashable, Equatable {
725+
func hash(into hasher: inout Hasher) {
726+
}
727+
728+
static func == (lhs: A, rhs: A) -> Bool {
729+
false
730+
}
731+
}
732+
733+
class B : A {}
734+
735+
func test(a: [B], b: [String: B]) {
736+
assert(Set(a) == Set(b.values.map { $0 as A })) // ok
737+
}
738+
739+
func test(a: [A], b: [B]) {
740+
assert(Set(a) == Set(b.map { $0 as A })) // Ok
741+
assert(Set(b.map { $0 as A }) == Set(a)) // Ok
742+
}
743+
}

0 commit comments

Comments
 (0)