Refactor KClassValue to store ClassLiteralValue internally
Only invariant array projections and non-null element types will be supported soon (see KT-26568), so it makes no sense to store the complete type in KClassValue. What we need is only the ClassId of the class, and the number of times it's wrapped into kotlin/Array, which is exactly what ClassLiteralValue represents. This change helps in decoupling annotation values from descriptors/types. The only constant value that depends on descriptors is now AnnotationValue. #KT-26582 Fixed
This commit is contained in:
@@ -439,7 +439,7 @@ public abstract class AnnotationCodegen {
|
||||
|
||||
@Override
|
||||
public Void visitKClassValue(KClassValue value, Void data) {
|
||||
annotationVisitor.visit(name, typeMapper.mapType(value.getValue()));
|
||||
annotationVisitor.visit(name, typeMapper.mapType(value.getArgumentType(module)));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ import org.jetbrains.kotlin.resolve.calls.util.UnderscoreUtilKt;
|
||||
import org.jetbrains.kotlin.resolve.constants.ArrayValue;
|
||||
import org.jetbrains.kotlin.resolve.constants.ConstantValue;
|
||||
import org.jetbrains.kotlin.resolve.constants.KClassValue;
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
|
||||
import org.jetbrains.kotlin.resolve.inline.InlineUtil;
|
||||
import org.jetbrains.kotlin.resolve.jvm.AsmTypes;
|
||||
import org.jetbrains.kotlin.resolve.jvm.RuntimeAssertionInfo;
|
||||
@@ -1111,7 +1112,7 @@ public class FunctionCodegen {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String[] getThrownExceptions(@NotNull FunctionDescriptor function, @NotNull KotlinTypeMapper mapper) {
|
||||
public static String[] getThrownExceptions(@NotNull FunctionDescriptor function, @NotNull KotlinTypeMapper typeMapper) {
|
||||
AnnotationDescriptor annotation = function.getAnnotations().findAnnotation(new FqName("kotlin.throws"));
|
||||
if (annotation == null) {
|
||||
annotation = function.getAnnotations().findAnnotation(new FqName("kotlin.jvm.Throws"));
|
||||
@@ -1130,9 +1131,10 @@ public class FunctionCodegen {
|
||||
arrayValue.getValue(),
|
||||
(ConstantValue<?> constant) -> {
|
||||
if (constant instanceof KClassValue) {
|
||||
KClassValue classValue = (KClassValue) constant;
|
||||
ClassDescriptor classDescriptor = DescriptorUtils.getClassDescriptorForType(classValue.getValue());
|
||||
return mapper.mapClass(classDescriptor).getInternalName();
|
||||
ClassDescriptor classDescriptor = DescriptorUtils.getClassDescriptorForType(
|
||||
((KClassValue) constant).getArgumentType(DescriptorUtilsKt.getModule(function))
|
||||
);
|
||||
return typeMapper.mapClass(classDescriptor).getInternalName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user