Index: lib/Format/Format.cpp =================================================================== --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -1983,7 +1983,7 @@ namespace { const char JavaImportRegexPattern[] = - "^[\t ]*import[\t ]*(static[\t ]*)?([^\t ]*)[\t ]*;"; + "^[\t ]*import[\t ]+(static[\t ]*)?([^\t ]*)[\t ]*;"; } // anonymous namespace Index: unittests/Format/SortImportsTestJava.cpp =================================================================== --- unittests/Format/SortImportsTestJava.cpp +++ 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"