thanksforallthefish
11/01/2018, 4:13 PMtoString
does not seem consistent (given my understanding that inline classes are substituted with their member)
given
inline class ProjectUid(val projectUid: String)
println(ProjectUid("test"))
the output is ProjectUid(projectUid=test)
, I would have expected only test
. This "breaks" some libraries (simple workaround is to inline myself)
am I misundersting something? is this behavior expected?diesieben07
11/01/2018, 4:16 PMprintln
, which expects Any?
, so the compiler has to create a boxing operation to preserve the semantics (proper toString).louiscad
11/01/2018, 4:52 PMtoString()
overriding method. And as said above, this is not like type aliases.thanksforallthefish
11/02/2018, 7:04 AMlouiscad
11/02/2018, 7:12 AMAny
Andreas Sinz
11/02/2018, 8:27 AMprintln
already expects Any
, so it would be fine to pass in the underlying string instead of a boxed versionlouiscad
11/02/2018, 8:40 AMAny
. The solution is to unwrap before, if possible (which it is here)thanksforallthefish
11/02/2018, 9:23 AMAt runtime, instances of the inline class will be represented using this single property
(at the beginning of the page) threw me off and made think inlining was always done