Files
swift-mirror/test/SIL/Parser/protocol_getter.sil
Roman Levenstein 8ad61d5cd6 Use function signatures for SILDeclRefs in witness_tables, vtables and witness_method instructions.
Textual SIL was sometimes ambiguous when SILDeclRefs were used, because the textual representation of SILDeclRefs was the same for functions that have the same name, but different signatures.
2017-01-27 12:16:14 -08:00

33 lines
1.7 KiB
Plaintext

// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil %s -emit-silgen | %FileCheck %s
// Verify that SILParser correctly handles witness_method on a getter.
import Swift
protocol TestP : class {
var count: Int {get}
func test() -> String!
}
// CHECK-LABEL: sil @test
sil @test : $@convention(method) (TestP) -> () {
bb0(%0 : $TestP):
%1 = open_existential_ref %0 : $TestP to $@opened("01234567-89ab-cdef-0123-000000000000") TestP
// CHECK: witness_method $@opened({{.*}}) TestP, #TestP.count!getter : {{.*}}, %{{.*}} : $@opened({{.*}} : $@convention(witness_method) <τ_0_0 where τ_0_0 : TestP> (τ_0_0) -> Int
%2 = witness_method $@opened("01234567-89ab-cdef-0123-000000000000") TestP, #TestP.count!getter, %1 : $@opened("01234567-89ab-cdef-0123-000000000000") TestP : $@convention(witness_method) <T: TestP> (T) -> Int
%3 = tuple ()
return %3 : $()
}
// Make sure we can parse "!" as ImplicitlyUnwrappedOptional.
// CHECK-LABEL: sil @top
sil @top : $@convention(thin) (@owned TestP) -> @owned Optional<String> {
bb0(%0 : $TestP):
strong_retain %0 : $TestP
%3 = open_existential_ref %0 : $TestP to $@opened("01234567-89ab-cdef-0123-111111111111") TestP
// CHECK: witness_method $@opened({{.*}}) TestP, #TestP.test!1
%4 = witness_method $@opened("01234567-89ab-cdef-0123-111111111111") TestP, #TestP.test!1, %3 : $@opened("01234567-89ab-cdef-0123-111111111111") TestP : $@convention(witness_method) @callee_owned <T: TestP> (@owned T) -> @owned Optional<String>
%5 = apply %4<@opened("01234567-89ab-cdef-0123-111111111111") TestP>(%3) : $@convention(witness_method) @callee_owned <T: TestP> (@owned T) -> @owned Optional<String>
strong_release %0 : $TestP
return %5 : $Optional<String>
}