Skip to content

Commit

Permalink
remove unused descriptor utils from BinaryUtils.
Browse files Browse the repository at this point in the history
  • Loading branch information
neetopia committed Sep 22, 2023
1 parent a207da6 commit 97a2cc2
Showing 1 changed file with 0 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,9 @@ import com.google.devtools.ksp.symbol.KSAnnotated
import com.google.devtools.ksp.symbol.KSDeclaration
import com.google.devtools.ksp.symbol.KSType
import org.jetbrains.kotlin.load.kotlin.KotlinJvmBinaryClass
import org.jetbrains.kotlin.load.kotlin.KotlinJvmBinarySourceElement
import org.jetbrains.kotlin.load.kotlin.VirtualFileKotlinClass
import org.jetbrains.kotlin.load.kotlin.getContainingKotlinJvmBinaryClass
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.descriptorUtil.isCompanionObject
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedPropertyDescriptor
import org.jetbrains.org.objectweb.asm.ClassReader
import org.jetbrains.org.objectweb.asm.ClassVisitor
import org.jetbrains.org.objectweb.asm.FieldVisitor
Expand Down Expand Up @@ -97,22 +92,6 @@ object BinaryClassInfoCache : KSObjectCache<ClassId, BinaryClassInfo>() {
}
}

/**
* Workaround for backingField in deserialized descriptors.
* They always return non-null for backing field even when they don't have a backing field.
*/
private fun DeserializedPropertyDescriptor.hasBackingFieldInBinaryClass(): Boolean {
val kotlinJvmBinaryClass = if (containingDeclaration.isCompanionObject()) {
// Companion objects have backing fields in containing classes.
// https://kotlinlang.org/docs/java-to-kotlin-interop.html#static-fields
val container = containingDeclaration.containingDeclaration as? DeserializedClassDescriptor
(container?.source as? KotlinJvmBinarySourceElement)?.binaryClass
} else {
this.getContainingKotlinJvmBinaryClass()
} ?: return false
return BinaryClassInfoCache.getCached(kotlinJvmBinaryClass).fieldAccFlags.containsKey(name.asString())
}

fun KSAnnotated.hasAnnotation(fqn: String): Boolean =
annotations.any {
fqn.endsWith(it.shortName.asString()) &&
Expand Down

0 comments on commit 97a2cc2

Please sign in to comment.