Skip to content

Commit 201bc6b

Browse files
nikpachoozoobestik
authored andcommitted
KTL-1313 feat: add support for explicit backing fields
1 parent 37dd96d commit 201bc6b

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

common/src/main/kotlin/component/KotlinEnvironment.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class KotlinEnvironment(
4242
"-opt-in=kotlin.contracts.ExperimentalContracts",
4343
"-opt-in=kotlin.experimental.ExperimentalTypeInference",
4444
"-Xcontext-receivers",
45+
"-XXLanguage:+ExplicitBackingFields"
4546
)
4647
}
4748

src/test/kotlin/com/compiler/server/KotlinFeatureSince170.kt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,28 @@ class KotlinFeatureSince170 : BaseExecutorTest() {
9494
contains = "second quarter"
9595
)
9696
}
97+
98+
@Test
99+
fun `Experimental support for explicit backing fields`() {
100+
run(
101+
code = """
102+
fun main() {
103+
class Test {
104+
val names: List<String>
105+
field: MutableList<String> = mutableListOf<String>()
106+
107+
fun doThing() {
108+
names.add("Hello!")
109+
}
110+
}
111+
112+
val test = Test()
113+
test.doThing()
114+
115+
println(test.names)
116+
}
117+
""".trimIndent(),
118+
contains = "[Hello!]"
119+
)
120+
}
97121
}

0 commit comments

Comments
 (0)