diff options
| author | 2024-02-05 20:40:16 +0000 | |
|---|---|---|
| committer | 2024-02-05 20:40:16 +0000 | |
| commit | f3ff901b9e05d9d8dd493159511c7ac03e86cfe4 (patch) | |
| tree | b104b6040999864ce79f9d28fef3039619d17526 | |
| parent | 0514919a557b704b091a881b5b3a9f616c8ef0b7 (diff) | |
| parent | 7f966b51e25bcaf53eea2acbd8042a223c571880 (diff) | |
Merge "Fix assignment for last element in codegen list" into main am: 12e1764dd6 am: 7f966b51e2
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2946346
Change-Id: Ice814d31230091bb7d9721996757169c9634bc7a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
| -rw-r--r-- | tools/codegen/src/com/android/codegen/FileInfo.kt | 4 | ||||
| -rw-r--r-- | tools/codegen/src/com/android/codegen/Utils.kt | 12 |
2 files changed, 3 insertions, 13 deletions
diff --git a/tools/codegen/src/com/android/codegen/FileInfo.kt b/tools/codegen/src/com/android/codegen/FileInfo.kt index a1d0389b0041..cc3a15654956 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 9ceb2042d74e..a40bdd7ba8e1 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 <T> MutableList<T>.last - get() = last() - set(value) { - if (isEmpty()) { - add(value) - } else { - this[size - 1] = value - } - } - -inline fun <T> buildList(init: MutableList<T>.() -> Unit) = mutableListOf<T>().apply(init)
\ No newline at end of file +inline fun <T> buildList(init: MutableList<T>.() -> Unit) = mutableListOf<T>().apply(init) |