Files
swift-mirror/test/Interpreter/Inputs/dynamic_replacement_without_previous_calls2.swift
Arnold Schwaighofer 7e646847c7 SILGen: Add an option to disable the previous implementation inside of dynamic replacement thunks
@_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
2019-05-29 11:31:27 -07:00

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)
}
}