Skip to content

Commit 298880d

Browse files
committed
Add a SILGen test case for a resilient enum protocol witness.
Tests rdar://108001491 (SIL verification failed: Found mutating or consuming use of in_guaranteed parameter?!: !ImmutableAddressUseVerifier().isMutatingOrConsuming(fArg))
1 parent ea7b805 commit 298880d

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

test/SILGen/protocol_enum_witness.swift

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %target-swift-emit-silgen %s | %FileCheck %s
2-
// RUN: %target-swift-emit-silgen %s -enable-library-evolution
2+
// RUN: %target-swift-emit-silgen %s -enable-library-evolution | %FileCheck %s --check-prefix=CHECK-LIB
33

44
public protocol Foo {
55
static var button: Self { get }
@@ -55,3 +55,27 @@ enum InternalEnumWithPublicStruct : Foo {
5555

5656
// CHECK-LABEL: sil_witness_table [serialized] AnotherBar: AnotherFoo module protocol_enum_witness {
5757
// CHECK: method #AnotherFoo.bar: <Self where Self : AnotherFoo> (Self.Type) -> (Int) -> Self : @$s21protocol_enum_witness10AnotherBarOAA0D3FooA2aDP3bar3argxSi_tFZTW
58+
59+
// -----------------------------------------------------------------------------
60+
// rdar://108001491 (SIL verification failed: Found mutating or consuming use of
61+
// an in_guaranteed parameter?!:
62+
// !ImmutableAddressUseVerifier().isMutatingOrConsuming(fArg))
63+
64+
public struct EntityIdentifier {
65+
public let value: Swift.UInt64
66+
}
67+
68+
public protocol ObjectProtocol {
69+
static func entityReference(_ id: EntityIdentifier) -> Self
70+
}
71+
72+
public enum Object : ObjectProtocol {
73+
case entityReference(EntityIdentifier)
74+
}
75+
76+
// CHECK-LIB-LABEL: sil private [transparent] [thunk] [ossa] @$s21protocol_enum_witness6ObjectOAA0D8ProtocolA2aDP15entityReferenceyxAA16EntityIdentifierVFZTW : $@convention(witness_method: ObjectProtocol) (@in_guaranteed EntityIdentifier, @thick Object.Type) -> @out Object {
77+
// CHECK-LIB: bb0(%0 : $*Object, %1 : $*EntityIdentifier, %2 : $@thick Object.Type):
78+
// CHECK-LIB: [[TEMP:%.*]] = alloc_stack $EntityIdentifier
79+
// CHECK-LIB: copy_addr %1 to [init] %3 : $*EntityIdentifier
80+
// CHECK-LIB: apply %{{.*}}(%0, [[TEMP]], %{{.*}}) : $@convention(method) (@in EntityIdentifier, @thin Object.Type) -> @out Object
81+
// CHECK-LIB-LABEL: } // end sil function '$s21protocol_enum_witness6ObjectOAA0D8ProtocolA2aDP15entityReferenceyxAA16EntityIdentifierVFZTW'

0 commit comments

Comments
 (0)