FIR: Add two label-related fields to FirContextReceiver

This commit is contained in:
Denis.Zharkov
2022-02-17 18:14:18 +03:00
committed by teamcity
parent 550d24f8c6
commit c595780d83
8 changed files with 24 additions and 11 deletions
@@ -34,7 +34,6 @@ import org.jetbrains.kotlin.fir.diagnostics.ConeSimpleDiagnostic
import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind
import org.jetbrains.kotlin.fir.expressions.*
import org.jetbrains.kotlin.fir.expressions.builder.*
import org.jetbrains.kotlin.fir.expressions.impl.FirEmptyAnnotationArgumentMapping
import org.jetbrains.kotlin.fir.expressions.impl.FirSingleExpressionBlock
import org.jetbrains.kotlin.fir.lightTree.LightTree2Fir
import org.jetbrains.kotlin.fir.lightTree.fir.*
@@ -2261,14 +2260,20 @@ class DeclarationsConverter(
return receivers.map { contextReceiverElement ->
buildContextReceiver {
this.source = contextReceiverElement.toFirSourceElement()
this.labelName =
this.customLabelName =
contextReceiverElement
.getChildNodeByType(LABEL_QUALIFIER)
?.getChildNodeByType(LABEL)
?.getChildNodeByType(IDENTIFIER)
?.getReferencedNameAsName()
contextReceiverElement.getChildNodeByType(TYPE_REFERENCE)?.let {
val typeReference = contextReceiverElement.getChildNodeByType(TYPE_REFERENCE)
this.labelNameFromTypeRef = typeReference?.getChildNodeByType(USER_TYPE)
?.getChildNodeByType(REFERENCE_EXPRESSION)
?.getReferencedNameAsName()
typeReference?.let {
this.typeRef = convertType(it)
}
}
@@ -25,7 +25,6 @@ import org.jetbrains.kotlin.fir.declarations.utils.*
import org.jetbrains.kotlin.fir.diagnostics.*
import org.jetbrains.kotlin.fir.expressions.*
import org.jetbrains.kotlin.fir.expressions.builder.*
import org.jetbrains.kotlin.fir.expressions.impl.FirEmptyAnnotationArgumentMapping
import org.jetbrains.kotlin.fir.expressions.impl.FirSingleExpressionBlock
import org.jetbrains.kotlin.fir.references.builder.*
import org.jetbrains.kotlin.fir.scopes.FirScopeProvider
@@ -1028,7 +1027,8 @@ open class RawFirBuilder(
return receivers.map { contextReceiverElement ->
buildContextReceiver {
this.source = contextReceiverElement.toFirSourceElement()
this.labelName = contextReceiverElement.labelNameAsName()
this.customLabelName = contextReceiverElement.labelNameAsName()
this.labelNameFromTypeRef = contextReceiverElement.typeReference()?.nameForReceiverLabel()?.let(Name::identifier)
contextReceiverElement.typeReference().convertSafe<FirTypeRef>()?.let {
this.typeRef = it