KT-14258 Optimize accesses to properties defined into companion
- Use direct access to property defined into companion object when it is possible rather than always use an accessor to access the property. - Use direct access will speedup runtime performance. - Avoid to generate useless accessors for companion properties. Fix of https://youtrack.jetbrains.com/issue/KT-14258
This commit is contained in:
committed by
Alexander Udalov
parent
fd244be9ca
commit
d0ed0c4049
@@ -16,7 +16,9 @@ class A {
|
||||
fun `access$getBar$lp`(a: A): Int = 7
|
||||
|
||||
companion object {
|
||||
private var foo = 1;
|
||||
private var foo = 1
|
||||
// Custom getter is needed, otherwise no need to generate getY and setY
|
||||
get() = field
|
||||
|
||||
fun test() {
|
||||
{
|
||||
|
||||
@@ -58,12 +58,12 @@ compiler/testData/cli/jvm/syntheticAccessorForPropertiesSignatureClash.kt:18:15:
|
||||
fun `access$setFoo$p`(p: A.Companion, d: Int): Unit defined in A.Companion
|
||||
companion object {
|
||||
^
|
||||
compiler/testData/cli/jvm/syntheticAccessorForPropertiesSignatureClash.kt:28:9: error: platform declaration clash: The following declarations have the same JVM signature (access$getFoo$p(LA$Companion;)I):
|
||||
compiler/testData/cli/jvm/syntheticAccessorForPropertiesSignatureClash.kt:30:9: error: platform declaration clash: The following declarations have the same JVM signature (access$getFoo$p(LA$Companion;)I):
|
||||
fun <get-foo>(): Int defined in A.Companion
|
||||
fun `access$getFoo$p`(p: A.Companion): Int defined in A.Companion
|
||||
fun `access$getFoo$p`(p: A.Companion): Int = 1
|
||||
^
|
||||
compiler/testData/cli/jvm/syntheticAccessorForPropertiesSignatureClash.kt:29:9: error: platform declaration clash: The following declarations have the same JVM signature (access$setFoo$p(LA$Companion;I)V):
|
||||
compiler/testData/cli/jvm/syntheticAccessorForPropertiesSignatureClash.kt:31:9: error: platform declaration clash: The following declarations have the same JVM signature (access$setFoo$p(LA$Companion;I)V):
|
||||
fun <set-foo>(<set-?>: Int): Unit defined in A.Companion
|
||||
fun `access$setFoo$p`(p: A.Companion, d: Int): Unit defined in A.Companion
|
||||
fun `access$setFoo$p`(p: A.Companion, d: Int) {}
|
||||
|
||||
Reference in New Issue
Block a user