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

Commit 7f966b51 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Fix assignment for last element in codegen list" into main am: 12e1764d

parents 5a35131a 12e1764d
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)