Move SSD truth index guard to typed Kotlin
ober
b20dd09de5be90c975a1f6b1440b5bdf83c33855
--- a/templates/ssd-review.ss +++ b/templates/ssd-review.ss @@ -5567,7 +5567,7 @@ (typed-kotlin-file "com/sfb/ssdreview/TruthIndexSelect.kt" (typed-library (com sfb ssdreview) - (export bestTruthIndexForSession) + (export bestTruthIndexForSession truthIndexEntryPresent) (type Int32) (type TruthIndexEntry) (type SsdSession) @@ -5586,6 +5586,8 @@ (if (betterTruthIndex candidate (nullable-get current)) (nullable-some candidate) current))) + (def (truthIndexEntryPresent (entry : (Nullable TruthIndexEntry))) : Bool + (not (nullable-null? entry))) (def (bestTruthIndexForSession (entries : (List TruthIndexEntry)) (initial : (Nullable TruthIndexEntry)) (session : SsdSession)) : (Nullable TruthIndexEntry) @@ -8636,7 +8638,8 @@ " truthIndexEntry(truthPath(session.sourceKey))," " session" " )" - " return best?.let { jsonObjectFromText(readLocalText(it._file)) }" + " if (!truthIndexEntryPresent(best)) return null" + " return jsonObjectFromText(readLocalText(checkNotNull(best)._file))" " }" "" " @Synchronized"