Skip to content

Commit 9bbfb21

Browse files
committed
[SILVerifier] Ease this over-strict verification.
It's permitted for a `witness_method` instruction to have multiple type-dependent operands. This can happen when for example when one local archetype is defined in terms of another. rdar://159211502
1 parent 3728c77 commit 9bbfb21

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

lib/SIL/Verifier/SILVerifier.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4208,8 +4208,9 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
42084208

42094209
auto lookupType = AMI->getLookupType();
42104210
if (getLocalArchetypeOf(lookupType) || lookupType->hasDynamicSelfType()) {
4211-
require(AMI->getTypeDependentOperands().size() == 1,
4212-
"Must have a type dependent operand for the opened archetype");
4211+
require(!AMI->getTypeDependentOperands().empty(),
4212+
"Must have at least one type-dependent operand when there's a "
4213+
"local archetype or dynamic self.");
42134214
verifyLocalArchetype(AMI, lookupType);
42144215
} else {
42154216
require(AMI->getTypeDependentOperands().empty() || lookupType->hasLocalArchetype(),
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// RUN: %target-build-swift %s -O -Xfrontend -sil-verify-all
2+
3+
protocol PA<I> {
4+
associatedtype I: P
5+
func get() -> I
6+
}
7+
8+
protocol P {
9+
var pa: any PA<Self> { get }
10+
}
11+
12+
func f(_ p: any P) {
13+
p.pa.get()
14+
}

0 commit comments

Comments
 (0)