Restore support for local class literals in annotation arguments
This was broken in c1ab08c8ce where we started to represent KClassValue
as a ClassId of the referenced class + number of times it's been wrapped
into kotlin.Array. Local classes do not have a sane ClassId, so in this
change we restore the old behavior by representing KClassValue with a
sealed class value instead
#KT-29891 Fixed
This commit is contained in:
+1
@@ -141,6 +141,7 @@ private fun ConstantValue<*>.asStringForPsiLiteral(parent: PsiElement): String =
|
||||
is NullValue -> "null"
|
||||
is StringValue -> "\"$value\""
|
||||
is KClassValue -> {
|
||||
val value = (value as KClassValue.Value.NormalClass).value
|
||||
val arrayPart = "[]".repeat(value.arrayNestedness)
|
||||
val fqName = value.classId.asSingleFqName()
|
||||
val canonicalText = psiType(
|
||||
|
||||
+3
-2
@@ -67,8 +67,9 @@ class KtLightPsiClassObjectAccessExpression(override val kotlinOrigin: KtClassLi
|
||||
override fun getType(): PsiType {
|
||||
val bindingContext = LightClassGenerationSupport.getInstance(this.project).analyze(kotlinOrigin)
|
||||
val (classId, arrayDimensions) = bindingContext[BindingContext.COMPILE_TIME_VALUE, kotlinOrigin]
|
||||
?.toConstantValue(TypeUtils.NO_EXPECTED_TYPE)?.safeAs<KClassValue>()?.value ?: return PsiType.VOID
|
||||
var type = psiType(classId.asSingleFqName().asString(), kotlinOrigin, boxPrimitiveType = arrayDimensions > 0) ?: return PsiType.VOID
|
||||
?.toConstantValue(TypeUtils.NO_EXPECTED_TYPE)?.safeAs<KClassValue>()?.value
|
||||
?.safeAs<KClassValue.Value.NormalClass>()?.value ?: return PsiType.VOID
|
||||
var type = psiType(classId.asSingleFqName().asString(), kotlinOrigin, boxPrimitiveType = arrayDimensions > 0)
|
||||
repeat(arrayDimensions) {
|
||||
type = type.createArrayType()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user