mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
The intent for `@inline(always)` is to act as an optimization control. The user can rely on inlining to happen or the compiler will emit an error message. Because function values can be dynamic (closures, protocol/class lookup) this guarantee can only be upheld for direct function references. In cases where the optimizer can resolve dynamic function values the attribute shall be respected. rdar://148608854
20 lines
354 B
Swift
20 lines
354 B
Swift
@inline(__always) @inlinable public func testAlwaysInline(x: Bool) -> Bool {
|
|
return x
|
|
}
|
|
|
|
@inline(always) @inlinable public func testAlwaysInlineGuaranteed(x: Bool) -> Bool {
|
|
return x
|
|
}
|
|
|
|
@frozen
|
|
public struct AlwaysInlineInitStruct {
|
|
@usableFromInline
|
|
var x: Bool
|
|
|
|
@inline(__always) @inlinable
|
|
public init(x x2: Bool) {
|
|
self.x = x2
|
|
}
|
|
}
|
|
|