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