File tree Expand file tree Collapse file tree
Sources/InterposeKit/Hooks Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -79,8 +79,30 @@ public class AnyHook: Hook {
7979
8080/// Hook baseclass with generic signatures.
8181public class TypedHook < MethodSignature, HookSignature> : AnyHook {
82+
83+ override func replaceImplementation( ) throws {
84+ if let strategy = self . strategy as? ClassHookStrategy < MethodSignature > {
85+ return try strategy. replaceImplementation ( )
86+ } else {
87+ preconditionFailure ( " Not implemented " )
88+ }
89+ }
90+
91+ override func resetImplementation( ) throws {
92+ if let strategy = self . strategy as? ClassHookStrategy < MethodSignature > {
93+ return try strategy. resetImplementation ( )
94+ } else {
95+ preconditionFailure ( " Not implemented " )
96+ }
97+ }
98+
8299 /// The original implementation of the hook. Might be looked up at runtime. Do not cache this.
83100 public var original : MethodSignature {
84- preconditionFailure ( " Always override " )
101+ if let strategy = self . strategy as? ClassHookStrategy < MethodSignature > {
102+ return strategy. original
103+ } else {
104+ preconditionFailure ( " Not implemented " )
105+ }
85106 }
107+
86108}
Original file line number Diff line number Diff line change @@ -26,19 +26,6 @@ extension Interpose {
2626 strategyProvider: strategyProvider
2727 )
2828 }
29-
30- override func replaceImplementation( ) throws {
31- try ( self . strategy as! ClassHookStrategy < MethodSignature > ) . replaceImplementation ( )
32- }
33-
34- override func resetImplementation( ) throws {
35- try ( self . strategy as! ClassHookStrategy < MethodSignature > ) . resetImplementation ( )
36- }
37-
38- /// The original implementation is cached at hook time.
39- public override var original : MethodSignature {
40- ( self . strategy as! ClassHookStrategy < MethodSignature > ) . original
41- }
4229
4330 }
4431}
You can’t perform that action at this time.
0 commit comments