mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
They are mandatory inlined anyway. Therefore the binary code of transparent functions is not used in most cases. In case the address of a transparent function is taken, the main program (which deserialized the transparent function) generates code for it and treats it as shared function. This reduces the stdlib code size by 2.8%.
38 lines
474 B
Swift
38 lines
474 B
Swift
|
|
@inline(never)
|
|
func incrementit(_ x: Int) -> Int {
|
|
return x + 1
|
|
}
|
|
|
|
class Derived : Base {
|
|
override func memberfunc(_ x: Int) -> Int {
|
|
return x + 2
|
|
}
|
|
}
|
|
|
|
private struct MyStruct : MyProto {
|
|
|
|
var x: Int
|
|
|
|
func protofunc() -> Int {
|
|
return x
|
|
}
|
|
}
|
|
|
|
@_transparent public func transparentfunc(_ x: Int) -> Int {
|
|
return x + 3
|
|
}
|
|
|
|
public var g1 = 234
|
|
|
|
let i = testit(27)
|
|
print(i)
|
|
|
|
let i2 = callmember(Derived())
|
|
print(i2)
|
|
|
|
callproto(MyStruct(x: 42))
|
|
|
|
print(callPrivInc(g1))
|
|
|