Index: clang/lib/Format/Format.cpp =================================================================== --- clang/lib/Format/Format.cpp +++ clang/lib/Format/Format.cpp @@ -1960,7 +1960,7 @@ namespace { const char JavaImportRegexPattern[] = - "^[\t ]*import[\t ]*(static[\t ]*)?([^\t ]*)[\t ]*;"; + "^[\t ]*import[\t ]+(static[\t ]*)?([^\t ]*)[\t ]*;"; } // anonymous namespace Index: clang/unittests/Format/SortImportsTestJava.cpp =================================================================== --- clang/unittests/Format/SortImportsTestJava.cpp +++ clang/unittests/Format/SortImportsTestJava.cpp @@ -262,6 +262,21 @@ "import org.a;")); } +TEST_F(SortImportsTestJava, ImportNamedFunction) { + EXPECT_EQ("import X;\n" + "class C {\n" + " void m() {\n" + " importFile();\n" + " }\n" + "}\n", + sort("import X;\n" + "class C {\n" + " void m() {\n" + " importFile();\n" + " }\n" + "}\n")); +} + TEST_F(SortImportsTestJava, NoReplacementsForValidImports) { // Identical #includes have led to a failure with an unstable sort. std::string Code = "import org.a;\n"