mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
@_dynamicReplacement(for: selfRec(x: acc:))
func selfRec_r(x: Int, acc: Int) -> Int {
if x <= 0 {
return acc
}
// Normally, this will call selfRec(x: acc:)'s implementation.
// With the option, this will call to selfRec_r(x: acc:).
return selfRec(x: x - 1, acc: acc + 1)
}
rdar://51229650
30 lines
557 B
Swift
30 lines
557 B
Swift
import Module1
|
|
|
|
@_dynamicReplacement(for: selfRec(_: _:))
|
|
func selfRec_r(_ x: Int, _ acc: Int) -> Int {
|
|
if x <= 0 {
|
|
return acc
|
|
}
|
|
return selfRec(x - 1, acc + 1)
|
|
}
|
|
|
|
extension AStruct {
|
|
@_dynamicReplacement(for: selfRec(_: _:))
|
|
func selfRec_r(_ x: Int, _ acc: Int) -> Int {
|
|
if x <= 0 {
|
|
return acc
|
|
}
|
|
return selfRec(x - 1, acc + 1)
|
|
}
|
|
}
|
|
|
|
extension AClass {
|
|
@_dynamicReplacement(for: selfRec(_: _:))
|
|
func selfRec_r(_ x: Int, _ acc: Int) -> Int {
|
|
if x <= 0 {
|
|
return acc
|
|
}
|
|
return selfRec(x - 1, acc + 1)
|
|
}
|
|
}
|