Skip to content

Commit 783d998

Browse files
committed
SIL: Introduce SameShape requirements in SubstFunctionTypePatternVisitor
1 parent a8cec8e commit 783d998

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

lib/SIL/IR/AbstractionPattern.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1993,9 +1993,21 @@ class SubstFunctionTypePatternVisitor
19931993
return CanType(pack);
19941994
}
19951995

1996+
auto substPatternType = visit(pack->getPatternType(),
1997+
pattern.getPackExpansionPatternType());
1998+
auto substCountType = visit(pack->getCountType(),
1999+
pattern.getPackExpansionCountType());
2000+
2001+
SmallVector<Type> rootParameterPacks;
2002+
substPatternType->getTypeParameterPacks(rootParameterPacks);
2003+
2004+
for (auto parameterPack : rootParameterPacks) {
2005+
substRequirements.emplace_back(RequirementKind::SameShape,
2006+
parameterPack, substCountType);
2007+
}
2008+
19962009
return CanType(PackExpansionType::get(
1997-
visit(pack->getPatternType(), pattern.getPackExpansionPatternType()),
1998-
visit(pack->getCountType(), pattern.getPackExpansionCountType())));
2010+
substPatternType, substCountType));
19992011
}
20002012

20012013
CanType visitExistentialType(ExistentialType *exist,

test/SILGen/pack_expansion_type.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ public struct VariadicType<each T> {
1414
// CHECK: bb0(%0 : $*Pack{repeat (each T, each U)}, %1 : $*Pack{repeat each T}, %2 : $*Pack{repeat each U}, %3 : $VariadicType<repeat each T>):
1515
public func variadicMethod<each U>(t: repeat each T, u: repeat each U) -> (repeat (each T, each U)) {}
1616

17-
// CHECK-LABEL: sil [ossa] @$s19pack_expansion_type12VariadicTypeV13takesFunction1tyqd__qd__Qp_txxQpXE_tRvd__lF : $@convention(method) <each T><each U> (@guaranteed @noescape @callee_guaranteed @substituted <each τ_0_0, each τ_0_1, each τ_0_2, each τ_0_3> (@pack_guaranteed Pack{repeat each τ_0_0}) -> @pack_out Pack{repeat each τ_0_2} for <Pack{repeat each T}, Pack{repeat each T}, Pack{repeat each U}, Pack{repeat each U}>, VariadicType<repeat each T>) -> () {
18-
// CHECK: bb0(%0 : @guaranteed $@noescape @callee_guaranteed @substituted <each τ_0_0, each τ_0_1, each τ_0_2, each τ_0_3> (@pack_guaranteed Pack{repeat each τ_0_0}) -> @pack_out Pack{repeat each τ_0_2} for <Pack{repeat each T}, Pack{repeat each T}, Pack{repeat each U}, Pack{repeat each U}>, %1 : $VariadicType<repeat each T>):
17+
// CHECK-LABEL: sil [ossa] @$s19pack_expansion_type12VariadicTypeV13takesFunction1tyqd__qd__Qp_txxQpXE_tRvd__lF : $@convention(method) <each T><each U> (@guaranteed @noescape @callee_guaranteed @substituted <each τ_0_0, each τ_0_1, each τ_0_2, each τ_0_3 where (repeat (each τ_0_0, each τ_0_1)) : Any, (repeat (each τ_0_2, each τ_0_3)) : Any> (@pack_guaranteed Pack{repeat each τ_0_0}) -> @pack_out Pack{repeat each τ_0_2} for <Pack{repeat each T}, Pack{repeat each T}, Pack{repeat each U}, Pack{repeat each U}>, VariadicType<repeat each T>) -> () {
18+
// CHECK: bb0(%0 : @guaranteed $@noescape @callee_guaranteed @substituted <each τ_0_0, each τ_0_1, each τ_0_2, each τ_0_3 where (repeat (each τ_0_0, each τ_0_1)) : Any, (repeat (each τ_0_2, each τ_0_3)) : Any> (@pack_guaranteed Pack{repeat each τ_0_0}) -> @pack_out Pack{repeat each τ_0_2} for <Pack{repeat each T}, Pack{repeat each T}, Pack{repeat each U}, Pack{repeat each U}>, %1 : $VariadicType<repeat each T>):
1919
public func takesFunction<each U>(t: (repeat each T) -> (repeat each U)) {}
2020
}
2121

0 commit comments

Comments
 (0)