Use Java 7+ diamond operator in compiler modules
This commit is contained in:
@@ -97,7 +97,7 @@ public abstract class AbstractControlFlowTest extends AbstractPseudocodeTest {
|
||||
if (natural == null) {
|
||||
return actual.isEmpty();
|
||||
}
|
||||
return Collections.singleton(natural).equals(new HashSet<Instruction>(actual));
|
||||
return Collections.singleton(natural).equals(new HashSet<>(actual));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -47,7 +47,7 @@ public class CFGraphToDotFilePrinter {
|
||||
|
||||
out.println("digraph " + FileUtil.getNameWithoutExtension(file) + " {");
|
||||
int[] count = new int[1];
|
||||
Map<Instruction, String> nodeToName = new HashMap<Instruction, String>();
|
||||
Map<Instruction, String> nodeToName = new HashMap<>();
|
||||
for (Pseudocode pseudocode : pseudocodes) {
|
||||
dumpNodes(pseudocode.getInstructionsIncludingDeadCode(), out, count, nodeToName, Sets
|
||||
.newHashSet(pseudocode.getInstructions()));
|
||||
|
||||
@@ -54,7 +54,7 @@ public abstract class AbstractCliTest extends TestCaseWithTmpdir {
|
||||
try {
|
||||
System.setErr(new PrintStream(bytes));
|
||||
ExitCode exitCode = CLICompiler.doMainNoExit(compiler, ArrayUtil.toStringArray(args));
|
||||
return new Pair<String, ExitCode>(bytes.toString("utf-8"), exitCode);
|
||||
return new Pair<>(bytes.toString("utf-8"), exitCode);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw ExceptionUtilsKt.rethrow(e);
|
||||
@@ -97,7 +97,7 @@ public abstract class AbstractCliTest extends TestCaseWithTmpdir {
|
||||
}
|
||||
|
||||
private void doTestAdditionalChecks(@NotNull File testConfigFile) throws IOException {
|
||||
List<String> diagnostics = new ArrayList<String>(0);
|
||||
List<String> diagnostics = new ArrayList<>(0);
|
||||
String content = FilesKt.readText(testConfigFile, Charsets.UTF_8);
|
||||
|
||||
List<String> existsList = InTextDirectivesUtils.findListWithPrefixes(content, "// EXISTS: ");
|
||||
|
||||
@@ -137,7 +137,7 @@ public class InnerClassInfoGenTest extends CodegenTestCase {
|
||||
assertNotNull(outputFile);
|
||||
byte[] bytes = outputFile.asByteArray();
|
||||
ClassReader reader = new ClassReader(bytes);
|
||||
List<InnerClassAttribute> result = new ArrayList<InnerClassAttribute>();
|
||||
List<InnerClassAttribute> result = new ArrayList<>();
|
||||
|
||||
reader.accept(new ClassVisitor(ASM5) {
|
||||
@Override
|
||||
|
||||
@@ -378,7 +378,7 @@ public class PackageGenTest extends CodegenTestCase {
|
||||
public void testSubstituteJavaMethodTypeParameters() throws Exception {
|
||||
loadText("import java.util.*; fun foo(l: ArrayList<Int>) { l.add(10) }");
|
||||
Method main = generateFunction();
|
||||
ArrayList<Integer> l = new ArrayList<Integer>();
|
||||
ArrayList<Integer> l = new ArrayList<>();
|
||||
main.invoke(null, l);
|
||||
assertEquals(10, l.get(0).intValue());
|
||||
}
|
||||
@@ -399,7 +399,7 @@ public class PackageGenTest extends CodegenTestCase {
|
||||
public void testJavaInterfaceMethod() throws Exception {
|
||||
loadText("import java.util.*; fun foo(l: ArrayList<String>) { l.add(\"foo\") }");
|
||||
Method main = generateFunction();
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
main.invoke(null, list);
|
||||
assertEquals("foo", list.get(0));
|
||||
}
|
||||
@@ -407,7 +407,7 @@ public class PackageGenTest extends CodegenTestCase {
|
||||
public void testArrayAccessForArrayList() throws Exception {
|
||||
loadText("import java.util.*; fun foo(l: ArrayList<String>) { l[0] = \"Kotlin\" + l[0]; }");
|
||||
Method main = generateFunction();
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
list.add("Language");
|
||||
main.invoke(null, list);
|
||||
assertEquals("KotlinLanguage", list.get(0));
|
||||
|
||||
@@ -32,7 +32,7 @@ public abstract class CompilerSmokeTestBase extends KotlinIntegrationTestBase {
|
||||
}
|
||||
|
||||
protected int runCompiler(String logName, String... arguments) throws Exception {
|
||||
Collection<String> javaArgs = new ArrayList<String>();
|
||||
Collection<String> javaArgs = new ArrayList<>();
|
||||
|
||||
javaArgs.add("-cp");
|
||||
javaArgs.add(StringsKt.join(Arrays.asList(
|
||||
|
||||
+4
-4
@@ -103,7 +103,7 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
|
||||
@NotNull CLICompiler<?> compiler, @NotNull String sourcePath, @NotNull File destination, List<String> additionalOptions, @NotNull File... extraClassPath
|
||||
) {
|
||||
Pair<String, ExitCode> output = compileKotlin(compiler, sourcePath, destination, additionalOptions, extraClassPath);
|
||||
Assert.assertEquals(normalizeOutput(new Pair<String, ExitCode>("", ExitCode.OK)), normalizeOutput(output));
|
||||
Assert.assertEquals(normalizeOutput(new Pair<>("", ExitCode.OK)), normalizeOutput(output));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -135,7 +135,7 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
|
||||
|
||||
@NotNull
|
||||
private KotlinCoreEnvironment createEnvironment(@NotNull List<File> extraClassPath) {
|
||||
List<File> extras = new ArrayList<File>();
|
||||
List<File> extras = new ArrayList<>();
|
||||
extras.addAll(extraClassPath);
|
||||
extras.add(KotlinTestUtils.getAnnotationsJar());
|
||||
|
||||
@@ -233,7 +233,7 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
|
||||
@NotNull List<String> additionalOptions,
|
||||
@NotNull File... classpath
|
||||
) {
|
||||
List<String> args = new ArrayList<String>();
|
||||
List<String> args = new ArrayList<>();
|
||||
File sourceFile = new File(getTestDataDirectory(), fileName);
|
||||
assert sourceFile.exists() : "Source file does not exist: " + sourceFile.getAbsolutePath();
|
||||
args.add(sourceFile.getPath());
|
||||
@@ -553,7 +553,7 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
|
||||
|
||||
compileKotlin("source.kt", tmpdir, tmpdir);
|
||||
|
||||
Ref<String> debugInfo = new Ref<String>();
|
||||
Ref<String> debugInfo = new Ref<>();
|
||||
File resultFile = new File(tmpdir.getAbsolutePath(), "test/B.class");
|
||||
new ClassReader(FilesKt.readBytes(resultFile)).accept(new ClassVisitor(Opcodes.ASM5) {
|
||||
@Override
|
||||
|
||||
@@ -30,7 +30,7 @@ public class FqNameTest {
|
||||
|
||||
for (String name : new String[] { "org", "org.jetbrains", "org.jetbrains.kotlin" }) {
|
||||
List<Name> segments = new FqName(name).pathSegments();
|
||||
List<String> segmentsStrings = new ArrayList<String>();
|
||||
List<String> segmentsStrings = new ArrayList<>();
|
||||
for (Name segment : segments) {
|
||||
segmentsStrings.add(segment.asString());
|
||||
}
|
||||
|
||||
@@ -318,7 +318,7 @@ public class StorageManagerTest extends TestCase {
|
||||
CounterImpl counter = new CounterImpl();
|
||||
NotNullLazyValue<Collection<String>> v = m.createLazyValueWithPostCompute(
|
||||
() -> {
|
||||
List<String> strings = new ArrayList<String>();
|
||||
List<String> strings = new ArrayList<>();
|
||||
strings.add("first");
|
||||
return strings;
|
||||
},
|
||||
@@ -339,7 +339,7 @@ public class StorageManagerTest extends TestCase {
|
||||
CounterImpl counter = new CounterImpl();
|
||||
NullableLazyValue<Collection<String>> v = m.createNullableLazyValueWithPostCompute(
|
||||
() -> {
|
||||
ArrayList<String> strings = new ArrayList<String>();
|
||||
ArrayList<String> strings = new ArrayList<>();
|
||||
strings.add("first");
|
||||
return strings;
|
||||
},
|
||||
|
||||
@@ -505,7 +505,7 @@ public class KotlinTypeCheckerTest extends KotlinTestWithEnvironment {
|
||||
}
|
||||
|
||||
private void assertIntersection(String expected, String... types) {
|
||||
Set<KotlinType> typesToIntersect = new LinkedHashSet<KotlinType>();
|
||||
Set<KotlinType> typesToIntersect = new LinkedHashSet<>();
|
||||
for (String type : types) {
|
||||
typesToIntersect.add(makeType(type));
|
||||
}
|
||||
@@ -515,7 +515,7 @@ public class KotlinTypeCheckerTest extends KotlinTestWithEnvironment {
|
||||
}
|
||||
|
||||
private void assertCommonSupertype(String expected, String... types) {
|
||||
Collection<KotlinType> subtypes = new ArrayList<KotlinType>();
|
||||
Collection<KotlinType> subtypes = new ArrayList<>();
|
||||
for (String type : types) {
|
||||
subtypes.add(makeType(type));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user