mattmoore
05/24/2020, 9:04 PMdata class
is not supported for source code? If I have a test like this:
@Test
fun `destructuring example`() {
assertThis(CompilerTest(
config = {
metaDependencies
},
code = {
"""|data class Person(val firstName: String, val lastName: String, val age: Int)
|
|val person = Person("Matt", "Moore", 100)
|val (firstName, lastName, age) = person
|""".source
},
assert = {
allOf(
"firstName".source.evalsTo("Matt"),
"lastName".source.evalsTo("Moore"),
"age".source.evalsTo(100)
)
}
))
}
The code snippet fails to compile. Removing the data
keyword succeeds, but then there are no componentN
functions generated for destructuring.e: /var/folders/d4/jb8hn0bj4g3f1kgvrf5p19tw0000gn/T/Kotlin-Compilation4522202210550990282/sources/Source.kt: (31, 5): Destructuring declarations are only allowed for local variables/values
I also found other examples where data class
is used. So I must be doing something wrong here. I'll keep looking.raulraja
05/25/2020, 11:45 AMmattmoore
05/25/2020, 5:02 PMconfig = { metaDependencies + addDependencies(arrowOptics) }