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

Commit 12e1764d authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Fix assignment for last element in codegen list" into main

parents 5e5cfe6c 815016a6
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)