mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[kotlin] KTIJ-37293 do not convert properties with two getters
GitOrigin-RevId: c44175bdf7fd97d55f19ada5486063957dd5cac2
This commit is contained in:
committed by
intellij-monorepo-bot
parent
a2b8eb8121
commit
f2a4850f03
+6
-4
@@ -115,9 +115,6 @@ internal class ConvertToExplicitBackingFieldsInspection :
|
||||
|
||||
override fun KaSession.prepareContext(element: KtProperty): Context? {
|
||||
val returnedProperty = getReturnedPropertyFromGetter(element.getter) ?: return null
|
||||
if (!returnedProperty.isPrivate()) return null
|
||||
if (returnedProperty.isVar) return null
|
||||
if (returnedProperty.hasDelegate()) return null
|
||||
|
||||
val allProperties = (element.parent as? KtElement)
|
||||
?.childrenOfType<KtProperty>()
|
||||
@@ -147,7 +144,12 @@ internal class ConvertToExplicitBackingFieldsInspection :
|
||||
|
||||
else -> null
|
||||
}
|
||||
return returnedExpr?.let { resolveToProperty(it) }
|
||||
val returnedProperty = returnedExpr?.let { resolveToProperty(it) } ?: return null
|
||||
if (!returnedProperty.isPrivate()) return null
|
||||
if (returnedProperty.isVar) return null
|
||||
if (returnedProperty.hasDelegate()) return null
|
||||
if (returnedProperty.getter != null) return null
|
||||
return returnedProperty
|
||||
}
|
||||
|
||||
context(_: KaSession)
|
||||
|
||||
+5
@@ -13470,6 +13470,11 @@ public abstract class K2LocalInspectionTestGenerated extends AbstractK2LocalInsp
|
||||
runTest("testData/inspectionsLocal/convertToExplicitBackingFields/simpleWithInheritance.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("twoGetters.kt")
|
||||
public void testTwoGetters() throws Exception {
|
||||
runTest("testData/inspectionsLocal/convertToExplicitBackingFields/twoGetters.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("withCustomFunctions.kt")
|
||||
public void testWithCustomFunctions() throws Exception {
|
||||
runTest("testData/inspectionsLocal/convertToExplicitBackingFields/withCustomFunctions.kt");
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// COMPILER_ARGUMENTS: -Xexplicit-backing-fields
|
||||
// PROBLEM: none
|
||||
class Foo {
|
||||
private val _x get() = mutableListOf<Int>()
|
||||
val x: List<Int> get() = _x<caret>
|
||||
}
|
||||
Reference in New Issue
Block a user