Set correct nullability and Companion support to annotations
This commit is contained in:
@@ -169,13 +169,10 @@ open class KtUltraLightClass(classOrObject: KtClassOrObject, internal val suppor
|
||||
override fun getLBrace(): PsiElement? = null
|
||||
|
||||
private val _ownFields: List<KtLightField> by lazyPub {
|
||||
|
||||
val result = arrayListOf<KtLightField>()
|
||||
val usedNames = hashSetOf<String>()
|
||||
|
||||
for (parameter in propertyParameters()) {
|
||||
membersBuilder.createPropertyField(parameter, usedNames, forceStatic = false)?.let(result::add)
|
||||
}
|
||||
|
||||
this.classOrObject.companionObjects.firstOrNull()?.let { companion ->
|
||||
result.add(
|
||||
KtUltraLightField(
|
||||
@@ -193,6 +190,12 @@ open class KtUltraLightClass(classOrObject: KtClassOrObject, internal val suppor
|
||||
}
|
||||
}
|
||||
|
||||
if (isAnnotationType) return@lazyPub result
|
||||
|
||||
for (parameter in propertyParameters()) {
|
||||
membersBuilder.createPropertyField(parameter, usedNames, forceStatic = false)?.let(result::add)
|
||||
}
|
||||
|
||||
if (!isInterface) {
|
||||
val isCompanion = this.classOrObject is KtObjectDeclaration && this.classOrObject.isCompanion()
|
||||
for (property in this.classOrObject.declarations.filterIsInstance<KtProperty>()) {
|
||||
|
||||
+7
-2
@@ -397,7 +397,13 @@ internal class UltraLightMembersCreator(
|
||||
val defaultGetterName = if (createAsAnnotationMethod) propertyName else JvmAbi.getterName(propertyName)
|
||||
val getterName = computeMethodName(auxiliaryOrigin, defaultGetterName, MethodType.GETTER)
|
||||
val getterPrototype = lightMethod(getterName, auxiliaryOrigin, forceStatic = onlyJvmStatic || forceStatic)
|
||||
val getterWrapper = KtUltraLightMethodForSourceDeclaration(getterPrototype, lightMemberOrigin, support, containingClass)
|
||||
val getterWrapper = KtUltraLightMethodForSourceDeclaration(
|
||||
getterPrototype,
|
||||
lightMemberOrigin,
|
||||
support,
|
||||
containingClass,
|
||||
forceToSkipNullabilityAnnotation = createAsAnnotationMethod
|
||||
)
|
||||
|
||||
val getterType: PsiType by lazyPub { methodReturnType(declaration, getterWrapper, isSuspendFunction = false) }
|
||||
getterPrototype.setMethodReturnType { getterType }
|
||||
@@ -419,7 +425,6 @@ internal class UltraLightMembersCreator(
|
||||
auxiliaryOriginalElement = auxiliaryOrigin
|
||||
)
|
||||
|
||||
|
||||
val setterName = computeMethodName(auxiliaryOrigin, JvmAbi.setterName(propertyName), MethodType.SETTER)
|
||||
val setterPrototype = lightMethod(setterName, auxiliaryOrigin, forceStatic = onlyJvmStatic || forceStatic)
|
||||
.setMethodReturnType(PsiType.VOID)
|
||||
|
||||
@@ -104,7 +104,8 @@ internal class KtUltraLightMethodForSourceDeclaration(
|
||||
delegate: PsiMethod,
|
||||
lightMemberOrigin: LightMemberOrigin?,
|
||||
support: KtUltraLightSupport,
|
||||
containingClass: KtLightClass
|
||||
containingClass: KtLightClass,
|
||||
private val forceToSkipNullabilityAnnotation: Boolean = false
|
||||
) : KtUltraLightMethod(
|
||||
delegate,
|
||||
lightMemberOrigin,
|
||||
@@ -119,7 +120,7 @@ internal class KtUltraLightMethodForSourceDeclaration(
|
||||
) : this(delegate, LightMemberOriginForDeclaration(declaration, JvmDeclarationOriginKind.OTHER), support, containingClass)
|
||||
|
||||
override val kotlinTypeForNullabilityAnnotation: KotlinType?
|
||||
get() = kotlinOrigin?.getKotlinType()
|
||||
get() = if (forceToSkipNullabilityAnnotation) null else kotlinOrigin?.getKotlinType()
|
||||
|
||||
override fun buildTypeParameterList(): PsiTypeParameterList {
|
||||
val origin = kotlinOrigin
|
||||
|
||||
Reference in New Issue
Block a user