Which keywords can be used as identifiers?


#1

Hi there,

I’m working on improving an otherwise excellent ANTLR Kotlin grammar and I ran across failures resulting from Kotlin allowing some keywords to be used as identifiers (method/parameter names). Would you happen to have a comprehensive list of keywords that can act this way?

Thank you in advance!
Marcin


#2

You can find the full list of Kotlin’s tokens here. Anything marked as softKeyword or softKeywordModifier is a context-dependent keyword, which can also be used as an identifier.


#3

Thanks a lot. Isn’t native missing from the list?


#4

No. @native is an annotation, not a keyword.


#5

How about this piece of Kotlin code?


#6

This repo is obsolete.


#7

Is it then safe to assume the language does not maintain backwards compatibility?
This BTW is not a charged question, just a hint I need to design the grammar.


#8

Kotlin team really didn’t care about BC before release. But things changed after 1.0 version.


#9

The language did not maintain the backward compatibility before the 1.0 release, and does maintain it now. The linked repo predates 1.0.