sandjelkovic
12/18/2019, 6:04 PMlateinit var
not allowed for inline classes that wrap types that otherwise can be lateinit
-ed?
For example:
inline class Id(val value: String)
can’t be used as
private lateinit var id: Id
and is there a workaround that is not a nullable field or a data class?StavFX
12/18/2019, 7:03 PMtypealias
instead for this purpose.
If your inline class has other properties/methods, you can replace them with extension methods.
So
inline class Foo(i: Int) {
fun bar() = ...
}
Turns into
typealias Foo = Int
fun Foo.bar() = ...
StavFX
12/18/2019, 7:05 PMbar()
on any Int, which wouldn’t be possible with inline class, but again, pretty close.sandjelkovic
12/19/2019, 8:38 AMtypealias Foo = Int
typealias Bar = Int
foo > bar
// passes, even though they are supposed to be 2 different types
Essentially, typealias doesn’t create a new typeStavFX
12/19/2019, 5:53 PMyou'll be able to call bar() on any Int
. If that’s a deal-breaker for you, you might have to settle on a nullable property, or wait till this is fixed 😛
It’s probably worth opening a youtrack ticket for.