Fix most unchecked/deprecation javac warnings in compiler modules
This commit is contained in:
+7
-15
@@ -16,9 +16,10 @@
|
||||
|
||||
package org.jetbrains.kotlin.codegen;
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import kotlin.collections.CollectionsKt;
|
||||
import kotlin.io.FilesKt;
|
||||
import kotlin.sequences.SequencesKt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles;
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment;
|
||||
@@ -28,28 +29,19 @@ import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||
import org.jetbrains.kotlin.test.TestJdkKind;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class AbstractTopLevelMembersInvocationTest extends AbstractBytecodeTextTest {
|
||||
|
||||
private static final String LIBRARY = "library";
|
||||
|
||||
@Override
|
||||
public void doTest(@NotNull String filename) throws Exception {
|
||||
File root = new File(filename);
|
||||
List<String> sourceFiles = new ArrayList<>(2);
|
||||
List<String> sourceFiles = SequencesKt.toList(SequencesKt.map(
|
||||
SequencesKt.filter(FilesKt.walkTopDown(root).maxDepth(1), File::isFile),
|
||||
this::relativePath
|
||||
));
|
||||
|
||||
FileUtil.processFilesRecursively(root, file -> {
|
||||
if (file.getName().endsWith(".kt")) {
|
||||
sourceFiles.add(relativePath(file));
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}, file -> !LIBRARY.equals(file.getName()));
|
||||
|
||||
File library = new File(root, LIBRARY);
|
||||
File library = new File(root, "library");
|
||||
List<File> classPath =
|
||||
library.exists()
|
||||
? Collections.singletonList(CompilerTestUtil.compileJvmLibrary(library))
|
||||
|
||||
@@ -308,7 +308,7 @@ public abstract class CodegenTestCase extends KtUsefulTestCase {
|
||||
assert configurationKeyField != null : "Expected [+|-][namespace.]configurationKey, got: " + flag;
|
||||
|
||||
try {
|
||||
//noinspection unchecked
|
||||
@SuppressWarnings("unchecked")
|
||||
CompilerConfigurationKey<Boolean> configurationKey = (CompilerConfigurationKey<Boolean>) configurationKeyField.get(null);
|
||||
configuration.put(configurationKey, flagEnabled);
|
||||
}
|
||||
@@ -615,9 +615,9 @@ public abstract class CodegenTestCase extends KtUsefulTestCase {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@SuppressWarnings("unchecked")
|
||||
public Class<? extends Annotation> loadAnnotationClassQuietly(@NotNull String fqName) {
|
||||
try {
|
||||
//noinspection unchecked
|
||||
return (Class<? extends Annotation>) initializedClassLoader.loadClass(fqName);
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
|
||||
+1
-1
@@ -70,11 +70,11 @@ public abstract class KtPlatformLiteFixture extends KtUsefulTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T registerComponentInstance(MutablePicoContainer container, Class<T> key, T implementation) {
|
||||
Object old = container.getComponentInstance(key);
|
||||
container.unregisterComponent(key);
|
||||
container.registerComponentInstance(key, implementation);
|
||||
//noinspection unchecked
|
||||
return (T)old;
|
||||
}
|
||||
}
|
||||
|
||||
+7
-2
@@ -180,6 +180,7 @@ public abstract class KtUsefulTestCase extends TestCase {
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<String> files = ReflectionUtil.getStaticFieldValue(aClass, Set.class, "files");
|
||||
DELETE_ON_EXIT_HOOK_CLASS = aClass;
|
||||
DELETE_ON_EXIT_HOOK_DOT_FILES = files;
|
||||
@@ -307,7 +308,9 @@ public abstract class KtUsefulTestCase extends TestCase {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (Object o : collection) {
|
||||
if (o instanceof THashSet) {
|
||||
builder.append(new TreeSet<Object>((THashSet)o));
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<Object> set = new TreeSet<Object>((THashSet) o);
|
||||
builder.append(set);
|
||||
}
|
||||
else {
|
||||
builder.append(o);
|
||||
@@ -317,6 +320,7 @@ public abstract class KtUsefulTestCase extends TestCase {
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
private static <T> void assertOrderedEquals(String errorMsg, @NotNull Iterable<T> actual, @NotNull T... expected) {
|
||||
Assert.assertNotNull(actual);
|
||||
Assert.assertNotNull(expected);
|
||||
@@ -339,10 +343,12 @@ public abstract class KtUsefulTestCase extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
public static <T> void assertSameElements(T[] collection, T... expected) {
|
||||
assertSameElements(Arrays.asList(collection), expected);
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
public static <T> void assertSameElements(Collection<? extends T> collection, T... expected) {
|
||||
assertSameElements(collection, Arrays.asList(expected));
|
||||
}
|
||||
@@ -388,7 +394,6 @@ public abstract class KtUsefulTestCase extends TestCase {
|
||||
}
|
||||
|
||||
protected static <T> void assertEmpty(String errorMsg, Collection<T> collection) {
|
||||
//noinspection unchecked
|
||||
assertOrderedEquals(errorMsg, collection);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user