Moritz Hofmeister
02/22/2022, 9:49 AMPostState
although the migration guide lists this as a migration step
• Initialization of the PostState
is done by assigning an object
derived from PostState
to the state
in the init
block, but IntelliJ shows a warning that this object
should be an external interface
to tell the compiler that this is no Kotlin object as described in the migration guide
Are there other open source JetBrains projects (or just other projects in general) that already use the IR compiler to get some insights on how this more restrictive design is handled in these projects?turansky
02/22/2022, 10:18 AMturansky
02/22/2022, 10:18 AMturansky
02/22/2022, 10:20 AMBoolean
.
Required boolean property is fine.turansky
02/22/2022, 10:24 AMMoritz Hofmeister
02/22/2022, 12:29 PMMoritz Hofmeister
02/22/2022, 12:31 PMturansky
02/22/2022, 12:42 PMturansky
02/22/2022, 12:45 PMturansky
02/22/2022, 12:45 PMturansky
02/22/2022, 12:49 PMMoritz Hofmeister
02/22/2022, 12:52 PMexternal interface MyState : RState { var myBoolean: Boolean? }
Having to make all booleans nullable in MyState
adds an extra layer of complexity because it either requires to force unwrap the boolean for every usage or putting all state members in a separate class which is then put in MyState
like external interface MyState : RState { var myClass: MyClass }
& class MyClass(var myBoolean: Boolean)
Moritz Hofmeister
02/22/2022, 12:53 PMturansky
02/22/2022, 1:01 PMturansky
02/22/2022, 1:02 PMundefined
like false
Moritz Hofmeister
02/22/2022, 1:32 PMif (!someBoolean)
would currently need to look like if (someBoolean != true)
when changing it to be nullableMoritz Hofmeister
02/22/2022, 1:38 PMturansky
02/22/2022, 1:40 PMMoritz Hofmeister
02/22/2022, 1:59 PMvonox7
02/22/2022, 2:12 PMturansky
02/22/2022, 2:49 PMkotlin-wrappers
project
In my project I use it even for optional properties, when false
by default is fine.
It’s unsafe, but it’s less code and more readability
@Sergei GrishchenkoSergei Grishchenko
02/22/2022, 4:00 PMMoritz Hofmeister [3:31 PM]
@Boolean warning: Do you mean that it’s not necessary to make booleans nullable in external interfaces or what do you mean by that
Victor Turansky [4:40 PM]
I use non-nullable booleans (“unsafe boolean”) (edited)I totally agree with @turansky, in case of Kotlin/JVM integration, developer decides whether value received from Java code is nullable or not, I think the same strategy should be used in case of Kotlin/JS integration too, only developer should decide his Boolean is nullable or not, in my point of view forcing everybody to use nullable booleans is big mistake
vonox7
02/23/2022, 8:52 AMturansky
02/23/2022, 12:14 PMturansky
02/23/2022, 12:21 PM