Fix a compatibility issue with AnnotationDescriptor

The `getSourceForArgument` method should be in the interface,
but adding it is a breaking change for Java usages,
since the module is not built with -Xjvm-default (KT-54749).

Move the method to an extension. This doesn't change the behavior,
since it was only ever called on LazyAnnotationDescriptor.
This commit is contained in:
Sergej Jaskiewicz
2022-11-01 17:42:31 +01:00
committed by Space Team
parent af8b9e6700
commit 37b32907ab
5 changed files with 6 additions and 8 deletions
@@ -125,7 +125,7 @@ class LazyAnnotationDescriptor(
valueArgumentsWithSourceInfo.mapValues { it.value.first }
}
override fun getSourceForArgument(name: Name): SourceElement =
fun getSourceForArgument(name: Name): SourceElement =
valueArgumentsWithSourceInfo[name]?.second ?: SourceElement.NO_SOURCE
override fun forceResolveAllContents() {
@@ -149,3 +149,6 @@ class LazyAnnotationDescriptor(
override fun toString(): String = "${name.asString()} declared in LazyAnnotations.kt"
}
}
fun AnnotationDescriptor.getSourceForArgument(name: Name): SourceElement =
(this as? LazyAnnotationDescriptor)?.getSourceForArgument(name) ?: SourceElement.NO_SOURCE
@@ -15,6 +15,7 @@ import org.jetbrains.kotlin.ir.util.TypeTranslator
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.psiUtil.endOffset
import org.jetbrains.kotlin.psi.psiUtil.startOffset
import org.jetbrains.kotlin.resolve.lazy.descriptors.getSourceForArgument
import org.jetbrains.kotlin.resolve.source.getPsi
class ConstantValueGeneratorImpl(