Cleanup: fix some compiler warnings (mostly deprecations, javaClass)

This commit is contained in:
Mikhail Glukhikh
2017-02-21 17:38:43 +03:00
parent d0cc1635db
commit b121bf8802
445 changed files with 773 additions and 949 deletions
@@ -35,7 +35,7 @@ class WrongBytecodeVersionTest : KtUsefulTestCase() {
val librarySource = File(directory, "A.kt")
val usageSource = File(directory, "B.kt")
val tmpdir = KotlinTestUtils.tmpDir(javaClass.simpleName)
val tmpdir = KotlinTestUtils.tmpDir(this::class.java.simpleName)
val environment = KotlinTestUtils.createEnvironmentWithMockJdkAndIdeaAnnotations(testRootDisposable)
LoadDescriptorUtil.compileKotlinToDirAndGetModule(listOf(librarySource), tmpdir, environment)
@@ -148,7 +148,7 @@ internal class TestRepl(
}
private fun makeScriptDefinition(templateClasspath: List<File>, templateClassName: String): KotlinScriptDefinition {
val classloader = URLClassLoader(templateClasspath.map { it.toURI().toURL() }.toTypedArray(), this.javaClass.classLoader)
val classloader = URLClassLoader(templateClasspath.map { it.toURI().toURL() }.toTypedArray(), this::class.java.classLoader)
val cls = classloader.loadClass(templateClassName)
return KotlinScriptDefinitionFromAnnotatedTemplate(cls.kotlin, null, null, emptyMap())
}
@@ -144,7 +144,7 @@ abstract class AbstractWriteSignatureTest : TestCaseWithTmpdir() {
val classDir = classFile.parentFile
val classLastName = classFile.name
val packageFacadePrefix = classLastName.replace(".class", "\$")
classDir.listFiles { dir, lastName ->
classDir.listFiles { _, lastName ->
lastName.startsWith(packageFacadePrefix) && lastName.endsWith(".class")
}.forEach { packageFacadeFile ->
processClassFile(checker, packageFacadeFile)
@@ -278,7 +278,7 @@ class ScriptTemplateTest {
try {
return if (runIsolated) KotlinToJVMBytecodeCompiler.compileScript(environment, paths)
else KotlinToJVMBytecodeCompiler.compileScript(environment, this.javaClass.classLoader)
else KotlinToJVMBytecodeCompiler.compileScript(environment, this::class.java.classLoader)
}
catch (e: CompilationException) {
messageCollector.report(CompilerMessageSeverity.EXCEPTION, OutputMessageUtil.renderException(e),
@@ -333,15 +333,17 @@ class TestKotlinScriptDependenciesResolver : TestKotlinScriptDummyDependenciesRe
val cp = script.annotations.flatMap {
when (it) {
is DependsOn -> if (it.path == "@{runtime}") listOf(kotlinPaths.runtimePath, kotlinPaths.scriptRuntimePath) else listOf(File(it.path))
is DependsOnTwo -> listOf(it.path1, it.path2).flatMap { it?.let {
when {
it.isBlank() -> emptyList()
it == "@{runtime}" -> listOf(kotlinPaths.runtimePath, kotlinPaths.scriptRuntimePath)
else -> listOf(File(it))
is DependsOnTwo -> listOf(it.path1, it.path2).flatMap {
it.let {
when {
it.isBlank() -> emptyList()
it == "@{runtime}" -> listOf(kotlinPaths.runtimePath, kotlinPaths.scriptRuntimePath)
else -> listOf(File(it))
}
}
}}
}
is InvalidScriptResolverAnnotation -> throw Exception("Invalid annotation ${it.name}", it.error)
else -> throw Exception("Unknown annotation ${it.javaClass}")
else -> throw Exception("Unknown annotation ${it::class.java}")
}
}
return object : KotlinScriptExternalDependencies {
@@ -117,7 +117,7 @@ class ScriptTest : KtUsefulTestCase() {
try {
return if (runIsolated) KotlinToJVMBytecodeCompiler.compileScript(environment, paths)
else KotlinToJVMBytecodeCompiler.compileScript(environment, this.javaClass.classLoader)
else KotlinToJVMBytecodeCompiler.compileScript(environment, this::class.java.classLoader)
}
catch (e: CompilationException) {
messageCollector.report(CompilerMessageSeverity.EXCEPTION, OutputMessageUtil.renderException(e),
@@ -35,7 +35,7 @@ class BuiltInsSerializerTest : TestCaseWithTmpdir() {
tmpdir,
srcDirs = listOf(File(source)),
extraClassPath = listOf(ForTestCompileRuntime.runtimeJarForTests()),
onComplete = { totalSize, totalFiles -> }
onComplete = { _, _ -> }
)
val module = KotlinTestUtils.createEmptyModule("<module>", DefaultBuiltIns.Instance)