Skip to content

Commit e3c1a3b

Browse files
authored
Merge pull request #84875 from hamishknight/simple-fix
[CS] Use `simplifyType` in `isDependentMemberTypeWithBaseThatContainsUnresolvedPackExpansions`
2 parents e7929f4 + 1f5a0b4 commit e3c1a3b

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7104,8 +7104,11 @@ static bool isDependentMemberTypeWithBaseThatContainsUnresolvedPackExpansions(
71047104
if (!type->is<DependentMemberType>())
71057105
return false;
71067106

7107-
auto baseTy = cs.getFixedTypeRecursive(type->getDependentMemberRoot(),
7108-
/*wantRValue=*/true);
7107+
// FIXME: It's really unfortunate we need to use `simplifyType` here since
7108+
// this is called from `matchTypes`. We need to completely simplify the type
7109+
// though since pack expansions can be present in fixed types for nested
7110+
// type vars.
7111+
auto baseTy = cs.simplifyType(type->getDependentMemberRoot());
71097112
llvm::SmallPtrSet<TypeVariableType *, 2> typeVars;
71107113
baseTy->getTypeVariables(typeVars);
71117114
return llvm::any_of(typeVars, [](const TypeVariableType *typeVar) {

test/Constraints/pack-expansion-expressions.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,3 +833,23 @@ func test_dependent_members() {
833833
return Variadic.f(c1, c2) // Ok
834834
}
835835
}
836+
837+
protocol P2 {
838+
associatedtype X
839+
}
840+
841+
extension P2 {
842+
func foo() where X == Bool {}
843+
func foo() where X == String {}
844+
}
845+
846+
do {
847+
struct S<each E>: P2 {
848+
typealias X = String
849+
init(_ fn: () -> (repeat each E)) {}
850+
}
851+
852+
func foo(_ x: Int) {
853+
S { x }.foo() // Make sure we can pick the right 'foo' here.
854+
}
855+
}

0 commit comments

Comments
 (0)