diff --git a/Interop/Indexer/src/main/kotlin/org/jetbrains/kotlin/native/interop/indexer/Utils.kt b/Interop/Indexer/src/main/kotlin/org/jetbrains/kotlin/native/interop/indexer/Utils.kt index 8c6ba62f60b..8e208c110f3 100644 --- a/Interop/Indexer/src/main/kotlin/org/jetbrains/kotlin/native/interop/indexer/Utils.kt +++ b/Interop/Indexer/src/main/kotlin/org/jetbrains/kotlin/native/interop/indexer/Utils.kt @@ -139,10 +139,10 @@ internal fun visitChildren(parent: CValue, visitor: CursorVisitor) { val visitorPtr = StableObjPtr.create(visitor) try { val clientData = visitorPtr.value - clang_visitChildren(parent, staticCFunction { cursor, parent, clientData -> - @Suppress("NAME_SHADOWING", "UNCHECKED_CAST") - val visitor = StableObjPtr.fromValue(clientData!!).get() as CursorVisitor - visitor(cursor, parent) + clang_visitChildren(parent, staticCFunction { cursorIt, parentIt, clientDataIt -> + @Suppress("UNCHECKED_CAST") + val visitorIt = StableObjPtr.fromValue(clientDataIt!!).get() as CursorVisitor + visitorIt(cursorIt, parentIt) }, clientData) } finally { visitorPtr.dispose() @@ -345,16 +345,20 @@ internal fun indexTranslationUnit(index: CXIndex, translationUnit: CXTranslation val indexerCallbacks = alloc().apply { abortQuery = null diagnostic = null - enteredMainFile = staticCFunction { clientData, mainFile, reserved -> + enteredMainFile = staticCFunction { clientData, mainFile, _ -> @Suppress("NAME_SHADOWING") val indexer = StableObjPtr.fromValue(clientData!!).get() as Indexer indexer.enteredMainFile(mainFile!!) + // We must ensure only interop types exist in function signature. + @Suppress("USELESS_CAST") null as CXIdxClientFile? } ppIncludedFile = staticCFunction { clientData, info -> @Suppress("NAME_SHADOWING") val indexer = StableObjPtr.fromValue(clientData!!).get() as Indexer indexer.ppIncludedFile(info!!.pointed) + // We must ensure only interop types exist in function signature. + @Suppress("USELESS_CAST") null as CXIdxClientFile? } importedASTFile = null diff --git a/Interop/Runtime/src/jvm/kotlin/kotlinx/cinterop/JvmCallbacks.kt b/Interop/Runtime/src/jvm/kotlin/kotlinx/cinterop/JvmCallbacks.kt index c7310a0ad90..6c0c733ee10 100644 --- a/Interop/Runtime/src/jvm/kotlin/kotlinx/cinterop/JvmCallbacks.kt +++ b/Interop/Runtime/src/jvm/kotlin/kotlinx/cinterop/JvmCallbacks.kt @@ -258,7 +258,7 @@ private fun createStaticCFunctionImpl( val impl: FfiClosureImpl = when (arity) { 0 -> { val f = function as () -> Any? - ffiClosureImpl(returnType) { args -> + ffiClosureImpl(returnType) { _ -> f() } } diff --git a/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/MappingBridgeGeneratorImpl.kt b/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/MappingBridgeGeneratorImpl.kt index 6259f82b506..d5dc7b1f401 100644 --- a/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/MappingBridgeGeneratorImpl.kt +++ b/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/MappingBridgeGeneratorImpl.kt @@ -123,7 +123,7 @@ class MappingBridgeGeneratorImpl( val bridgeArguments = mutableListOf() - nativeValues.forEachIndexed { index, (type, value) -> + nativeValues.forEachIndexed { _, (type, value) -> val bridgeArgument = if (type.unwrapTypedefs() is RecordType) { BridgeTypedNativeValue(BridgedType.NATIVE_PTR, "&$value") } else { diff --git a/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/ObjCStubs.kt b/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/ObjCStubs.kt index d555a2927de..e39dd188376 100644 --- a/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/ObjCStubs.kt +++ b/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/ObjCStubs.kt @@ -25,7 +25,7 @@ private fun ObjCMethod.getKotlinParameterNames(): List { val result = mutableListOf() // The names of all parameters except first must depend only on the selector: - this.parameters.forEachIndexed { index, parameter -> + this.parameters.forEachIndexed { index, _ -> if (index > 0) { var name = selectorParts[index] if (name.isEmpty()) { diff --git a/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2Native.kt b/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2Native.kt index 9dbdaf9789a..c63353c4d5b 100644 --- a/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2Native.kt +++ b/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2Native.kt @@ -39,6 +39,7 @@ import kotlin.reflect.KFunction private fun maybeExecuteHelper(targetName: String) { try { val kClass = Class.forName("org.jetbrains.kotlin.konan.Helper0").kotlin + @Suppress("UNCHECKED_CAST") val ctor = kClass.constructors.single() as KFunction val distribution = Distribution(TargetManager(targetName)) val result = ctor.call( diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt index ead9debdbf3..a568db717d0 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt @@ -127,7 +127,7 @@ internal fun produceOutput(context: Context) { llvmModule, nopack, manifest, - context.moduleEscapeAnalysisResult?.build()?.toByteArray()) + context.moduleEscapeAnalysisResult.build().toByteArray()) context.library = library context.bitcodeFileName = library.mainBitcodeFileName diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/LlvmUtils.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/LlvmUtils.kt index f0d58d77f4f..83f46aac599 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/LlvmUtils.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/LlvmUtils.kt @@ -150,7 +150,7 @@ internal fun structType(types: List): LLVMTypeRef = internal fun ContextUtils.numParameters(functionType: LLVMTypeRef) : Int { // Note that type is usually function pointer, so we have to dereference it. - return LLVMCountParamTypes(LLVMGetElementType(functionType))!! + return LLVMCountParamTypes(LLVMGetElementType(functionType)) } internal fun ContextUtils.isObjectReturn(functionType: LLVMTypeRef) : Boolean { diff --git a/gradle.properties b/gradle.properties index 7671710d0cb..2c6bc876e77 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,7 +14,7 @@ # limitations under the License. # -kotlin_version=1.1.3 +kotlin_version=1.1.4 llvmVersion = 3.9.0 remoteRoot=konan_tests #kotlinCompilerModule=org.jetbrains.kotlin:kotlin-compiler:1.1-SNAPSHOT