Generate @JvmDefault for property accessors in LIGHT_CLASS MODE
This commit is contained in:
+13
-3
@@ -33,6 +33,7 @@ import org.jetbrains.kotlin.psi.*
|
|||||||
import org.jetbrains.kotlin.psi.psiUtil.isPropertyParameter
|
import org.jetbrains.kotlin.psi.psiUtil.isPropertyParameter
|
||||||
import org.jetbrains.kotlin.resolve.AnnotationChecker
|
import org.jetbrains.kotlin.resolve.AnnotationChecker
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
|
import org.jetbrains.kotlin.resolve.annotations.JVM_DEFAULT_FQ_NAME
|
||||||
import org.jetbrains.kotlin.resolve.source.getPsi
|
import org.jetbrains.kotlin.resolve.source.getPsi
|
||||||
|
|
||||||
abstract class KtLightModifierList<out T : KtLightElement<KtModifierListOwner, PsiModifierListOwner>>(protected val owner: T)
|
abstract class KtLightModifierList<out T : KtLightElement<KtModifierListOwner, PsiModifierListOwner>>(protected val owner: T)
|
||||||
@@ -138,9 +139,18 @@ private fun getAnnotationDescriptors(declaration: KtDeclaration, annotatedLightE
|
|||||||
else -> descriptor
|
else -> descriptor
|
||||||
} ?: return emptyList()
|
} ?: return emptyList()
|
||||||
|
|
||||||
return annotatedDescriptor.annotations.getAllAnnotations()
|
val annotations = annotatedDescriptor.annotations.getAllAnnotations()
|
||||||
.filter { it.matches(annotatedLightElement) }
|
.filter { it.matches(annotatedLightElement) }
|
||||||
.map { it.annotation }
|
.map { it.annotation }
|
||||||
|
|
||||||
|
if (descriptor is PropertyDescriptor) {
|
||||||
|
val jvmDefault = descriptor.annotations.findAnnotation(JVM_DEFAULT_FQ_NAME)
|
||||||
|
if (jvmDefault != null) {
|
||||||
|
return annotations + jvmDefault
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return annotations
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun hasAnnotationsInSource(declaration: KtDeclaration): Boolean {
|
private fun hasAnnotationsInSource(declaration: KtDeclaration): Boolean {
|
||||||
|
|||||||
Vendored
+6
-3
@@ -6,9 +6,12 @@ interface KotlinInterface {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @JvmDefault
|
@JvmDefault
|
||||||
// val foo: String
|
var foo: String
|
||||||
// get() = "123"
|
get() = "123"
|
||||||
|
set(field) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user