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
@@ -288,4 +288,5 @@ fun skipJvmDefaultAllForModule(path: String): Boolean =
// java.lang.IllegalAccessError: tried to access method kotlin.reflect.jvm.internal.impl.types.checker.ClassicTypeSystemContext$substitutionSupertypePolicy$2.<init>(
// Lkotlin/reflect/jvm/internal/impl/types/checker/ClassicTypeSystemContext;Lkotlin/reflect/jvm/internal/impl/types/TypeSubstitutor;
// )V from class kotlin.reflect.jvm.internal.impl.resolve.OverridingUtilTypeSystemContext
// KT-54749
path == ":core:descriptors"
@@ -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(
@@ -37,7 +37,6 @@ interface AnnotationDescriptor : AnnotationMarker {
val source: SourceElement
fun getSourceForArgument(name: Name): SourceElement = SourceElement.NO_SOURCE
}
val AnnotationDescriptor.abbreviationFqName: FqName?
@@ -67,12 +67,6 @@ public class AnnotationDescriptorImpl implements AnnotationDescriptor {
return source;
}
@NotNull
@Override
public SourceElement getSourceForArgument(@NotNull Name name) {
return SourceElement.NO_SOURCE;
}
@Override
public String toString() {
return DescriptorRenderer.FQ_NAMES_IN_TYPES.renderAnnotation(this, null);