Nikky
08/30/2019, 7:50 PMThis property is marked as @Transient and therefore must have an initializing expressionseems like this is no longer valid?
@Transient
lateinit var rootDir: File
this seems to only be a error on 1.3.50, worked fine on 1.3.41Casey Brooks
08/30/2019, 8:01 PMlateinit
doesn't make sense because it's in an undefined state after deserialization, it's never initialized. There's no way for the deserializer to infer a default value for every possible type, so the only reasonable solution is to require the developer to provide itNikky
08/30/2019, 8:05 PMCasey Brooks
08/30/2019, 8:11 PMlateinit
is designed for something you know is going to be set. If you can't reasonably expect a property to actually be set during some initialization process, you should probably keep it nullable. Keep in mind that lateinit
does not mean "null until set", as would be the case for such variables in Java; it's a much stronger contract than thatNikky
08/30/2019, 8:13 PM@Transient
val sourceFolder: File
get() = rootDir.resolve(sourceDir)
these do not error at all, like you would expect them to i guess
i would hate to cover everything with safecalls and nullchecks if lateinit is exactly what i needStephan Schroeder
09/02/2019, 9:38 AMlateinit
is for dependency injection into property (into constructor works obviously without it)