📜 ⬆️ ⬇️

Kotlin compiler message types to use in Suppress

Kotlin error and warning message types


The warnings and errors that the Kotlin compiler generates often need to be masked, either so that they do not callus eyes, or simply because the program logic needs just such code that leads to an error or warning message.



Masking compiler messages in both Java and Kotlin is the same:


 @Suppress("MESSAGE") 

where "MESSAGE" is a message type.


The problem is that it is often impossible to find out in a simple way which type of message corresponds to a specific text. For some reason, Lint tips do not always work strongly, there is no auto-completion, and for some reason this information has not been published by the Kotlin developers.


To make it easier to find the right types of messages, I put them together with the text in one table. If you need to disguise a message, you can easily find it in this table and find out what type you need to specify in order to suppress it.


Sample table


Type ofMessage
Data class inheritance from other classes is forbiddenDATA_CLASS_CANNOT_HAVE_CLASS_SUPERTYPES
Data constructor parameterDATA_CLASS_WITHOUT_PARAMETERS

In one post on Habré, it’s impossible to thrust a table of messages, and there is no sense in spreading it over several messages. it will be inconvenient to use, so I put it on GitHub.


Link to the full version of the table


Perhaps someone this information is useful.


')

Source: https://habr.com/ru/post/322026/


All Articles