Which keywords can be used as identifiers?

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

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.

1 Like

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

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

How about this piece of Kotlin code?

This repo is obsolete.

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.

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

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

1 Like