diff --git a/src/main/kotlin/api/AsmMetadataLoading.kt b/src/main/kotlin/api/AsmMetadataLoading.kt index c3731684..b1f9c5ee 100644 --- a/src/main/kotlin/api/AsmMetadataLoading.kt +++ b/src/main/kotlin/api/AsmMetadataLoading.kt @@ -54,11 +54,6 @@ fun ClassNode.isDefaultImpls(metadata: KotlinClassMetadata?) = isInner() && name fun ClassNode.findAnnotation(annotationName: String, includeInvisible: Boolean = false) = findAnnotation(annotationName, visibleAnnotations, invisibleAnnotations, includeInvisible) -fun MethodNode.findAnnotation(annotationName: String, includeInvisible: Boolean = false) = - findAnnotation(annotationName, visibleAnnotations, invisibleAnnotations, includeInvisible) -fun FieldNode.findAnnotation(annotationName: String, includeInvisible: Boolean = false) = - findAnnotation(annotationName, visibleAnnotations, invisibleAnnotations, includeInvisible) - operator fun AnnotationNode.get(key: String): Any? = values.annotationValue(key) private fun List.annotationValue(key: String): Any? { diff --git a/src/main/kotlin/api/KotlinMetadataSignature.kt b/src/main/kotlin/api/KotlinMetadataSignature.kt index 29a7a311..a5ea7283 100644 --- a/src/main/kotlin/api/KotlinMetadataSignature.kt +++ b/src/main/kotlin/api/KotlinMetadataSignature.kt @@ -7,7 +7,7 @@ package kotlinx.validation.api import kotlinx.metadata.jvm.* import kotlinx.validation.* -import org.objectweb.asm.Opcodes +import org.objectweb.asm.* import org.objectweb.asm.tree.* @ExternalApi // Only name is part of the API, nothing else is used by stdlib @@ -94,6 +94,12 @@ internal fun MethodNode.alternateDefaultSignature(className: String): JvmMethodS } fun MethodNode.toMethodBinarySignature( + /* + * Extra annotations are: + * * Annotations from the original method for synthetic `$default` method + * * Annotations from getter, setter or field for synthetic `$annotation` method + * * Annotations from a field for getter and setter + */ extraAnnotations: List, alternateDefaultSignature: JvmMethodSignature? ): MethodBinarySignature { diff --git a/src/main/kotlin/api/KotlinSignaturesLoading.kt b/src/main/kotlin/api/KotlinSignaturesLoading.kt index 17d1dc01..f0c401d4 100644 --- a/src/main/kotlin/api/KotlinSignaturesLoading.kt +++ b/src/main/kotlin/api/KotlinSignaturesLoading.kt @@ -74,8 +74,10 @@ public fun Sequence.loadApiFromJvmClasses(visibilityFilter: (String val annotationHolders = mVisibility?.members?.get(JvmMethodSignature(it.name, it.desc))?.propertyAnnotation val foundAnnotations = ArrayList() - foundAnnotations += fields.annotationsFor(annotationHolders?.field) - foundAnnotations += methods.annotationsFor(annotationHolders?.method) + if (annotationHolders != null) { + foundAnnotations += fields.annotationsFor(annotationHolders.field) + foundAnnotations += methods.annotationsFor(annotationHolders.method) + } /** * For synthetic $default methods, pull the annotations from the corresponding method