Fix @Retain annotation behavior. (#2068)

This commit is contained in:
Nikolay Igotti
2018-09-14 17:00:45 +03:00
committed by GitHub
parent 0853f2cec9
commit 1794f08638
3 changed files with 4 additions and 6 deletions
@@ -25,10 +25,8 @@ typealias Object = Int
typealias Pointer = Int
/**
* Used annotation is required to preserve functions
* from internalization and DCE
* @Retain annotation is required to preserve functions from internalization and DCE.
*/
@Retain
@SymbolName("Konan_js_allocateArena")
external public fun allocateArena(): Arena
@@ -738,7 +738,7 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
}
if (declaration.descriptor.usedAnnotation) {
if (declaration.descriptor.retainAnnotation) {
context.llvm.usedFunctions.add(codegen.llvmFunction(declaration))
}
@@ -9,9 +9,9 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.annotations.*
import org.jetbrains.kotlin.name.FqName
private val annotationName = FqName("kotlin.native.Used")
private val annotationName = FqName("kotlin.native.Retain")
internal val FunctionDescriptor.usedAnnotation: Boolean
internal val FunctionDescriptor.retainAnnotation: Boolean
get() {
return (this.annotations.findAnnotation(annotationName) != null)
}