Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parcelize complains "Parcelable should be a class" on objects and enums

When I try to annotate an enum class or object with @Parcelize, it results in the error 'Parcelable' should be a class, both as an editor hint and as a compile failure. I can @Parcelize classes just fine, but I can't do things like

@Parcelize object MySingletion : Parcelable
@Parcelize enum class Direction : Parcelable { N, E, W, S }

This happens even though the Kotlin website explicitly states that objects and enums are supported. Is there a way to fix this so that I can @Parcelize these types of classes? And ideally, is there a solution that doesn't involve manually coding the parceler logic?

like image 484
Leo Aso Avatar asked Jul 09 '18 20:07

Leo Aso


1 Answers

Since Kotlin 1.2.60, the CHANGELOG states that Parcelize works with object and enum types.

like image 134
veyndan Avatar answered Sep 24 '22 01:09

veyndan