https://kotlinlang.org logo
Title
e

egorand

02/15/2019, 3:55 PM
Got a bug report on KotlinPoet regarding the following scenario:
enum class RenderPassCreate(override val value: Int) {
    companion object
}
This is the code we currently generate, and it will not compile, with the error being
Expecting ';' after the last enum entry or '}' to close enum class body
. The compiler expects the following:
enum class RenderPassCreate(override val value: Int) {
    ;
    companion object
}
which in my opinion looks ugly. I wonder if there’s a hard technical limitation behind this, and whether the compiler could handle this better? Tried searching YouTrack and it doesn’t look like it’s been filed
r

Ruckus

02/15/2019, 4:26 PM
How do you expect the compiler to know
companion
isn't one of the enum's values? As a side note, what is the purpose of an enum without values?
💯 1
e

egorand

02/15/2019, 5:23 PM
both are good points
d

Dominaezzz

02/15/2019, 5:38 PM
In vulkan, some enums have no entries yet and are reserved for future use.
r

Ruckus

02/15/2019, 6:06 PM
@Dominaezzz Interesting. That seems... pointless, but that may just be because I've never done any Vulkan development.
d

Dominaezzz

02/15/2019, 6:13 PM
It's done so they don't have the situation where they have to make a
vkCreateRenderPass2(...)
method because
vkCreateRenderPass(...)
doesn't take a
RenderPassCreate
parameter. It's also consistent with all the other
vkCreateSomeObject
methods that take a
SomeObjectCreate
parameter that have actual entries.
r

Ruckus

02/15/2019, 7:35 PM
So you always pass in null for now? Or can you just not call the function yet?
d

Dominaezzz

02/15/2019, 7:43 PM
Yeah, always pass null.