JVM_IR: Support @JvmSynthetic annotations.
This commit is contained in:
committed by
Georgy Bronnikov
parent
8bdc5f981e
commit
34cf5a19df
+3
-1
@@ -37,6 +37,7 @@ import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
|
||||
import org.jetbrains.kotlin.resolve.jvm.annotations.JVM_SYNTHETIC_ANNOTATION_FQ_NAME
|
||||
import org.jetbrains.kotlin.resolve.jvm.annotations.TRANSIENT_ANNOTATION_FQ_NAME
|
||||
import org.jetbrains.kotlin.resolve.jvm.annotations.VOLATILE_ANNOTATION_FQ_NAME
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin
|
||||
@@ -346,7 +347,8 @@ private val IrField.flags: Int
|
||||
(if (isFinal) Opcodes.ACC_FINAL else 0) or
|
||||
(if (isStatic) Opcodes.ACC_STATIC else 0) or
|
||||
(if (hasAnnotation(VOLATILE_ANNOTATION_FQ_NAME)) Opcodes.ACC_VOLATILE else 0) or
|
||||
(if (hasAnnotation(TRANSIENT_ANNOTATION_FQ_NAME)) Opcodes.ACC_TRANSIENT else 0)
|
||||
(if (hasAnnotation(TRANSIENT_ANNOTATION_FQ_NAME)) Opcodes.ACC_TRANSIENT else 0) or
|
||||
(if (hasAnnotation(JVM_SYNTHETIC_ANNOTATION_FQ_NAME)) Opcodes.ACC_SYNTHETIC else 0)
|
||||
|
||||
private val IrDeclarationOrigin.flags: Int
|
||||
get() = (if (isSynthetic) Opcodes.ACC_SYNTHETIC else 0) or
|
||||
|
||||
+5
-1
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.ir.expressions.*
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
|
||||
import org.jetbrains.kotlin.resolve.jvm.annotations.JVM_SYNTHETIC_ANNOTATION_FQ_NAME
|
||||
import org.jetbrains.kotlin.resolve.jvm.annotations.STRICTFP_ANNOTATION_FQ_NAME
|
||||
import org.jetbrains.kotlin.resolve.jvm.annotations.SYNCHRONIZED_ANNOTATION_FQ_NAME
|
||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodGenericSignature
|
||||
@@ -87,9 +88,12 @@ open class FunctionCodegen(
|
||||
else -> if (classCodegen.irClass.isJvmInterface && irFunction.body == null) Opcodes.ACC_ABSTRACT else 0 //TODO transform interface modality on lowering to DefaultImpls
|
||||
}
|
||||
val nativeFlag = if (irFunction.isExternal) Opcodes.ACC_NATIVE else 0
|
||||
val syntheticFlag = if (irFunction.origin.isSynthetic) Opcodes.ACC_SYNTHETIC else 0
|
||||
val syntheticFlag =
|
||||
if (irFunction.origin.isSynthetic || irFunction.hasAnnotation(JVM_SYNTHETIC_ANNOTATION_FQ_NAME)) Opcodes.ACC_SYNTHETIC
|
||||
else 0
|
||||
val strictFpFlag = if (irFunction.hasAnnotation(STRICTFP_ANNOTATION_FQ_NAME)) Opcodes.ACC_STRICT else 0
|
||||
val synchronizedFlag = if (irFunction.hasAnnotation(SYNCHRONIZED_ANNOTATION_FQ_NAME)) Opcodes.ACC_SYNCHRONIZED else 0
|
||||
|
||||
return visibility or
|
||||
modalityFlag or
|
||||
staticFlag or
|
||||
|
||||
@@ -17,6 +17,21 @@ class C {
|
||||
|
||||
@Strictfp fun str() {}
|
||||
@Synchronized fun sync() {}
|
||||
|
||||
@JvmSynthetic val synth = "ABC"
|
||||
|
||||
var synth2 = 5
|
||||
@JvmSynthetic public get
|
||||
@JvmSynthetic public set
|
||||
|
||||
@field:JvmSynthetic
|
||||
val synth3 = 0
|
||||
|
||||
@get:JvmSynthetic @set:JvmSynthetic
|
||||
var synth4 = 0
|
||||
|
||||
@JvmSynthetic
|
||||
fun synth5() {}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
@@ -29,5 +44,21 @@ fun box(): String {
|
||||
if (c.getDeclaredMethod("str").getModifiers() and Modifier.STRICT == 0) return "Fail: strict"
|
||||
if (c.getDeclaredMethod("sync").getModifiers() and Modifier.SYNCHRONIZED == 0) return "Fail: synchronized"
|
||||
|
||||
if (!c.getDeclaredField("synth").isSynthetic()) return "Fail: synthetic"
|
||||
if (c.getDeclaredMethod("getSynth").isSynthetic()) return "Fail: get synthetic"
|
||||
|
||||
if (c.getDeclaredField("synth2").isSynthetic()) return "Fail: synthetic 2"
|
||||
if (!c.getDeclaredMethod("getSynth2").isSynthetic()) return "Fail: get synthetic 2"
|
||||
if (!c.getDeclaredMethod("setSynth2", Int::class.java).isSynthetic()) return "Fail: set synthetic 2"
|
||||
|
||||
if (!c.getDeclaredField("synth3").isSynthetic()) return "Fail: synthetic 3"
|
||||
if (c.getDeclaredMethod("getSynth3").isSynthetic()) return "Fail: get synthetic 3"
|
||||
|
||||
if (c.getDeclaredField("synth4").isSynthetic()) return "Fail: synthetic 4"
|
||||
if (!c.getDeclaredMethod("getSynth4").isSynthetic()) return "Fail: get synthetic 4"
|
||||
if (!c.getDeclaredMethod("setSynth4", Int::class.java).isSynthetic()) return "Fail: set synthetic 4"
|
||||
|
||||
if (!c.getDeclaredMethod("synth5").isSynthetic()) return "Fail: synthetic 5"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user