summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSorin Basca <sorinbasca@google.com>2024-02-02 18:09:36 +0000
committerSorin Basca <sorinbasca@google.com>2024-02-05 13:35:55 +0000
commit815016a64d44084bb0bcadef2778ca122dfd716e (patch)
tree220696f353871e8b4d185acbe177d957817f5a67 /tools
parent5bb6f919af11353b73b9cf09cc0064a215914ffc (diff)
downloadbase-815016a64d44084bb0bcadef2778ca122dfd716e.tar.gz
Fix assignment for last element in codegen list
Bug: 322973175 Test: TH Change-Id: Ib55bea6050e0d125c0d7d4821d75101085ab48af
Diffstat (limited to 'tools')
-rw-r--r--tools/codegen/src/com/android/codegen/FileInfo.kt4
-rw-r--r--tools/codegen/src/com/android/codegen/Utils.kt12
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)