diff --git a/GoogleUtilities/Example/Tests/Swizzler/GULAppDelegateSwizzlerTest.m b/GoogleUtilities/Example/Tests/Swizzler/GULAppDelegateSwizzlerTest.m index 1452aec7f84..e9fa793be9d 100644 --- a/GoogleUtilities/Example/Tests/Swizzler/GULAppDelegateSwizzlerTest.m +++ b/GoogleUtilities/Example/Tests/Swizzler/GULAppDelegateSwizzlerTest.m @@ -181,7 +181,8 @@ - (BOOL)application:(UIApplication *)application - (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity - restorationHandler:(void (^)(NSArray *__nullable restorableObjects))restorationHandler { + restorationHandler:(void (^)(NSArray> *__nullable + restorableObjects))restorationHandler { _userActivity = userActivity; return YES; } @@ -261,7 +262,7 @@ - (void)testHandleBackgroundSessionMethod { UIApplication *currentApplication = [UIApplication sharedApplication]; NSString *sessionID = @"123"; - void (^nilHandler)() = nil; + void (^nilHandler)(void) = nil; [realAppDelegate application:currentApplication handleEventsForBackgroundURLSession:sessionID completionHandler:nilHandler]; @@ -274,8 +275,11 @@ - (void)testHandleBackgroundSessionMethod { /** Tests registering and unregistering invalid interceptors. */ - (void)testInvalidInterceptor { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wnonnull" XCTAssertThrows([GULAppDelegateSwizzler registerAppDelegateInterceptor:nil], @"Should not register nil interceptor"); +#pragma clang diagnostic pop XCTAssertEqual([GULAppDelegateSwizzler interceptors].count, 0); // Try to register some random object that does not conform to UIApplicationDelegate. @@ -303,6 +307,8 @@ - (void)testInvalidInterceptor { XCTAssertEqual([GULAppDelegateSwizzler interceptors].count, 1); // Try to unregister an empty string. Should not remove anything. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wnonnull" XCTAssertThrows([GULAppDelegateSwizzler unregisterAppDelegateInterceptorWithID:nil], @"Should not unregister nil interceptorID"); XCTAssertEqual([GULAppDelegateSwizzler interceptors].count, 1); diff --git a/GoogleUtilities/Example/Tests/Swizzler/GULSwizzlerInheritedMethodsSwizzlingTest.m b/GoogleUtilities/Example/Tests/Swizzler/GULSwizzlerInheritedMethodsSwizzlingTest.m index 48cfd206911..9137b62e3ee 100644 --- a/GoogleUtilities/Example/Tests/Swizzler/GULSwizzlerInheritedMethodsSwizzlingTest.m +++ b/GoogleUtilities/Example/Tests/Swizzler/GULSwizzlerInheritedMethodsSwizzlingTest.m @@ -110,15 +110,16 @@ - (void)testSwizzlingAndUnswizzlingInheritedInstanceMethodsForSuperclassesWorksA NSString *swizzledPollutedTestObjectSubclassSubclassDescription = [originalPollutedTestObjectSubclassSubclassDescription stringByAppendingString:@"SWIZZLED!"]; - NSString * (^newImplementationPollutedTestObject)() = ^NSString *(id _self) { + NSString * (^newImplementationPollutedTestObject)(NSString *) = ^NSString *(id _self) { return swizzledPollutedTestObjectDescription; }; - NSString * (^newImplementationPollutedTestObjectSubclass)() = ^NSString *(id _self) { + NSString * (^newImplementationPollutedTestObjectSubclass)(NSString *) = ^NSString *(id _self) { return swizzledPollutedTestObjectSubclassDescription; }; - NSString * (^newImplementationPollutedTestObjectSubclassSubclass)() = ^NSString *(id _self) { + NSString * (^newImplementationPollutedTestObjectSubclassSubclass)(NSString *) = + ^NSString *(id _self) { return swizzledPollutedTestObjectSubclassSubclassDescription; }; diff --git a/GoogleUtilities/Example/Tests/Swizzler/GULSwizzlerTest.m b/GoogleUtilities/Example/Tests/Swizzler/GULSwizzlerTest.m index f7650730a79..e4cd2888f61 100644 --- a/GoogleUtilities/Example/Tests/Swizzler/GULSwizzlerTest.m +++ b/GoogleUtilities/Example/Tests/Swizzler/GULSwizzlerTest.m @@ -69,7 +69,7 @@ @implementation GULSwizzlerTest - (void)testOriginalImpInstanceMethod { Method method = class_getInstanceMethod([NSObject class], @selector(description)); IMP originalImp = method_getImplementation(method); - NSString * (^newImplementation)() = ^NSString *() { + NSString * (^newImplementation)(void) = ^NSString *() { return @"nonsense"; }; @@ -155,7 +155,7 @@ - (void)testOriginalImpCallThrough { - (void)testOriginalImpClassMethod { Method method = class_getInstanceMethod([NSObject class], @selector(description)); IMP originalImp = method_getImplementation(method); - NSString * (^newImplementation)() = ^NSString *() { + NSString * (^newImplementation)(void) = ^NSString *() { return @"nonsense"; }; @@ -179,7 +179,7 @@ - (void)testOriginalImpInstanceAndClassImpsAreDifferent { IMP instanceImp = method_getImplementation(instanceMethod); IMP classImp = method_getImplementation(classMethod); - NSString * (^newImplementation)() = ^NSString *() { + NSString * (^newImplementation)(void) = ^NSString *() { return @"nonsense"; }; @@ -208,7 +208,7 @@ - (void)testOriginalImpInstanceAndClassImpsAreDifferent { /** Tests swizzling an instance method. */ - (void)testSwizzleInstanceMethod { NSString *swizzledDescription = @"Not what you expected!"; - NSString * (^newImplementation)() = ^NSString *() { + NSString * (^newImplementation)(void) = ^NSString *() { return swizzledDescription; }; @@ -224,7 +224,7 @@ - (void)testSwizzleInstanceMethod { /** Tests swizzling a class method. */ - (void)testSwizzleClassMethod { NSString *swizzledDescription = @"Swizzled class description"; - NSString * (^newImplementation)() = ^NSString *() { + NSString * (^newImplementation)(void) = ^NSString *() { return swizzledDescription; }; @@ -241,7 +241,7 @@ - (void)testUnswizzleInstanceMethod { NSObject *object = [[NSObject alloc] init]; NSString *originalDescription = [object description]; NSString *swizzledDescription = @"Swizzled description"; - NSString * (^newImplementation)() = ^NSString *() { + NSString * (^newImplementation)(void) = ^NSString *() { return swizzledDescription; }; @@ -260,7 +260,7 @@ - (void)testUnswizzleInstanceMethod { - (void)testUnswizzleClassMethod { NSString *originalDescription = [NSObject description]; NSString *swizzledDescription = @"Swizzled class description"; - NSString * (^newImplementation)() = ^NSString *() { + NSString * (^newImplementation)(void) = ^NSString *() { return swizzledDescription; }; @@ -276,7 +276,7 @@ - (void)testUnswizzleClassMethod { /** Tests swizzling a class method doesn't swizzle an instance method of the same name. */ - (void)testSwizzlingAClassMethodDoesntSwizzleAnInstanceMethod { NSString *swizzledDescription = @"Swizzled class description"; - NSString * (^newImplementation)() = ^NSString *() { + NSString * (^newImplementation)(void) = ^NSString *() { return swizzledDescription; }; @@ -292,7 +292,7 @@ - (void)testSwizzlingAClassMethodDoesntSwizzleAnInstanceMethod { /** Tests swizzling an instance method doesn't swizzle a class method of the same name. */ - (void)testSwizzlingAnInstanceMethodDoesntSwizzleAClassMethod { NSString *swizzledDescription = @"Not what you expected!"; - NSString * (^newImplementation)() = ^NSString *() { + NSString * (^newImplementation)(void) = ^NSString *() { return swizzledDescription; }; @@ -310,7 +310,7 @@ - (void)testSwizzlingAnInstanceMethodDoesntSwizzleAClassMethod { - (void)testSwizzlingSuperclassInstanceMethod { NSObject *generalObject = [[NSObject alloc] init]; BOOL generalObjectIsProxyValue = [generalObject isProxy]; - BOOL (^newImplementation)() = ^BOOL() { + BOOL (^newImplementation)(void) = ^BOOL() { return !generalObjectIsProxyValue; }; @@ -325,7 +325,7 @@ - (void)testSwizzlingSuperclassInstanceMethod { /** Tests swizzling a superclass's class method. */ - (void)testSwizzlingSuperclassClassMethod { NSString *swizzledDescription = @"Swizzled class description"; - NSString * (^newImplementation)() = ^NSString *() { + NSString * (^newImplementation)(void) = ^NSString *() { return swizzledDescription; }; @@ -344,7 +344,7 @@ - (void)testSwizzlingInstanceMethodThatCallsSuper { TestObject *testObject = [[TestObject alloc] init]; NSString *originalDescription = [testObject description]; NSString *swizzledDescription = [originalDescription stringByAppendingString:@"SWIZZLED!"]; - NSString * (^newImplementation)() = ^NSString *() { + NSString * (^newImplementation)(void) = ^NSString *() { return swizzledDescription; }; @@ -492,7 +492,7 @@ - (void)testSwizzlingInstanceMethodIsEffectiveOnMultipleInstancesOfSameClass { - (void)testSwizzlingClassMethodThatCallsSuper { NSString *originalDescription = [TestObject description]; NSString *swizzledDescription = @"Swizzled class description"; - NSString * (^newImplementation)() = ^NSString *() { + NSString * (^newImplementation)(void) = ^NSString *() { return swizzledDescription; }; @@ -513,7 +513,7 @@ - (void)testSwizzlingClassMethodThatCallsSuper { - (void)testSwizzlingAnInheritedInstanceMethodDoesntAffectTheIMPOfItsSuperclass { NSObject *generalObject = [[NSObject alloc] init]; BOOL originalGeneralObjectValue = [generalObject isProxy]; - BOOL (^newImplementation)() = ^BOOL() { + BOOL (^newImplementation)(void) = ^BOOL(void) { return !originalGeneralObjectValue; }; @@ -533,7 +533,7 @@ - (void)testSwizzlingAnInheritedInstanceMethodDoesntAffectTheIMPOfItsSuperclass - (void)testSwizzlingADeeperInheritedInstanceMethodDoesntAffectTheIMPOfItsSuperclass { TestObject *testObject = [[TestObject alloc] init]; BOOL originalTestObjectValue = [testObject isProxy]; - BOOL (^newImplementation)() = ^BOOL() { + BOOL (^newImplementation)(void) = ^BOOL(void) { return !originalTestObjectValue; }; @@ -556,7 +556,7 @@ - (void)testSwizzlingAnInheritedClassMethodDoesntAffectTheIMPOfItsSuperclass { // Fun fact, this won't work on +new. Swizzling +new causes a retain to not be placed correctly. NSString *originalDescription = [TestObject description]; NSString *swizzledDescription = [originalDescription stringByAppendingString:@"SWIZZLED!"]; - NSString * (^newImplementation)() = ^NSString *() { + NSString * (^newImplementation)(void) = ^NSString *() { return swizzledDescription; }; @@ -579,7 +579,7 @@ - (void)testSwizzlingAnInheritedClassMethodDoesntAffectTheIMPOfItsSuperclass { - (void)testSwizzlingADeeperInheritedClassMethodDoesntAffectTheIMPOfItsSuperclass { NSString *originalDescription = [TestObjectSubclass description]; NSString *swizzledDescription = [originalDescription stringByAppendingString:@"SWIZZLED!"]; - NSString * (^newImplementation)() = ^NSString *() { + NSString * (^newImplementation)(void) = ^NSString *() { return swizzledDescription; };