You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 26, 2021. It is now read-only.
In Kotlin, all data classes are marked as final classes when the app compiles. An error like this is thrown at compile time:
error: Unable to access field "whatever" in class com.example.stagtest.MyDataModel, field must not be final.
Reproduction Steps
@UseStag
data class ApiResponse(val dates: List<Day>, val totalGames: Int) {
@UseStag
data class Day(
val totalGames: Int, // 14
val games: List<Game>
)
}
Attempt to compile.
Expected Behavior
App compiles to completion.
Actual Behavior
Throws an error:
/Users/me/StagDeserializationPrototype/app/build/tmp/kapt3/stubs/debug/com/example/stagdeserializationprototype/ApiResponse.java:92: error: Unable to access field "totalGames" in class com.example.stagdeserializationprototype.ApiResponse.Day, field must not be final.
private final int totalGames = 0;
The text was updated successfully, but these errors were encountered:
I would suggest using moshi-kotlin-codegen with kotlin DTOs. In order to use stag, you must make you make the properties mutable var as @ToxicBakery correctly pointed out.
Issue Summary
In Kotlin, all data classes are marked as final classes when the app compiles. An error like this is thrown at compile time:
Reproduction Steps
Expected Behavior
App compiles to completion.
Actual Behavior
Throws an error:
The text was updated successfully, but these errors were encountered: