Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 815016a6 authored by Sorin Basca's avatar Sorin Basca
Browse files

Fix assignment for last element in codegen list

Bug: 322973175
Test: TH
Change-Id: Ib55bea6050e0d125c0d7d4821d75101085ab48af
parent 5bb6f919
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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 {
+1 −11
Original line number Diff line number Diff line
@@ -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)