Skip to content

Commit 75d25c6

Browse files
committed
RequirementMachine: Ensure that isValidTypeParameter() checks the generic parameter type too
1 parent 476823b commit 75d25c6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/AST/RequirementMachine/GenericSignatureQueries.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,19 @@ RequirementMachine::getLongestValidPrefix(const MutableTerm &term) const {
244244
"Protocol symbol can only appear at the start of a type term");
245245
break;
246246

247-
case Symbol::Kind::GenericParam:
247+
case Symbol::Kind::GenericParam: {
248248
assert(prefix.empty() &&
249249
"Generic parameter symbol can only appear at the start of a type term");
250+
251+
if (std::find_if(Params.begin(), Params.end(),
252+
[&](Type otherParam) -> bool {
253+
return otherParam->isEqual(symbol.getGenericParam());
254+
}) == Params.end()) {
255+
return prefix;
256+
}
257+
250258
break;
259+
}
251260

252261
case Symbol::Kind::AssociatedType: {
253262
const auto *props = Map.lookUpProperties(prefix);

0 commit comments

Comments
 (0)