Skip to content

Commit 2e038d6

Browse files
committed
A bit of documentation and cleanup
1 parent 66031d9 commit 2e038d6

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

src/main/kotlin/api/AsmMetadataLoading.kt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,6 @@ fun ClassNode.isDefaultImpls(metadata: KotlinClassMetadata?) = isInner() && name
5454

5555
fun ClassNode.findAnnotation(annotationName: String, includeInvisible: Boolean = false) =
5656
findAnnotation(annotationName, visibleAnnotations, invisibleAnnotations, includeInvisible)
57-
fun MethodNode.findAnnotation(annotationName: String, includeInvisible: Boolean = false) =
58-
findAnnotation(annotationName, visibleAnnotations, invisibleAnnotations, includeInvisible)
59-
fun FieldNode.findAnnotation(annotationName: String, includeInvisible: Boolean = false) =
60-
findAnnotation(annotationName, visibleAnnotations, invisibleAnnotations, includeInvisible)
61-
6257
operator fun AnnotationNode.get(key: String): Any? = values.annotationValue(key)
6358

6459
private fun List<Any>.annotationValue(key: String): Any? {

src/main/kotlin/api/KotlinMetadataSignature.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package kotlinx.validation.api
77

88
import kotlinx.metadata.jvm.*
99
import kotlinx.validation.*
10-
import org.objectweb.asm.Opcodes
10+
import org.objectweb.asm.*
1111
import org.objectweb.asm.tree.*
1212

1313
@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
9494
}
9595

9696
fun MethodNode.toMethodBinarySignature(
97+
/*
98+
* Extra annotations are:
99+
* * Annotations from the original method for synthetic `$default` method
100+
* * Annotations from getter, setter or field for synthetic `$annotation` method
101+
* * Annotations from a field for getter and setter
102+
*/
97103
extraAnnotations: List<AnnotationNode>,
98104
alternateDefaultSignature: JvmMethodSignature?
99105
): MethodBinarySignature {

src/main/kotlin/api/KotlinSignaturesLoading.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,10 @@ public fun Sequence<InputStream>.loadApiFromJvmClasses(visibilityFilter: (String
7474
val annotationHolders =
7575
mVisibility?.members?.get(JvmMethodSignature(it.name, it.desc))?.propertyAnnotation
7676
val foundAnnotations = ArrayList<AnnotationNode>()
77-
foundAnnotations += fields.annotationsFor(annotationHolders?.field)
78-
foundAnnotations += methods.annotationsFor(annotationHolders?.method)
77+
if (annotationHolders != null) {
78+
foundAnnotations += fields.annotationsFor(annotationHolders.field)
79+
foundAnnotations += methods.annotationsFor(annotationHolders.method)
80+
}
7981

8082
/**
8183
* For synthetic $default methods, pull the annotations from the corresponding method

0 commit comments

Comments
 (0)