[FIR] Unify some special names to make code more uniform

This commit is contained in:
Roman Golyshev
2022-05-31 18:09:06 +04:00
parent 023def9d25
commit 01ce499bb2
20 changed files with 159 additions and 140 deletions
@@ -61,6 +61,24 @@ object SpecialNames {
@JvmField
val IMPLICIT_SET_PARAMETER = Name.special("<set-?>")
@JvmField
val ARRAY = Name.special("<array>")
@JvmField
val RECEIVER = Name.special("<receiver>")
/**
* Special name to store expressions used as indexes in subscription operators (`get` and `set`).
*
* For example, `bar1()` and `bar2()` are indexes in `foo[bar1(), bar2()]` call.
*/
@JvmStatic
fun subscribeOperatorIndex(idx: Int): Name {
require(idx >= 0) { "Index should be non-negative, but was $idx" }
return Name.special("<index_$idx>")
}
@JvmStatic
fun safeIdentifier(name: Name?): Name {
return if (name != null && !name.isSpecial) name else SAFE_IDENTIFIER_FOR_NO_NAME