[macos] early return to suppress clang-tidy warning (#56588)
If we disable the NSAssert during release mode, this code will continue after NSAssert failure, which will then pass a `nil` value into a dictionary (which cannot have a nil value), hence the clang-tidy warning here https://github.com/flutter/engine/pull/53005#issuecomment-2140975126
*List which issues are fixed by this PR. You must list at least one issue.*
https://github.com/flutter/flutter/issues/148279
https://github.com/flutter/flutter/issues/157837
*If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
diff --git a/shell/platform/darwin/macos/framework/Source/FlutterChannelKeyResponder.mm b/shell/platform/darwin/macos/framework/Source/FlutterChannelKeyResponder.mm
index 98abd50..d3f1551 100644
--- a/shell/platform/darwin/macos/framework/Source/FlutterChannelKeyResponder.mm
+++ b/shell/platform/darwin/macos/framework/Source/FlutterChannelKeyResponder.mm
@@ -131,10 +131,13 @@
return;
}
break;
- default: {
- NSAssert(false, @"Unexpected key event type (got %lu).", event.type);
- callback(false);
- }
+ default:
+ [[unlikely]] {
+ NSAssert(false, @"Unexpected key event type (got %lu).", event.type);
+ callback(false);
+ // This should not happen. Return to suppress clang-tidy warning on `type` being nil.
+ return;
+ }
}
_previouslyPressedFlags = modifierFlags;
NSMutableDictionary* keyMessage = [@{