You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Wrong lookup behavior in super trampoline when subclasses override below injection #21
Originally pointed out in this discussion. When installing the super trampoline into a class hierarchy, if a subclass below the injection point overrides the method, the lookup logic in ITKReturnThreadSuper(…) misroutes to the nearest override, potentially causing infinite recursion.
Reproduction
importITKSuperBuilderimportXCTestfinalclassTrampolineTests:XCTestCase{functestTrampolineEdgeCase()throws{
// Inject our super trampoline into `Level2` for `sayHello()`.
tryITKSuperBuilder.addSuperInstanceMethod(to:Level2.self,selector:#selector(Level2.sayHello))
// Create a `Level4` instance and call `sayHello()`. We expect this to eventually
// call `Level1`’s implementation exactly once. However, due to the broken lookup
// logic in `ITKReturnThreadSuper(…)`, it will loop forever between Level3 overrides.
letobject=Level4()object.sayHello()}}classLevel1:NSObject{@objcdynamicfuncsayHello(){print("Level1 says hello")}}classLevel2:Level1{
// No override here. This is where we install the trampoline.
}classLevel3:Level2{@objcdynamicoverridefuncsayHello(){print("Level3 says hello")super.sayHello()}}classLevel4:Level3{@objcdynamicoverridefuncsayHello(){print("Level4 says hello")super.sayHello()}}
Activity