Index: lib/Format/TokenAnnotator.cpp =================================================================== --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -372,7 +372,9 @@ updateParameterCount(Left, CurrentToken); if (CurrentToken->isOneOf(tok::colon, tok::l_brace)) { FormatToken *Previous = CurrentToken->getPreviousNonComment(); - if ((CurrentToken->is(tok::colon) || + if (((CurrentToken->is(tok::colon) && + (!Contexts.back().ColonIsDictLiteral || + Style.Language != FormatStyle::LK_Cpp)) || Style.Language == FormatStyle::LK_Proto) && Previous->is(tok::identifier)) Previous->Type = TT_SelectorName; Index: unittests/Format/FormatTest.cpp =================================================================== --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -7502,6 +7502,12 @@ " bbbbbbbbbbbbbbbbbb : bbbbb,\n" " cccccccccccccccc : ccccccccccccccc\n" " }];"); + + // Ensure that casts before the key are kept on the same line as the key + verifyFormat("NSDictionary *query = @{\n" + " (__bridge id)kSecClass : (__bridge id)kSecClassGenericPassword,\n" + " (__bridge id)kSecReturnData : (__bridge id)kCFBooleanTrue,\n" + "};"); } TEST_F(FormatTest, ObjCArrayLiterals) {