Skip to content

Commit c0f1fd4

Browse files
committed
Sema: Handle SameShape requirements in doesMemberHaveUnfulfillableConstraintsWithExistentialBase()
1 parent aa81ce3 commit c0f1fd4

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7479,9 +7479,6 @@ static bool doesMemberHaveUnfulfillableConstraintsWithExistentialBase(
74797479

74807480
for (const auto &req : sig.getRequirements()) {
74817481
switch (req.getKind()) {
7482-
case RequirementKind::SameShape:
7483-
llvm_unreachable("Same-shape requirement not supported here");
7484-
74857482
case RequirementKind::Superclass: {
74867483
if (req.getFirstType()->getRootGenericParam()->getDepth() > 0 &&
74877484
req.getSecondType().walk(isDependentOnSelfWalker)) {
@@ -7490,7 +7487,8 @@ static bool doesMemberHaveUnfulfillableConstraintsWithExistentialBase(
74907487

74917488
break;
74927489
}
7493-
case RequirementKind::SameType: {
7490+
case RequirementKind::SameType:
7491+
case RequirementKind::SameShape: {
74947492
const auto isNonSelfRootedTypeParam = [](Type ty) {
74957493
return ty->isTypeParameter() &&
74967494
ty->getRootGenericParam()->getDepth() > 0;

test/decl/protocol/existential_member_accesses_self_assoctype.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,3 +1024,12 @@ do {
10241024
let _: Array<any Class2Base & CovariantAssocTypeErasureDerived> = exist.method11()
10251025
let _: Dictionary<String, any Class2Base & CovariantAssocTypeErasureDerived> = exist.method12()
10261026
}
1027+
1028+
// Same-shape requirements
1029+
protocol HasSameShape {
1030+
func foo<each T, each U>(t: repeat each T, u: repeat each U) -> (repeat (each T, each U))
1031+
}
1032+
1033+
func bar(a: any HasSameShape) -> (Int, String) {
1034+
a.foo(t: 1, u: "hi")
1035+
}

0 commit comments

Comments
 (0)