From 453afd650f54829c9a3b78e677224db65cfa274e Mon Sep 17 00:00:00 2001 From: hellohuanlin <41930132+hellohuanlin@users.noreply.github.com> Date: Fri, 15 Nov 2024 12:25:17 -0800 Subject: [PATCH] [macos] early return to suppress clang-tidy warning (flutter/engine#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 --- .../framework/Source/FlutterChannelKeyResponder.mm | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterChannelKeyResponder.mm b/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterChannelKeyResponder.mm index 98abd505d4..d3f1551533 100644 --- a/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterChannelKeyResponder.mm +++ b/engine/src/flutter/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 = [@{