[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
This commit is contained in:
hellohuanlin 2024-11-15 12:25:17 -08:00 committed by GitHub
parent 08b52b491b
commit 453afd650f

View File

@ -131,10 +131,13 @@
return; return;
} }
break; break;
default: { default:
NSAssert(false, @"Unexpected key event type (got %lu).", event.type); [[unlikely]] {
callback(false); 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; _previouslyPressedFlags = modifierFlags;
NSMutableDictionary* keyMessage = [@{ NSMutableDictionary* keyMessage = [@{