Skip to content

Commit 31d1c4c

Browse files
authored
Merge pull request #67326 from xedin/rdar-110721928
[CSSimplify] Deplay member lookup until single-element tuple with pac…
2 parents 669285f + eb86497 commit 31d1c4c

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9378,6 +9378,17 @@ performMemberLookup(ConstraintKind constraintKind, DeclNameRef memberName,
93789378
return result;
93799379
}
93809380

9381+
// Delay member lookup until single-element tuple with pack expansion
9382+
// is sufficiently resolved.
9383+
if (isSingleUnlabeledPackExpansionTuple(instanceTy)) {
9384+
auto elementTy = instanceTy->castTo<TupleType>()->getElementType(0);
9385+
if (elementTy->is<TypeVariableType>()) {
9386+
MemberLookupResult result;
9387+
result.OverallResult = MemberLookupResult::Unsolved;
9388+
return result;
9389+
}
9390+
}
9391+
93819392
// Okay, start building up the result list.
93829393
MemberLookupResult result;
93839394
result.OverallResult = MemberLookupResult::HasResults;

test/Constraints/pack-expansion-expressions.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,3 +707,18 @@ do {
707707
test3(str: "", a, a) // expected-error {{ambiguous use of 'test3'}}
708708
}
709709
}
710+
711+
// rdar://112095973 - single-element tuples are not unwrapped in member references
712+
do {
713+
struct V<Value> {
714+
let key: Int
715+
}
716+
717+
struct S<each T> {
718+
let data: (repeat V<each T>)
719+
}
720+
721+
func test<U>(_ value: S<U>) {
722+
_ = value.data.key // Ok
723+
}
724+
}

0 commit comments

Comments
 (0)