diff src/name/blackcap/exifwasher/Misc.kt @ 21:539c3641c539

Input type to SetOnceImpl cannot be nullable.
author David Barts <n5jrn@me.com>
date Sun, 12 Apr 2020 18:46:57 -0700
parents 965435b85a69
children cd2ca4727b7f
line wrap: on
line diff
--- a/src/name/blackcap/exifwasher/Misc.kt	Sun Apr 12 11:46:12 2020 -0700
+++ b/src/name/blackcap/exifwasher/Misc.kt	Sun Apr 12 18:46:57 2020 -0700
@@ -23,7 +23,7 @@
  * needed in Swing, because some vars inevitably need to be declared at
  * outer levels but initialized in the Swing event dispatch thread.
  */
-class SetOnceImpl<T>: ReadWriteProperty<Any?,T> {
+class SetOnceImpl<T: Any>: ReadWriteProperty<Any?,T> {
     private var setOnceValue: T? = null
 
     override operator fun getValue(thisRef: Any?, property: KProperty<*>): T {
@@ -43,7 +43,7 @@
     }
 }
 
-fun <T> setOnce(): SetOnceImpl<T> = SetOnceImpl<T>()
+fun <T: Any> setOnce(): SetOnceImpl<T> = SetOnceImpl<T>()
 
 /**
  * Run something in the Swing thread, asynchronously.