Skip to content

Commit c05c4db

Browse files
authored
Merge pull request #77972 from eeckstein/fix-verifier
SILVerifier: fix a wrong check for witness_method instructions
2 parents a045d66 + d16a213 commit c05c4db

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

lib/SIL/IR/SILPrinter.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2520,10 +2520,11 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
25202520
PrintOptions QualifiedSILTypeOptions =
25212521
PrintOptions::printQualifiedSILType();
25222522
QualifiedSILTypeOptions.CurrentModule = WMI->getModule().getSwiftModule();
2523-
*this << "$" << WMI->getLookupType() << ", " << WMI->getMember() << " : ";
2523+
auto lookupType = WMI->getLookupType();
2524+
*this << "$" << lookupType << ", " << WMI->getMember() << " : ";
25242525
WMI->getMember().getDecl()->getInterfaceType().print(
25252526
PrintState.OS, QualifiedSILTypeOptions);
2526-
if (!WMI->getTypeDependentOperands().empty()) {
2527+
if ((getLocalArchetypeOf(lookupType) || lookupType->hasDynamicSelfType()) && !WMI->getTypeDependentOperands().empty()) {
25272528
*this << ", ";
25282529
*this << getIDAndForcedPrintedType(WMI->getTypeDependentOperands()[0].get());
25292530
}

lib/SIL/Verifier/SILVerifier.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4177,7 +4177,7 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
41774177
"Must have a type dependent operand for the opened archetype");
41784178
verifyLocalArchetype(AMI, lookupType);
41794179
} else {
4180-
require(AMI->getTypeDependentOperands().empty(),
4180+
require(AMI->getTypeDependentOperands().empty() || lookupType->hasLocalArchetype(),
41814181
"Should not have an operand for the opened existential");
41824182
}
41834183
if (!isa<ArchetypeType>(lookupType) && !isa<DynamicSelfType>(lookupType)) {
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// RUN: %target-run-simple-swift(-O -Xfrontend -sil-verify-all) | %FileCheck %s
2+
3+
protocol P {}
4+
extension P {
5+
func foo() -> some Sequence<Int> {
6+
[1, 2, 3]
7+
}
8+
}
9+
10+
struct B {
11+
let p: P
12+
13+
@inline(never)
14+
func bar() {
15+
for x in p.foo() {
16+
print(x)
17+
}
18+
}
19+
}
20+
21+
22+
struct S : P {
23+
var x = 0
24+
}
25+
26+
27+
let b = B(p: S())
28+
29+
// CHECK: 1
30+
// CHECK-NEXT: 2
31+
// CHECK-NEXT: 3
32+
b.bar()
33+

0 commit comments

Comments
 (0)