Support @JvmSynthetic in ultra-light classes

This commit is contained in:
Denis Zharkov
2018-11-20 16:05:02 +03:00
parent 91c86f7f56
commit 17328a442a
4 changed files with 26 additions and 1 deletions
@@ -194,6 +194,7 @@ class KtUltraLightClass(classOrObject: KtClassOrObject, private val support: Ult
private fun propertyField(property: KtProperty, generateUniqueName: (String) -> String, forceStatic: Boolean): KtLightField? {
if (!hasBackingField(property)) return null
if (property.hasAnnotation(JVM_SYNTHETIC_ANNOTATION_FQ_NAME)) return null
val hasDelegate = property.hasDelegate()
val fieldName = generateUniqueName((property.name ?: "") + (if (hasDelegate) "\$delegate" else ""))
@@ -312,6 +313,8 @@ class KtUltraLightClass(classOrObject: KtClassOrObject, private val support: Ult
override fun getOwnMethods(): List<KtLightMethod> = if (tooComplex) super.getOwnMethods() else _ownMethods
private fun asJavaMethods(ktFunction: KtFunction, forceStatic: Boolean): Collection<KtLightMethod> {
if (ktFunction.hasAnnotation(JVM_SYNTHETIC_ANNOTATION_FQ_NAME)) return emptyList()
val basicMethod = asJavaMethod(ktFunction, forceStatic)
if (!ktFunction.hasAnnotation(JVM_OVERLOADS_FQ_NAME)) return listOf(basicMethod)
@@ -475,7 +478,7 @@ class KtUltraLightClass(classOrObject: KtClassOrObject, private val support: Ult
if (declaration is KtProperty && declaration.hasDelegate()) {
return true
}
if (accessor?.hasModifier(PRIVATE_KEYWORD) == true) {
if (accessor?.hasModifier(PRIVATE_KEYWORD) == true || accessor?.hasAnnotation(JVM_SYNTHETIC_ANNOTATION_FQ_NAME) == true) {
return false
}
if (!isPrivate || accessor?.hasBody() == true) {