Provide setter-method for LC for private property setter
^KT-41694 Fixed
This commit is contained in:
committed by
Vladimir Dolzhenko
parent
b5b319803b
commit
127257aa27
+5
-5
@@ -418,17 +418,17 @@ internal class UltraLightMembersCreator(
|
||||
if (isPrivate && declaration !is KtProperty) return emptyList()
|
||||
|
||||
fun needsAccessor(accessor: KtPropertyAccessor?, type: MethodType): Boolean {
|
||||
|
||||
if (onlyJvmStatic && !declaration.isJvmStatic(support) && !(accessor != null && accessor.isJvmStatic(support)))
|
||||
return false
|
||||
|
||||
if (declaration is KtProperty && declaration.hasDelegate())
|
||||
return true
|
||||
|
||||
if (accessor?.hasModifier(PRIVATE_KEYWORD) == true || accessor?.hasAnnotation(JVM_SYNTHETIC_ANNOTATION_FQ_NAME) == true)
|
||||
return false
|
||||
|
||||
if (isPrivate && accessor?.hasBody() != true) return false
|
||||
if (accessor?.hasBody() != true &&
|
||||
(accessor?.hasModifier(PRIVATE_KEYWORD) == true ||
|
||||
accessor?.hasAnnotation(JVM_SYNTHETIC_ANNOTATION_FQ_NAME) == true ||
|
||||
isPrivate)
|
||||
) return false
|
||||
|
||||
if (!declaration.hasAnnotation(JVM_SYNTHETIC_ANNOTATION_FQ_NAME)) return true
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
class Foo {
|
||||
var prop = "V"
|
||||
get() = "V"
|
||||
private set(value) {
|
||||
field = value
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.asJava
|
||||
import com.intellij.injected.editor.EditorWindow
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiFile
|
||||
import com.intellij.psi.PsiMethod
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import com.intellij.testFramework.LightProjectDescriptor
|
||||
import junit.framework.TestCase
|
||||
@@ -93,9 +94,17 @@ class KtFileLightClassTest : KotlinLightCodeInsightFixtureTestCase() {
|
||||
assertEquals("Injected class should be `A`", "A", ((injectedFile as KtFile).declarations.single() as KtClass).toLightClass()!!.name)
|
||||
}
|
||||
|
||||
fun testPropertyWithPrivateSetter() {
|
||||
val file = myFixture.configureByFile("propWithPrivateSetter.kt") as KtFile
|
||||
val aClass = file.classes.single()
|
||||
val methods = aClass.methods
|
||||
val methodNames = methods.map(PsiMethod::getName)
|
||||
assertEquals(methodNames.toString(), 3, methods.size)
|
||||
assertTrue(methods.toString(), "getProp" in methodNames)
|
||||
assertTrue(methods.toString(), "setProp" in methodNames)
|
||||
}
|
||||
|
||||
fun testSameVirtualFileForLightElement() {
|
||||
|
||||
val psiFile = myFixture.addFileToProject(
|
||||
"pkg/AnnotatedClass.kt", """
|
||||
package pkg
|
||||
|
||||
Reference in New Issue
Block a user