Skip to content

Commit

Permalink
KTL-1313 feat: add support for explicit backing fields
Browse files Browse the repository at this point in the history
  • Loading branch information
nikpachoo committed Dec 28, 2023
1 parent 5548958 commit 57ba53a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions common/src/main/kotlin/component/KotlinEnvironment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class KotlinEnvironment(
"-opt-in=kotlin.contracts.ExperimentalContracts",
"-opt-in=kotlin.experimental.ExperimentalTypeInference",
"-Xcontext-receivers",
"-XXLanguage:+ExplicitBackingFields"
)
}

Expand Down
24 changes: 24 additions & 0 deletions src/test/kotlin/com/compiler/server/KotlinFeatureSince170.kt
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,28 @@ class KotlinFeatureSince170 : BaseExecutorTest() {
contains = "second quarter"
)
}

@Test
fun `Experimental support for explicit backing fields`() {
run(
code = """
fun main() {
class Test {
val names: List<String>
field: MutableList<String> = mutableListOf<String>()
fun doThing() {
names.add("Hello!")
}
}
val test = Test()
test.doThing()
println(test.names)
}
""".trimIndent(),
contains = "[Hello!]"
)
}
}

0 comments on commit 57ba53a

Please sign in to comment.