Class::property.name should be compile-time constant


#1

Hi!

I’m trying out Kotlin. Coming from a C# background, I already saw some people suggesting the nameof function. And I also saw some people recomending using the format in the title.

I was playing around with some annotations and I would like to annotate a field referencing another field in another class, but IntelliJ tells me it’s not possible this way because Class::property.name is not a compile-time constant:

image

I think it would be really nice if we could do something like that and not have to define constants and loose strings elsewhere in the code. (dunno if it is really possible in java n_n’)

What you guys think?


#2

There’s an open issue about that: KT-16304