diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 2b215fd09f9f..6d2b67c29c09 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -1375,9 +1375,10 @@ void UnwrappedLineParser::parseRecord() { } // The actual identifier can be a nested name specifier, and in macros // it is often token-pasted. - while (FormatTok->Tok.is(tok::identifier) || - FormatTok->Tok.is(tok::coloncolon) || - FormatTok->Tok.is(tok::hashhash)) + while ( + FormatTok->is(tok::identifier) || FormatTok->is(tok::coloncolon) || + FormatTok->is(tok::hashhash) || + (Style.Language == FormatStyle::LK_Java && FormatTok->is(tok::period))) nextToken(); // Note that parsing away template declarations here leads to incorrectly diff --git a/clang/unittests/Format/FormatTestJava.cpp b/clang/unittests/Format/FormatTestJava.cpp index cf48a7a11d12..a4e9396b0d8e 100644 --- a/clang/unittests/Format/FormatTestJava.cpp +++ b/clang/unittests/Format/FormatTestJava.cpp @@ -57,6 +57,7 @@ TEST_F(FormatTestJava, ClassDeclarations) { " int j;\n" " }\n" "}"); + verifyFormat("public class A extends B.C {}"); } TEST_F(FormatTestJava, ThrowsDeclarations) {