Skip to content

Commit ae73cd4

Browse files
committed
RequirementMachine: Fix an incorrect assertion
We don't expect to see type parameters that are not generic parameters here, but dependent member types that wrap an ErrorType are fine, they show up when a conformance had an invalid type witness. Fixes the remaining example from swiftlang#59384.
1 parent 61dbaf8 commit ae73cd4

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

lib/AST/RequirementMachine/TypeDifference.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,16 +332,18 @@ swift::rewriting::buildTypeDifference(
332332
return nextSubstitution(substitution);
333333
}
334334

335-
assert(!t->is<DependentMemberType>());
335+
// DependentMemberType with ErrorType base is OK.
336+
assert(!t->isTypeParameter());
336337
return std::nullopt;
337338
});
338339
}
339340
}
340341

341-
assert(!t->is<DependentMemberType>());
342342
return nextSubstitution(substitutions[index]);
343343
}
344344

345+
// DependentMemberType with ErrorType base is OK.
346+
assert(!t->isTypeParameter());
345347
return std::nullopt;
346348
});
347349

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN: not %target-swift-frontend -emit-ir %s
2+
3+
protocol P1 {}
4+
protocol Q1 {
5+
associatedtype A
6+
associatedtype B
7+
}
8+
9+
protocol Q2: Q1 where B == S<Self>, B.C == Self {}
10+
11+
protocol P2: P1 {
12+
associatedtype C: Q2 where C.A == Void
13+
}
14+
15+
struct S<C: Q2>: P2 {
16+
}

0 commit comments

Comments
 (0)