A new kind of synthetic accessors for backing fields, if accessed inside lambda / object literal / local class #KT-9657 Fixed
A set of tests provided Also #KT-4867 Fixed Also #KT-8750 Fixed Slight codegen refactoring
This commit is contained in:
@@ -9,6 +9,12 @@ class A {
|
||||
fun `access$getFoo$cp`(): Int = 1
|
||||
fun `access$setFoo$cp`(d: Int) {}
|
||||
|
||||
val bar = 0
|
||||
get() = { field }()
|
||||
|
||||
//synthetic field convention accessor
|
||||
fun `access$getBar$lp`(a: A): Int = 7
|
||||
|
||||
companion object {
|
||||
private var foo = 1;
|
||||
|
||||
@@ -26,7 +32,7 @@ class A {
|
||||
fun test() {
|
||||
{
|
||||
foo = 2;
|
||||
foo
|
||||
foo + bar
|
||||
}()
|
||||
}
|
||||
}
|
||||
+14
-4
@@ -18,6 +18,11 @@ compiler/testData/cli/jvm/syntheticAccessorForPropertiesSignatureClash.kt:1:7: e
|
||||
fun `access$setFoo$cp`(d: kotlin.Int): kotlin.Unit
|
||||
class A {
|
||||
^
|
||||
compiler/testData/cli/jvm/syntheticAccessorForPropertiesSignatureClash.kt:1:7: error: platform declaration clash: The following declarations have the same JVM signature (access$getBar$lp(LA;)I):
|
||||
fun <get-bar>(): kotlin.Int
|
||||
fun `access$getBar$lp`(a: A): kotlin.Int
|
||||
class A {
|
||||
^
|
||||
compiler/testData/cli/jvm/syntheticAccessorForPropertiesSignatureClash.kt:5:5: error: platform declaration clash: The following declarations have the same JVM signature (access$getFoo$p(LA;)I):
|
||||
fun <get-foo>(): kotlin.Int
|
||||
fun `access$getFoo$p`(a: A): kotlin.Int
|
||||
@@ -38,22 +43,27 @@ compiler/testData/cli/jvm/syntheticAccessorForPropertiesSignatureClash.kt:10:5:
|
||||
fun `access$setFoo$cp`(d: kotlin.Int): kotlin.Unit
|
||||
fun `access$setFoo$cp`(d: Int) {}
|
||||
^
|
||||
compiler/testData/cli/jvm/syntheticAccessorForPropertiesSignatureClash.kt:12:15: error: platform declaration clash: The following declarations have the same JVM signature (access$getFoo$p(LA$Companion;)I):
|
||||
compiler/testData/cli/jvm/syntheticAccessorForPropertiesSignatureClash.kt:16:5: error: platform declaration clash: The following declarations have the same JVM signature (access$getBar$lp(LA;)I):
|
||||
fun <get-bar>(): kotlin.Int
|
||||
fun `access$getBar$lp`(a: A): kotlin.Int
|
||||
fun `access$getBar$lp`(a: A): Int = 7
|
||||
^
|
||||
compiler/testData/cli/jvm/syntheticAccessorForPropertiesSignatureClash.kt:18:15: error: platform declaration clash: The following declarations have the same JVM signature (access$getFoo$p(LA$Companion;)I):
|
||||
fun <get-foo>(): kotlin.Int
|
||||
fun `access$getFoo$p`(p: A.Companion): kotlin.Int
|
||||
companion object {
|
||||
^
|
||||
compiler/testData/cli/jvm/syntheticAccessorForPropertiesSignatureClash.kt:12:15: 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:18:15: error: platform declaration clash: The following declarations have the same JVM signature (access$setFoo$p(LA$Companion;I)V):
|
||||
fun <set-foo>(<set-?>: kotlin.Int): kotlin.Unit
|
||||
fun `access$setFoo$p`(p: A.Companion, d: kotlin.Int): kotlin.Unit
|
||||
companion object {
|
||||
^
|
||||
compiler/testData/cli/jvm/syntheticAccessorForPropertiesSignatureClash.kt:22: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:28:9: error: platform declaration clash: The following declarations have the same JVM signature (access$getFoo$p(LA$Companion;)I):
|
||||
fun <get-foo>(): kotlin.Int
|
||||
fun `access$getFoo$p`(p: A.Companion): kotlin.Int
|
||||
fun `access$getFoo$p`(p: A.Companion): Int = 1
|
||||
^
|
||||
compiler/testData/cli/jvm/syntheticAccessorForPropertiesSignatureClash.kt:23: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:29:9: error: platform declaration clash: The following declarations have the same JVM signature (access$setFoo$p(LA$Companion;I)V):
|
||||
fun <set-foo>(<set-?>: kotlin.Int): kotlin.Unit
|
||||
fun `access$setFoo$p`(p: A.Companion, d: kotlin.Int): kotlin.Unit
|
||||
fun `access$setFoo$p`(p: A.Companion, d: Int) {}
|
||||
|
||||
Reference in New Issue
Block a user