diff --git a/tools/codegen/src/com/android/codegen/FileInfo.kt b/tools/codegen/src/com/android/codegen/FileInfo.kt index a1d0389b004170f1dd894e6bc7a492a7f6970ec0..cc3a156549568c3fb6130d7a0222a837a4934529 100644 --- a/tools/codegen/src/com/android/codegen/FileInfo.kt +++ b/tools/codegen/src/com/android/codegen/FileInfo.kt @@ -238,7 +238,7 @@ class FileInfo( } else if (classBounds.isDataclass) { // Insert placeholder for generated code to be inserted for the 1st time - chunks.last = (chunks.last as Code) + chunks[chunks.lastIndex] = (chunks.last() as Code) .lines .dropLastWhile { it.isBlank() } .run { @@ -286,4 +286,4 @@ class FileInfo( .let { addAll(it) } } } -} \ No newline at end of file +} diff --git a/tools/codegen/src/com/android/codegen/Utils.kt b/tools/codegen/src/com/android/codegen/Utils.kt index 9ceb2042d74e39e8fcf7191ae1bcc3c12e48f4c0..a40bdd7ba8e10a927d968ea39a49b7185029f8c0 100644 --- a/tools/codegen/src/com/android/codegen/Utils.kt +++ b/tools/codegen/src/com/android/codegen/Utils.kt @@ -137,14 +137,4 @@ private fun parseFailed(source: String, cause: Throwable? = null, desc: String = cause) } -var MutableList.last - get() = last() - set(value) { - if (isEmpty()) { - add(value) - } else { - this[size - 1] = value - } - } - -inline fun buildList(init: MutableList.() -> Unit) = mutableListOf().apply(init) \ No newline at end of file +inline fun buildList(init: MutableList.() -> Unit) = mutableListOf().apply(init)