Make FE1.0/FIR OptIn override message more clear

This commit is contained in:
Mikhail Glukhikh
2022-03-03 10:49:56 +03:00
committed by Space
parent d823020c07
commit 779aa75855
11 changed files with 133 additions and 16 deletions
@@ -45,4 +45,12 @@ object OptInNames {
fun buildMessagePrefix(verb: String): String =
"This declaration needs OptIn. Its usage $verb be marked"
fun buildOverrideMessage(supertypeName: String, markerMessage: String?, verb: String, markerName: String): String {
val basePrefix = "Base declaration of supertype '$supertypeName' needs OptIn. "
val markerMessageOrStub = markerMessage
?.takeIf { it.isNotBlank() }?.let { if (it.endsWith(".")) "$it " else "$it. " } ?: ""
val baseSuffix = "The declaration override $verb be annotated with '@$markerName'"
return basePrefix + markerMessageOrStub + baseSuffix
}
}