mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Also, mark witness thunks for [fragile] witnesses as [fragile]. This allows us to serialize the witness table, as well as any thunks for witnesses declared @_transparent and @inline(__always).
53 lines
1.3 KiB
Swift
53 lines
1.3 KiB
Swift
// RUN: %target-swift-frontend -O -emit-sil %s | FileCheck %s
|
|
|
|
// Check that compiler does not crash on the devirtualization of materializeForSet methods
|
|
// and produces a correct code.
|
|
|
|
// CHECK-LABEL: sil [transparent] [fragile] [thunk] @_TTWC24devirt_materializeForSet7BaseFooS_3FooS_FS1_m3barSS
|
|
// CHECK: checked_cast_br [exact] %{{.*}} : $BaseFoo to $ChildFoo
|
|
// CHECK: thin_function_to_pointer %{{.*}} : $@convention(thin) (Builtin.RawPointer, @inout Builtin.UnsafeValueBuffer, @inout ChildFoo, @thick ChildFoo.Type) -> () to $Builtin.RawPointer
|
|
// CHECK: enum $Optional<Builtin.RawPointer>, #Optional.some!enumelt.1, %{{.*}} : $Builtin.RawPointer
|
|
// CHECK: tuple (%{{.*}} : $Builtin.RawPointer, %{{.*}} : $Optional<Builtin.RawPointer>)
|
|
|
|
public protocol Foo {
|
|
var bar: String { get set }
|
|
}
|
|
|
|
public class BaseFoo: Foo {
|
|
public var bar: String = "hello"
|
|
}
|
|
|
|
public class ChildFoo: BaseFoo {
|
|
private var _bar: String = "world"
|
|
|
|
override public var bar: String {
|
|
get {
|
|
return _bar
|
|
}
|
|
set {
|
|
_bar = newValue
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@inline(never)
|
|
public func test1(bf: BaseFoo) {
|
|
bf.bar = "test1"
|
|
print(bf.bar)
|
|
}
|
|
|
|
@inline(never)
|
|
public func test2(f: Foo) {
|
|
var f = f
|
|
f.bar = "test2"
|
|
print(f.bar)
|
|
}
|
|
|
|
|
|
//test1(BaseFoo())
|
|
//test1(ChildFoo())
|
|
|
|
//test2(BaseFoo())
|
|
//test2(ChildFoo())
|