[FIR] Introduce FirArgumentList node

This commit is contained in:
Mikhail Glukhikh
2020-03-11 12:30:41 +03:00
parent 476d3c4092
commit 91d51b93e1
71 changed files with 596 additions and 407 deletions
@@ -8,7 +8,7 @@ package org.jetbrains.kotlin.fir.backend
import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.*
import org.jetbrains.kotlin.fir.expressions.FirComparisonExpression import org.jetbrains.kotlin.fir.expressions.FirComparisonExpression
import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirExpression
import org.jetbrains.kotlin.fir.resolve.firSymbolProvider import org.jetbrains.kotlin.fir.expressions.arguments
import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.*
import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult
@@ -16,10 +16,7 @@ import org.jetbrains.kotlin.fir.declarations.FirTypeParameter
import org.jetbrains.kotlin.fir.declarations.FirValueParameter import org.jetbrains.kotlin.fir.declarations.FirValueParameter
import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind
import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.*
import org.jetbrains.kotlin.fir.expressions.FirArrayOfCall
import org.jetbrains.kotlin.fir.expressions.FirConstKind
import org.jetbrains.kotlin.fir.expressions.FirExpression
import org.jetbrains.kotlin.fir.expressions.builder.* import org.jetbrains.kotlin.fir.expressions.builder.*
import org.jetbrains.kotlin.fir.java.declarations.buildJavaValueParameter import org.jetbrains.kotlin.fir.java.declarations.buildJavaValueParameter
import org.jetbrains.kotlin.fir.java.enhancement.readOnlyToMutable import org.jetbrains.kotlin.fir.java.enhancement.readOnlyToMutable
@@ -335,8 +332,10 @@ internal fun JavaAnnotation.toFirAnnotationCall(
annotationTypeRef = buildResolvedTypeRef { annotationTypeRef = buildResolvedTypeRef {
type = ConeClassLikeTypeImpl(FirRegularClassSymbol(classId!!).toLookupTag(), emptyArray(), isNullable = false) type = ConeClassLikeTypeImpl(FirRegularClassSymbol(classId!!).toLookupTag(), emptyArray(), isNullable = false)
} }
for (argument in this@toFirAnnotationCall.arguments) { argumentList = buildArgumentList {
arguments += argument.toFirExpression(session, javaTypeParameterStack) for (argument in this@toFirAnnotationCall.arguments) {
arguments += argument.toFirExpression(session, javaTypeParameterStack)
}
} }
} }
} }
@@ -399,8 +398,10 @@ private fun JavaAnnotationArgument.toFirExpression(
value.createConstant(session) value.createConstant(session)
} }
is JavaArrayAnnotationArgument -> buildArrayOfCall { is JavaArrayAnnotationArgument -> buildArrayOfCall {
for (element in getElements()) { argumentList = buildArgumentList {
arguments += element.toFirExpression(session, javaTypeParameterStack) for (element in getElements()) {
arguments += element.toFirExpression(session, javaTypeParameterStack)
}
} }
} }
is JavaEnumValueAnnotationArgument -> { is JavaEnumValueAnnotationArgument -> {
@@ -428,9 +429,11 @@ private fun JavaAnnotationArgument.toFirExpression(
} }
is JavaClassObjectAnnotationArgument -> buildGetClassCall { is JavaClassObjectAnnotationArgument -> buildGetClassCall {
val referencedType = getReferencedType() val referencedType = getReferencedType()
arguments += buildClassReferenceExpression { argumentList = buildUnaryArgumentList(
classTypeRef = referencedType.toFirResolvedTypeRef(session, javaTypeParameterStack) buildClassReferenceExpression {
} classTypeRef = referencedType.toFirResolvedTypeRef(session, javaTypeParameterStack)
}
)
} }
is JavaAnnotationAsAnnotationArgument -> getAnnotation().toFirAnnotationCall(session, javaTypeParameterStack) is JavaAnnotationAsAnnotationArgument -> getAnnotation().toFirAnnotationCall(session, javaTypeParameterStack)
else -> buildErrorExpression { else -> buildErrorExpression {
@@ -442,8 +445,10 @@ private fun JavaAnnotationArgument.toFirExpression(
// TODO: use kind here // TODO: use kind here
private fun <T> List<T>.createArrayOfCall(session: FirSession, @Suppress("UNUSED_PARAMETER") kind: FirConstKind<T>): FirArrayOfCall { private fun <T> List<T>.createArrayOfCall(session: FirSession, @Suppress("UNUSED_PARAMETER") kind: FirConstKind<T>): FirArrayOfCall {
return buildArrayOfCall { return buildArrayOfCall {
for (element in this@createArrayOfCall) { argumentList = buildArgumentList {
arguments += element.createConstant(session) for (element in this@createArrayOfCall) {
arguments += element.createConstant(session)
}
} }
} }
} }
@@ -18,9 +18,7 @@ import org.jetbrains.kotlin.fir.deserialization.FirDeserializationContext
import org.jetbrains.kotlin.fir.deserialization.deserializeClassToSymbol import org.jetbrains.kotlin.fir.deserialization.deserializeClassToSymbol
import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind
import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.*
import org.jetbrains.kotlin.fir.expressions.FirClassReferenceExpression
import org.jetbrains.kotlin.fir.expressions.FirExpression
import org.jetbrains.kotlin.fir.expressions.builder.* import org.jetbrains.kotlin.fir.expressions.builder.*
import org.jetbrains.kotlin.fir.java.JavaSymbolProvider import org.jetbrains.kotlin.fir.java.JavaSymbolProvider
import org.jetbrains.kotlin.fir.java.createConstant import org.jetbrains.kotlin.fir.java.createConstant
@@ -223,7 +221,7 @@ class KotlinDeserializedJvmSymbolsProvider(
override fun visitClassLiteral(name: Name, value: ClassLiteralValue) { override fun visitClassLiteral(name: Name, value: ClassLiteralValue) {
argumentMap[name] = buildGetClassCall { argumentMap[name] = buildGetClassCall {
arguments += value.toFirClassReferenceExpression() argumentList = buildUnaryArgumentList(value.toFirClassReferenceExpression())
} }
} }
@@ -249,7 +247,9 @@ class KotlinDeserializedJvmSymbolsProvider(
override fun visitEnd() { override fun visitEnd() {
argumentMap[name] = buildArrayOfCall { argumentMap[name] = buildArrayOfCall {
arguments += elements argumentList = buildArgumentList {
arguments += elements
}
} }
} }
} }
@@ -269,11 +269,13 @@ class KotlinDeserializedJvmSymbolsProvider(
override fun visitEnd() { override fun visitEnd() {
result += buildAnnotationCall { result += buildAnnotationCall {
annotationTypeRef = symbol.toDefaultResolvedTypeRef(annotationClassId) annotationTypeRef = symbol.toDefaultResolvedTypeRef(annotationClassId)
for ((name, expression) in argumentMap) { argumentList = buildArgumentList {
arguments += buildNamedArgumentExpression { for ((name, expression) in argumentMap) {
this.expression = expression arguments += buildNamedArgumentExpression {
this.name = name this.expression = expression
isSpread = false this.name = name
isSpread = false
}
} }
} }
} }
@@ -6,6 +6,7 @@
package org.jetbrains.kotlin.fir.java.enhancement package org.jetbrains.kotlin.fir.java.enhancement
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.arguments
import org.jetbrains.kotlin.fir.expressions.classId import org.jetbrains.kotlin.fir.expressions.classId
import org.jetbrains.kotlin.fir.expressions.toResolvedCallableSymbol import org.jetbrains.kotlin.fir.expressions.toResolvedCallableSymbol
import org.jetbrains.kotlin.load.java.* import org.jetbrains.kotlin.load.java.*
@@ -15,16 +15,11 @@ import org.jetbrains.kotlin.descriptors.Visibilities
import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.FirSession
import org.jetbrains.kotlin.fir.builder.generateResolvedAccessExpression import org.jetbrains.kotlin.fir.builder.generateResolvedAccessExpression
import org.jetbrains.kotlin.fir.declarations.FirVariable import org.jetbrains.kotlin.fir.declarations.FirVariable
import org.jetbrains.kotlin.fir.declarations.builder.FirTypeParametersOwnerBuilder
import org.jetbrains.kotlin.fir.declarations.builder.buildProperty import org.jetbrains.kotlin.fir.declarations.builder.buildProperty
import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl
import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirExpression
import org.jetbrains.kotlin.fir.expressions.builder.FirAnnotationCallBuilder import org.jetbrains.kotlin.fir.expressions.builder.*
import org.jetbrains.kotlin.fir.expressions.builder.FirCallBuilder
import org.jetbrains.kotlin.fir.expressions.builder.buildBlock
import org.jetbrains.kotlin.fir.expressions.builder.buildComponentCall
import org.jetbrains.kotlin.fir.lightTree.fir.DestructuringDeclaration import org.jetbrains.kotlin.fir.lightTree.fir.DestructuringDeclaration
import org.jetbrains.kotlin.fir.lightTree.fir.TypeConstraint
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
import org.jetbrains.kotlin.lexer.KtSingleValueToken import org.jetbrains.kotlin.lexer.KtSingleValueToken
import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.lexer.KtTokens
@@ -75,7 +70,9 @@ fun LighterASTNode.isExpression(): Boolean {
fun <T : FirCallBuilder> T.extractArgumentsFrom(container: List<FirExpression>, stubMode: Boolean): T { fun <T : FirCallBuilder> T.extractArgumentsFrom(container: List<FirExpression>, stubMode: Boolean): T {
if (!stubMode || this is FirAnnotationCallBuilder) { if (!stubMode || this is FirAnnotationCallBuilder) {
this.arguments += container argumentList = buildArgumentList {
arguments += container
}
} }
return this return this
} }
@@ -236,7 +236,7 @@ class ExpressionsConverter(
name = conventionCallName ?: operationTokenName.nameAsSafeName() name = conventionCallName ?: operationTokenName.nameAsSafeName()
} }
explicitReceiver = leftArgAsFir explicitReceiver = leftArgAsFir
arguments += rightArgAsFir argumentList = buildUnaryArgumentList(rightArgAsFir)
} }
} else { } else {
val firOperation = operationToken.toFirOperation() val firOperation = operationToken.toFirOperation()
@@ -246,8 +246,7 @@ class ExpressionsConverter(
buildOperatorCall { buildOperatorCall {
source = binaryExpression.toFirSourceElement() source = binaryExpression.toFirSourceElement()
operation = firOperation operation = firOperation
arguments += leftArgAsFir argumentList = buildBinaryArgumentList(leftArgAsFir, rightArgAsFir)
arguments += rightArgAsFir
} }
} }
} }
@@ -277,7 +276,7 @@ class ExpressionsConverter(
source = binaryExpression.toFirSourceElement() source = binaryExpression.toFirSourceElement()
operation = operationTokenName.toFirOperation() operation = operationTokenName.toFirOperation()
conversionTypeRef = firType conversionTypeRef = firType
arguments += leftArgAsFir argumentList = buildUnaryArgumentList(leftArgAsFir)
} }
} }
@@ -325,7 +324,7 @@ class ExpressionsConverter(
operationToken == EXCLEXCL -> { operationToken == EXCLEXCL -> {
buildCheckNotNullCall { buildCheckNotNullCall {
source = unaryExpression.toFirSourceElement() source = unaryExpression.toFirSourceElement()
arguments += getAsFirExpression<FirExpression>(argument, "No operand") argumentList = buildUnaryArgumentList(getAsFirExpression<FirExpression>(argument, "No operand"))
} }
} }
@@ -338,7 +337,7 @@ class ExpressionsConverter(
prefix = unaryExpression.tokenType == PREFIX_EXPRESSION prefix = unaryExpression.tokenType == PREFIX_EXPRESSION
) { getAsFirExpression(this) } ) { getAsFirExpression(this) }
} }
buildFunctionCall{ buildFunctionCall {
source = unaryExpression.toFirSourceElement() source = unaryExpression.toFirSourceElement()
calleeReference = buildSimpleNamedReference { name = conventionCallName } calleeReference = buildSimpleNamedReference { name = conventionCallName }
explicitReceiver = getAsFirExpression(argument, "No operand") explicitReceiver = getAsFirExpression(argument, "No operand")
@@ -349,7 +348,7 @@ class ExpressionsConverter(
buildOperatorCall { buildOperatorCall {
source = unaryExpression.toFirSourceElement() source = unaryExpression.toFirSourceElement()
operation = firOperation operation = firOperation
arguments += getAsFirExpression<FirExpression>(argument, "No operand") argumentList = buildUnaryArgumentList(getAsFirExpression<FirExpression>(argument, "No operand"))
} }
} }
} }
@@ -388,7 +387,7 @@ class ExpressionsConverter(
return buildGetClassCall { return buildGetClassCall {
source = classLiteralExpression.toFirSourceElement() source = classLiteralExpression.toFirSourceElement()
arguments += firReceiverExpression argumentList = buildUnaryArgumentList(firReceiverExpression)
} }
} }
@@ -642,10 +641,11 @@ class ExpressionsConverter(
buildOperatorCall { buildOperatorCall {
source = whenCondition.toFirSourceElement() source = whenCondition.toFirSourceElement()
operation = FirOperation.EQ operation = FirOperation.EQ
arguments += buildWhenSubjectExpression { argumentList = buildBinaryArgumentList(
whenSubject = subject buildWhenSubjectExpression {
} whenSubject = subject
arguments += firExpression }, firExpression
)
} }
} else { } else {
@@ -708,7 +708,7 @@ class ExpressionsConverter(
source = whenCondition.toFirSourceElement() source = whenCondition.toFirSourceElement()
operation = firOperation operation = firOperation
conversionTypeRef = firType conversionTypeRef = firType
arguments += subjectExpression argumentList = buildUnaryArgumentList(subjectExpression)
} }
} }
@@ -732,8 +732,10 @@ class ExpressionsConverter(
name = if (getArgument == null) OperatorNameConventions.GET else OperatorNameConventions.SET name = if (getArgument == null) OperatorNameConventions.GET else OperatorNameConventions.SET
} }
explicitReceiver = firExpression explicitReceiver = firExpression
arguments += indices argumentList = buildArgumentList {
getArgument?.let { arguments += it } arguments += indices
getArgument?.let { arguments += it }
}
} }
} }
@@ -748,7 +750,9 @@ class ExpressionsConverter(
return buildArrayOfCall { return buildArrayOfCall {
source = expression.toFirSourceElement() source = expression.toFirSourceElement()
arguments += firExpressionList argumentList = buildArgumentList {
arguments += firExpressionList
}
} }
} }
@@ -289,36 +289,38 @@ abstract class BaseFirBuilder<T>(val baseSession: FirSession, val context: Conte
return buildStringConcatenationCall { return buildStringConcatenationCall {
val sb = StringBuilder() val sb = StringBuilder()
var hasExpressions = false var hasExpressions = false
L@ for (entry in this@toInterpolatingCall) { argumentList = buildArgumentList {
if (entry == null) continue L@ for (entry in this@toInterpolatingCall) {
arguments += when (entry.elementType) { if (entry == null) continue
OPEN_QUOTE, CLOSING_QUOTE -> continue@L arguments += when (entry.elementType) {
LITERAL_STRING_TEMPLATE_ENTRY -> { OPEN_QUOTE, CLOSING_QUOTE -> continue@L
sb.append(entry.asText) LITERAL_STRING_TEMPLATE_ENTRY -> {
buildConstExpression(entry.getSourceOrNull(), FirConstKind.String, entry.asText) sb.append(entry.asText)
} buildConstExpression(entry.getSourceOrNull(), FirConstKind.String, entry.asText)
ESCAPE_STRING_TEMPLATE_ENTRY -> { }
sb.append(entry.unescapedValue) ESCAPE_STRING_TEMPLATE_ENTRY -> {
buildConstExpression(entry.getSourceOrNull(), FirConstKind.String, entry.unescapedValue) sb.append(entry.unescapedValue)
} buildConstExpression(entry.getSourceOrNull(), FirConstKind.String, entry.unescapedValue)
SHORT_STRING_TEMPLATE_ENTRY, LONG_STRING_TEMPLATE_ENTRY -> { }
hasExpressions = true SHORT_STRING_TEMPLATE_ENTRY, LONG_STRING_TEMPLATE_ENTRY -> {
val firExpression = entry.convertTemplateEntry("Incorrect template argument") hasExpressions = true
val source = firExpression.source val firExpression = entry.convertTemplateEntry("Incorrect template argument")
buildFunctionCall { val source = firExpression.source
this.source = source buildFunctionCall {
explicitReceiver = firExpression
calleeReference = buildSimpleNamedReference {
this.source = source this.source = source
name = Name.identifier("toString") explicitReceiver = firExpression
calleeReference = buildSimpleNamedReference {
this.source = source
name = Name.identifier("toString")
}
} }
} }
} else -> {
else -> { hasExpressions = true
hasExpressions = true buildErrorExpression {
buildErrorExpression { source = entry.getSourceOrNull()
source = entry.getSourceOrNull() diagnostic = FirSimpleDiagnostic("Incorrect template entry: ${entry.asText}", DiagnosticKind.Syntax)
diagnostic = FirSimpleDiagnostic("Incorrect template entry: ${entry.asText}", DiagnosticKind.Syntax) }
} }
} }
} }
@@ -326,7 +328,7 @@ abstract class BaseFirBuilder<T>(val baseSession: FirSession, val context: Conte
source = base?.toFirSourceElement() source = base?.toFirSourceElement()
// Fast-pass if there is no non-const string expressions // Fast-pass if there is no non-const string expressions
if (!hasExpressions) return buildConstExpression(source, FirConstKind.String, sb.toString()) if (!hasExpressions) return buildConstExpression(source, FirConstKind.String, sb.toString())
arguments.singleOrNull()?.let { return it } argumentList.arguments.singleOrNull()?.let { return it }
} }
} }
@@ -482,6 +484,7 @@ abstract class BaseFirBuilder<T>(val baseSession: FirSession, val context: Conte
rValue = value rValue = value
this.operation = operation this.operation = operation
indexes += firArrayAccess.arguments indexes += firArrayAccess.arguments
argumentList = FirArraySetArgumentList(rValue, indexes)
} }
val arrayExpression = this.getChildNodeByType(REFERENCE_EXPRESSION) val arrayExpression = this.getChildNodeByType(REFERENCE_EXPRESSION)
if (arrayExpression != null) { if (arrayExpression != null) {
@@ -510,12 +513,13 @@ abstract class BaseFirBuilder<T>(val baseSession: FirSession, val context: Conte
source = baseSource source = baseSource
this.operation = operation this.operation = operation
// TODO: take good psi // TODO: take good psi
arguments += this@generateAssignment?.convert() ?: argumentList = buildBinaryArgumentList(
buildErrorExpression { this@generateAssignment?.convert() ?: buildErrorExpression {
source = null source = null
diagnostic = FirSimpleDiagnostic("Unsupported left value of assignment: ${baseSource?.psi?.text}", DiagnosticKind.Syntax) diagnostic = FirSimpleDiagnostic("Unsupported left value of assignment: ${baseSource?.psi?.text}", DiagnosticKind.Syntax)
} },
arguments += value value
)
} }
} }
require(operation == FirOperation.ASSIGN) require(operation == FirOperation.ASSIGN)
@@ -166,8 +166,9 @@ fun FirExpression.generateNotNullOrOther(
condition = buildOperatorCall { condition = buildOperatorCall {
source = baseSource source = baseSource
operation = FirOperation.EQ operation = FirOperation.EQ
arguments += subjectExpression argumentList = buildBinaryArgumentList(
arguments += buildConstExpression(baseSource, FirConstKind.Null, null) subjectExpression, buildConstExpression(baseSource, FirConstKind.Null, null)
)
} }
result = buildSingleExpressionBlock(other) result = buildSingleExpressionBlock(other)
} }
@@ -209,8 +210,9 @@ internal fun KtWhenCondition.toFirWhenCondition(
buildOperatorCall { buildOperatorCall {
source = expression?.toFirSourceElement() source = expression?.toFirSourceElement()
operation = FirOperation.EQ operation = FirOperation.EQ
arguments += firSubjectExpression argumentList = buildBinaryArgumentList(
arguments += expression.convert("No expression in condition with expression") firSubjectExpression, expression.convert("No expression in condition with expression")
)
} }
} }
is KtWhenConditionInRange -> { is KtWhenConditionInRange -> {
@@ -222,7 +224,7 @@ internal fun KtWhenCondition.toFirWhenCondition(
source = typeReference?.toFirSourceElement() source = typeReference?.toFirSourceElement()
operation = if (isNegated) FirOperation.NOT_IS else FirOperation.IS operation = if (isNegated) FirOperation.NOT_IS else FirOperation.IS
conversionTypeRef = typeReference.toFirOrErrorTypeRef() conversionTypeRef = typeReference.toFirOrErrorTypeRef()
arguments += firSubjectExpression argumentList = buildUnaryArgumentList(firSubjectExpression)
} }
} }
else -> { else -> {
@@ -313,7 +315,7 @@ private fun FirExpression.createConventionCall(
name = conventionName name = conventionName
} }
explicitReceiver = this@createConventionCall explicitReceiver = this@createConventionCall
arguments += argument argumentList = buildUnaryArgumentList(argument)
} }
} }
@@ -407,6 +409,7 @@ fun FirPropertyBuilder.generateAccessorsByDelegate(
val delegateFieldSymbol = FirDelegateFieldSymbol<FirProperty>(symbol.callableId).also { val delegateFieldSymbol = FirDelegateFieldSymbol<FirProperty>(symbol.callableId).also {
this.delegateFieldSymbol = it this.delegateFieldSymbol = it
} }
fun delegateAccess() = buildQualifiedAccessExpression { fun delegateAccess() = buildQualifiedAccessExpression {
source = null source = null
calleeReference = buildDelegateFieldReference { calleeReference = buildDelegateFieldReference {
@@ -437,8 +440,7 @@ fun FirPropertyBuilder.generateAccessorsByDelegate(
source = null source = null
name = PROVIDE_DELEGATE name = PROVIDE_DELEGATE
} }
arguments += thisRef() argumentList = buildBinaryArgumentList(thisRef(), propertyRef())
arguments += propertyRef()
} }
delegate = delegateBuilder.build() delegate = delegateBuilder.build()
if (stubMode) return if (stubMode) return
@@ -460,8 +462,7 @@ fun FirPropertyBuilder.generateAccessorsByDelegate(
source = null source = null
name = GET_VALUE name = GET_VALUE
} }
arguments += thisRef() argumentList = buildBinaryArgumentList(thisRef(), propertyRef())
arguments += propertyRef()
} }
target = returnTarget target = returnTarget
} }
@@ -493,12 +494,14 @@ fun FirPropertyBuilder.generateAccessorsByDelegate(
calleeReference = buildSimpleNamedReference { calleeReference = buildSimpleNamedReference {
name = SET_VALUE name = SET_VALUE
} }
arguments += thisRef() argumentList = buildArgumentList {
arguments += propertyRef() arguments += thisRef()
arguments += buildQualifiedAccessExpression { arguments += propertyRef()
calleeReference = buildResolvedNamedReference { arguments += buildQualifiedAccessExpression {
name = DELEGATED_SETTER_PARAM calleeReference = buildResolvedNamedReference {
resolvedSymbol = parameter.symbol name = DELEGATED_SETTER_PARAM
resolvedSymbol = parameter.symbol
}
} }
} }
} }
@@ -369,16 +369,19 @@ class RawFirBuilder(
} }
private fun KtCallElement.extractArgumentsTo(container: FirCallBuilder) { private fun KtCallElement.extractArgumentsTo(container: FirCallBuilder) {
for (argument in this.valueArguments) { val argumentList = buildArgumentList {
val argumentExpression = argument.toFirExpression() for (argument in valueArguments) {
container.arguments += when (argument) { val argumentExpression = argument.toFirExpression()
is KtLambdaArgument -> buildLambdaArgumentExpression { arguments += when (argument) {
source = argument.toFirSourceElement() is KtLambdaArgument -> buildLambdaArgumentExpression {
expression = argumentExpression source = argument.toFirSourceElement()
expression = argumentExpression
}
else -> argumentExpression
} }
else -> argumentExpression
} }
} }
container.argumentList = argumentList
} }
private fun KtClassOrObject.extractSuperTypeListEntriesTo( private fun KtClassOrObject.extractSuperTypeListEntriesTo(
@@ -1388,7 +1391,7 @@ class RawFirBuilder(
name = conventionCallName ?: expression.operationReference.getReferencedNameAsName() name = conventionCallName ?: expression.operationReference.getReferencedNameAsName()
} }
explicitReceiver = leftArgument explicitReceiver = leftArgument
arguments += rightArgument argumentList = buildUnaryArgumentList(rightArgument)
} }
} else { } else {
val firOperation = operationToken.toFirOperation() val firOperation = operationToken.toFirOperation()
@@ -1400,8 +1403,7 @@ class RawFirBuilder(
buildOperatorCall { buildOperatorCall {
this.source = source this.source = source
operation = firOperation operation = firOperation
arguments += leftArgument argumentList = buildBinaryArgumentList(leftArgument, rightArgument)
arguments += rightArgument
} }
} }
} }
@@ -1412,7 +1414,7 @@ class RawFirBuilder(
source = expression.toFirSourceElement() source = expression.toFirSourceElement()
operation = expression.operationReference.getReferencedNameElementType().toFirOperation() operation = expression.operationReference.getReferencedNameElementType().toFirOperation()
conversionTypeRef = expression.right.toFirOrErrorType() conversionTypeRef = expression.right.toFirOrErrorType()
arguments += expression.left.toFirExpression("No left operand") argumentList = buildUnaryArgumentList(expression.left.toFirExpression("No left operand"))
} }
} }
@@ -1421,7 +1423,7 @@ class RawFirBuilder(
source = expression.toFirSourceElement() source = expression.toFirSourceElement()
operation = if (expression.isNegated) FirOperation.NOT_IS else FirOperation.IS operation = if (expression.isNegated) FirOperation.NOT_IS else FirOperation.IS
conversionTypeRef = expression.typeReference.toFirOrErrorType() conversionTypeRef = expression.typeReference.toFirOrErrorType()
arguments += expression.leftHandSide.toFirExpression("No left operand") argumentList = buildUnaryArgumentList(expression.leftHandSide.toFirExpression("No left operand"))
} }
} }
@@ -1433,7 +1435,7 @@ class RawFirBuilder(
operationToken == EXCLEXCL -> { operationToken == EXCLEXCL -> {
buildCheckNotNullCall { buildCheckNotNullCall {
source = expression.toFirSourceElement() source = expression.toFirSourceElement()
arguments += argument.toFirExpression("No operand") argumentList = buildUnaryArgumentList(argument.toFirExpression("No operand"))
} }
} }
conventionCallName != null -> { conventionCallName != null -> {
@@ -1457,7 +1459,7 @@ class RawFirBuilder(
buildOperatorCall { buildOperatorCall {
source = expression.toFirSourceElement() source = expression.toFirSourceElement()
operation = operationToken.toFirOperation() operation = operationToken.toFirOperation()
arguments += argument.toFirExpression("No operand") argumentList = buildUnaryArgumentList(argument.toFirExpression("No operand"))
} }
} }
} }
@@ -1534,11 +1536,13 @@ class RawFirBuilder(
} }
} }
explicitReceiver = arrayExpression.toFirExpression("No array expression") explicitReceiver = arrayExpression.toFirExpression("No array expression")
for (indexExpression in expression.indexExpressions) { argumentList = buildArgumentList {
arguments += indexExpression.toFirExpression("Incorrect index expression") for (indexExpression in expression.indexExpressions) {
} arguments += indexExpression.toFirExpression("Incorrect index expression")
if (getArgument != null) { }
arguments += getArgument if (getArgument != null) {
arguments += getArgument
}
} }
} }
} }
@@ -1645,7 +1649,7 @@ class RawFirBuilder(
override fun visitClassLiteralExpression(expression: KtClassLiteralExpression, data: Unit): FirElement { override fun visitClassLiteralExpression(expression: KtClassLiteralExpression, data: Unit): FirElement {
return buildGetClassCall { return buildGetClassCall {
source = expression.toFirSourceElement() source = expression.toFirSourceElement()
arguments += expression.receiverExpression.toFirExpression("No receiver in class literal") argumentList = buildUnaryArgumentList(expression.receiverExpression.toFirExpression("No receiver in class literal"))
} }
} }
@@ -1664,8 +1668,10 @@ class RawFirBuilder(
override fun visitCollectionLiteralExpression(expression: KtCollectionLiteralExpression, data: Unit): FirElement { override fun visitCollectionLiteralExpression(expression: KtCollectionLiteralExpression, data: Unit): FirElement {
return buildArrayOfCall { return buildArrayOfCall {
source = expression.toFirSourceElement() source = expression.toFirSourceElement()
for (innerExpression in expression.getInnerExpressions()) { argumentList = buildArgumentList {
arguments += innerExpression.toFirExpression("Incorrect collection literal argument") for (innerExpression in expression.getInnerExpressions()) {
arguments += innerExpression.toFirExpression("Incorrect collection literal argument")
}
} }
} }
} }
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.fir.contracts.impl.FirEmptyContractDescription
import org.jetbrains.kotlin.fir.declarations.FirFile import org.jetbrains.kotlin.fir.declarations.FirFile
import org.jetbrains.kotlin.fir.declarations.FirTypeParameter import org.jetbrains.kotlin.fir.declarations.FirTypeParameter
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.FirEmptyArgumentList
import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression
import org.jetbrains.kotlin.fir.references.impl.FirEmptyControlFlowGraphReference import org.jetbrains.kotlin.fir.references.impl.FirEmptyControlFlowGraphReference
import org.jetbrains.kotlin.fir.references.impl.FirStubReference import org.jetbrains.kotlin.fir.references.impl.FirStubReference
@@ -164,7 +165,7 @@ abstract class AbstractRawFirBuilderTestCase : KtParsingTestCase(
private fun throwTwiceVisitingError(element: FirElement) { private fun throwTwiceVisitingError(element: FirElement) {
if (element is FirTypeRef || element is FirNoReceiverExpression || element is FirTypeParameter || if (element is FirTypeRef || element is FirNoReceiverExpression || element is FirTypeParameter ||
element is FirEmptyContractDescription || element is FirEmptyControlFlowGraphReference || element is FirEmptyContractDescription || element is FirEmptyControlFlowGraphReference ||
element is FirStubReference || element.isExtensionFunctionAnnotation element is FirStubReference || element.isExtensionFunctionAnnotation || element is FirEmptyArgumentList
) { ) {
return return
} }
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
fun FirFunctionCall.copy( fun FirFunctionCall.copy(
annotations: List<FirAnnotationCall> = this.annotations, annotations: List<FirAnnotationCall> = this.annotations,
arguments: List<FirExpression> = this.arguments, argumentList: FirArgumentList = this.argumentList,
calleeReference: FirNamedReference = this.calleeReference, calleeReference: FirNamedReference = this.calleeReference,
explicitReceiver: FirExpression? = this.explicitReceiver, explicitReceiver: FirExpression? = this.explicitReceiver,
dispatchReceiver: FirExpression = this.dispatchReceiver, dispatchReceiver: FirExpression = this.dispatchReceiver,
@@ -49,7 +49,7 @@ fun FirFunctionCall.copy(
this.source = source this.source = source
this.safe = safe this.safe = safe
this.annotations.addAll(annotations) this.annotations.addAll(annotations)
this.arguments.addAll(arguments) this.argumentList = argumentList
this.explicitReceiver = explicitReceiver this.explicitReceiver = explicitReceiver
this.dispatchReceiver = dispatchReceiver this.dispatchReceiver = dispatchReceiver
this.extensionReceiver = extensionReceiver this.extensionReceiver = extensionReceiver
@@ -151,7 +151,7 @@ fun FirCheckNotNullCall.copy(
): FirCheckNotNullCall = buildCheckNotNullCall { ): FirCheckNotNullCall = buildCheckNotNullCall {
source = this@copy.source source = this@copy.source
this.calleeReference = calleeReference this.calleeReference = calleeReference
arguments += this@copy.arguments argumentList = this@copy.argumentList
this.typeRef = resultType this.typeRef = resultType
this.annotations += annotations this.annotations += annotations
} }
@@ -62,8 +62,10 @@ class FirCallResolver(
qualifiedResolver.reset() qualifiedResolver.reset()
@Suppress("NAME_SHADOWING") @Suppress("NAME_SHADOWING")
var functionCall = functionCall.transformExplicitReceiver(transformer, ResolutionMode.ContextIndependent) var functionCall = functionCall.transformExplicitReceiver(transformer, ResolutionMode.ContextIndependent)
.also { dataFlowAnalyzer.enterQualifiedAccessExpression(functionCall) } .also {
.transformArguments(transformer, ResolutionMode.ContextDependent) dataFlowAnalyzer.enterQualifiedAccessExpression(functionCall)
functionCall.argumentList.transformArguments(transformer, ResolutionMode.ContextDependent)
}
var result = collectCandidates(functionCall) var result = collectCandidates(functionCall)
@@ -91,7 +93,7 @@ class FirCallResolver(
explicitReceiver = candidate.callInfo.explicitReceiver, explicitReceiver = candidate.callInfo.explicitReceiver,
dispatchReceiver = candidate.dispatchReceiverExpression(), dispatchReceiver = candidate.dispatchReceiverExpression(),
extensionReceiver = candidate.extensionReceiverExpression(), extensionReceiver = candidate.extensionReceiverExpression(),
arguments = candidate.callInfo.arguments, argumentList = candidate.callInfo.argumentList,
safe = candidate.callInfo.isSafeCall, safe = candidate.callInfo.isSafeCall,
) )
} else { } else {
@@ -110,14 +112,14 @@ class FirCallResolver(
private fun collectCandidates(functionCall: FirFunctionCall): ResolutionResult { private fun collectCandidates(functionCall: FirFunctionCall): ResolutionResult {
val explicitReceiver = functionCall.explicitReceiver val explicitReceiver = functionCall.explicitReceiver
val arguments = functionCall.arguments val argumentList = functionCall.argumentList
val typeArguments = functionCall.typeArguments val typeArguments = functionCall.typeArguments
val info = CallInfo( val info = CallInfo(
CallKind.Function, CallKind.Function,
functionCall.calleeReference.name, functionCall.calleeReference.name,
explicitReceiver, explicitReceiver,
arguments, argumentList,
functionCall.safe, functionCall.safe,
isPotentialQualifierPart = false, isPotentialQualifierPart = false,
typeArguments, typeArguments,
@@ -157,7 +159,7 @@ class FirCallResolver(
CallKind.VariableAccess, CallKind.VariableAccess,
callee.name, callee.name,
qualifiedAccess.explicitReceiver, qualifiedAccess.explicitReceiver,
emptyList(), FirEmptyArgumentList,
qualifiedAccess.safe, qualifiedAccess.safe,
qualifiedAccess.explicitReceiver is FirResolvedQualifier && qualifiedResolver.isPotentialQualifierPartPosition(), qualifiedAccess.explicitReceiver is FirResolvedQualifier && qualifiedResolver.isPotentialQualifierPartPosition(),
emptyList(), emptyList(),
@@ -307,7 +309,7 @@ class FirCallResolver(
CallKind.Function, CallKind.Function,
className, className,
explicitReceiver = null, explicitReceiver = null,
delegatedConstructorCall.arguments, delegatedConstructorCall.argumentList,
isSafeCall = false, isSafeCall = false,
isPotentialQualifierPart = false, isPotentialQualifierPart = false,
typeArguments = typeArguments, typeArguments = typeArguments,
@@ -358,7 +360,7 @@ class FirCallResolver(
CallKind.CallableReference, CallKind.CallableReference,
callableReferenceAccess.calleeReference.name, callableReferenceAccess.calleeReference.name,
callableReferenceAccess.explicitReceiver, callableReferenceAccess.explicitReceiver,
emptyList(), FirEmptyArgumentList,
false, false,
isPotentialQualifierPart = false, isPotentialQualifierPart = false,
emptyList(), emptyList(),
@@ -12,9 +12,7 @@ import org.jetbrains.kotlin.fir.declarations.FirRegularClass
import org.jetbrains.kotlin.fir.declarations.collectEnumEntries import org.jetbrains.kotlin.fir.declarations.collectEnumEntries
import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind
import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.*
import org.jetbrains.kotlin.fir.expressions.FirConstKind
import org.jetbrains.kotlin.fir.expressions.FirExpression
import org.jetbrains.kotlin.fir.expressions.builder.* import org.jetbrains.kotlin.fir.expressions.builder.*
import org.jetbrains.kotlin.fir.references.builder.buildErrorNamedReference import org.jetbrains.kotlin.fir.references.builder.buildErrorNamedReference
import org.jetbrains.kotlin.fir.references.builder.buildResolvedNamedReference import org.jetbrains.kotlin.fir.references.builder.buildResolvedNamedReference
@@ -103,7 +101,9 @@ abstract class AbstractAnnotationDeserializer(
type = it.constructType(emptyList(), isNullable = false) type = it.constructType(emptyList(), isNullable = false)
} }
} ?: buildErrorTypeRef { diagnostic =FirUnresolvedSymbolError(classId) } } ?: buildErrorTypeRef { diagnostic =FirUnresolvedSymbolError(classId) }
this.arguments += arguments argumentList = buildArgumentList {
this.arguments += arguments
}
} }
} }
@@ -127,11 +127,13 @@ abstract class AbstractAnnotationDeserializer(
val classId = nameResolver.getClassId(value.classId) val classId = nameResolver.getClassId(value.classId)
val lookupTag = ConeClassLikeLookupTagImpl(classId) val lookupTag = ConeClassLikeLookupTagImpl(classId)
val referencedType = lookupTag.constructType(emptyArray(), isNullable = false) val referencedType = lookupTag.constructType(emptyArray(), isNullable = false)
arguments += buildClassReferenceExpression { argumentList = buildUnaryArgumentList(
classTypeRef = buildResolvedTypeRef { buildClassReferenceExpression {
type = referencedType classTypeRef = buildResolvedTypeRef {
type = referencedType
}
} }
} )
} }
ENUM -> buildFunctionCall { ENUM -> buildFunctionCall {
val classId = nameResolver.getClassId(value.classId) val classId = nameResolver.getClassId(value.classId)
@@ -8,7 +8,10 @@ package org.jetbrains.kotlin.fir.resolve.calls
import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.FirSession
import org.jetbrains.kotlin.fir.declarations.FirFile import org.jetbrains.kotlin.fir.declarations.FirFile
import org.jetbrains.kotlin.fir.declarations.FirValueParameter import org.jetbrains.kotlin.fir.declarations.FirValueParameter
import org.jetbrains.kotlin.fir.expressions.FirArgumentList
import org.jetbrains.kotlin.fir.expressions.FirEmptyArgumentList
import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirExpression
import org.jetbrains.kotlin.fir.expressions.builder.buildArgumentList
import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression
import org.jetbrains.kotlin.fir.resolve.BodyResolveComponents import org.jetbrains.kotlin.fir.resolve.BodyResolveComponents
import org.jetbrains.kotlin.fir.resolve.DoubleColonLHS import org.jetbrains.kotlin.fir.resolve.DoubleColonLHS
@@ -31,7 +34,7 @@ data class CallInfo(
val name: Name, val name: Name,
val explicitReceiver: FirExpression?, val explicitReceiver: FirExpression?,
val arguments: List<FirExpression>, val argumentList: FirArgumentList,
val isSafeCall: Boolean, val isSafeCall: Boolean,
val isPotentialQualifierPart: Boolean, val isPotentialQualifierPart: Boolean,
@@ -46,23 +49,30 @@ data class CallInfo(
val lhs: DoubleColonLHS? = null, val lhs: DoubleColonLHS? = null,
val stubReceiver: FirExpression? = null val stubReceiver: FirExpression? = null
) { ) {
val arguments: List<FirExpression> get() = argumentList.arguments
val argumentCount get() = arguments.size val argumentCount get() = arguments.size
fun noStubReceiver(): CallInfo = fun noStubReceiver(): CallInfo =
if (stubReceiver == null) this else CallInfo( if (stubReceiver == null) this else CallInfo(
callKind, name, explicitReceiver, arguments, callKind, name, explicitReceiver, argumentList,
isSafeCall, isPotentialQualifierPart, typeArguments, session, isSafeCall, isPotentialQualifierPart, typeArguments, session,
containingFile, implicitReceiverStack, expectedType, outerCSBuilder, lhs, null containingFile, implicitReceiverStack, expectedType, outerCSBuilder, lhs, null
) )
fun replaceWithVariableAccess(): CallInfo = fun replaceWithVariableAccess(): CallInfo =
copy(callKind = CallKind.VariableAccess, arguments = emptyList()) copy(callKind = CallKind.VariableAccess, argumentList = FirEmptyArgumentList)
fun replaceExplicitReceiver(explicitReceiver: FirExpression?): CallInfo = fun replaceExplicitReceiver(explicitReceiver: FirExpression?): CallInfo =
copy(explicitReceiver = explicitReceiver) copy(explicitReceiver = explicitReceiver)
fun withReceiverAsArgument(receiverExpression: FirExpression): CallInfo = fun withReceiverAsArgument(receiverExpression: FirExpression): CallInfo =
copy(arguments = listOf(receiverExpression) + arguments) copy(
argumentList = buildArgumentList {
arguments += receiverExpression
arguments += argumentList.arguments
}
)
} }
enum class CandidateApplicability { enum class CandidateApplicability {
@@ -69,8 +69,7 @@ private object ConeConditionalEffectToFirVisitor : ConeContractDescriptionVisito
} else { } else {
FirOperation.EQ FirOperation.EQ
} }
arguments += argument argumentList = buildBinaryArgumentList(argument, createConstNull())
arguments += createConstNull()
} }
} }
@@ -53,10 +53,11 @@ class FirCallCompleter(
call.resultType = typeRef call.resultType = typeRef
} }
val errorCall = if (call is FirFunctionCall) { val errorCall = if (call is FirFunctionCall) {
call.transformArguments( call.argumentList.transformArguments(
transformer, transformer,
ResolutionMode.WithExpectedType(typeRef.resolvedTypeFromPrototype(session.builtinTypes.nullableAnyType.type)) ResolutionMode.WithExpectedType(typeRef.resolvedTypeFromPrototype(session.builtinTypes.nullableAnyType.type))
) as T )
call
} else { } else {
call call
} }
@@ -9,8 +9,8 @@ import org.jetbrains.kotlin.fir.*
import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic
import org.jetbrains.kotlin.fir.expressions.* import org.jetbrains.kotlin.fir.expressions.*
import org.jetbrains.kotlin.fir.expressions.builder.buildArgumentList
import org.jetbrains.kotlin.fir.expressions.builder.buildVarargArgumentsExpression import org.jetbrains.kotlin.fir.expressions.builder.buildVarargArgumentsExpression
import org.jetbrains.kotlin.fir.expressions.impl.FirFunctionCallImpl
import org.jetbrains.kotlin.fir.references.builder.buildResolvedCallableReference import org.jetbrains.kotlin.fir.references.builder.buildResolvedCallableReference
import org.jetbrains.kotlin.fir.references.builder.buildResolvedNamedReference import org.jetbrains.kotlin.fir.references.builder.buildResolvedNamedReference
import org.jetbrains.kotlin.fir.resolve.calls.Candidate import org.jetbrains.kotlin.fir.resolve.calls.Candidate
@@ -175,13 +175,15 @@ class FirCallCompletionResultsWriterTransformer(
val expectedType = data?.getExpectedType(functionCall) val expectedType = data?.getExpectedType(functionCall)
resultType = resultType =
typeRef.resolvedTypeFromPrototype(typeRef.coneTypeUnsafe<ConeIntegerLiteralType>().getApproximatedType(expectedType)) typeRef.resolvedTypeFromPrototype(typeRef.coneTypeUnsafe<ConeIntegerLiteralType>().getApproximatedType(expectedType))
result.transformArguments(this, expectedType?.toExpectedType()).transformSingle(integerApproximator, expectedType) result.argumentList.transformArguments(this, expectedType?.toExpectedType())
result.transformSingle(integerApproximator, expectedType)
} }
else -> { else -> {
resultType = typeRef.substituteTypeRef(subCandidate) resultType = typeRef.substituteTypeRef(subCandidate)
val vararg = subCandidate.argumentMapping?.values?.firstOrNull { it.isVararg } val vararg = subCandidate.argumentMapping?.values?.firstOrNull { it.isVararg }
result.transformArguments(this, subCandidate.createArgumentsMapping()).apply call@{ result.argumentList.transformArguments(this, subCandidate.createArgumentsMapping())
if (vararg != null && this is FirFunctionCallImpl) { with(result.argumentList) call@{
if (vararg != null) {
// Create a FirVarargArgumentExpression for the vararg arguments // Create a FirVarargArgumentExpression for the vararg arguments
val resolvedArrayType = vararg.returnTypeRef.substitute(subCandidate) val resolvedArrayType = vararg.returnTypeRef.substitute(subCandidate)
val resolvedElementType = resolvedArrayType.arrayElementType(session) val resolvedElementType = resolvedArrayType.arrayElementType(session)
@@ -200,12 +202,18 @@ class FirCallCompletionResultsWriterTransformer(
} }
} }
} }
for (arg in varargArgument.arguments) { result.replaceArgumentList(
arguments.remove(arg) buildArgumentList {
} arguments += result.arguments
arguments.add(firstIndex, varargArgument) for (arg in varargArgument.arguments) {
arguments.remove(arg)
}
arguments.add(firstIndex, varargArgument)
}
)
} }
}.transformExplicitReceiver(integerApproximator, null) }
result.transformExplicitReceiver(integerApproximator, null)
} }
} }
@@ -215,7 +223,7 @@ class FirCallCompletionResultsWriterTransformer(
if (mode == Mode.DelegatedPropertyCompletion) { if (mode == Mode.DelegatedPropertyCompletion) {
calleeReference.candidateSymbol.fir.transformSingle(declarationWriter, null) calleeReference.candidateSymbol.fir.transformSingle(declarationWriter, null)
val typeUpdater = TypeUpdaterForDelegateArguments() val typeUpdater = TypeUpdaterForDelegateArguments()
result.transformArguments(typeUpdater, null) result.argumentList.transformArguments(typeUpdater, null)
result.transformExplicitReceiver(typeUpdater, null) result.transformExplicitReceiver(typeUpdater, null)
} }
@@ -260,8 +268,8 @@ class FirCallCompletionResultsWriterTransformer(
val calleeReference = val calleeReference =
delegatedConstructorCall.calleeReference as? FirNamedReferenceWithCandidate ?: return delegatedConstructorCall.compose() delegatedConstructorCall.calleeReference as? FirNamedReferenceWithCandidate ?: return delegatedConstructorCall.compose()
val result = delegatedConstructorCall.transformArguments(this, calleeReference.candidate.createArgumentsMapping()) delegatedConstructorCall.argumentList.transformArguments(this, calleeReference.candidate.createArgumentsMapping())
return result.transformCalleeReference( return delegatedConstructorCall.transformCalleeReference(
StoreCalleeReference, StoreCalleeReference,
buildResolvedNamedReference { buildResolvedNamedReference {
source = calleeReference.source source = calleeReference.source
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.fir.declarations.builder.buildTypeParameter
import org.jetbrains.kotlin.fir.declarations.builder.buildValueParameter import org.jetbrains.kotlin.fir.declarations.builder.buildValueParameter
import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl
import org.jetbrains.kotlin.fir.expressions.* import org.jetbrains.kotlin.fir.expressions.*
import org.jetbrains.kotlin.fir.expressions.builder.buildArgumentList
import org.jetbrains.kotlin.fir.expressions.builder.buildFunctionCall import org.jetbrains.kotlin.fir.expressions.builder.buildFunctionCall
import org.jetbrains.kotlin.fir.inferenceContext import org.jetbrains.kotlin.fir.inferenceContext
import org.jetbrains.kotlin.fir.references.FirReference import org.jetbrains.kotlin.fir.references.FirReference
@@ -53,10 +54,12 @@ class FirSyntheticCallGenerator(
// assert(stubReference is FirStubReference) // assert(stubReference is FirStubReference)
if (stubReference !is FirStubReference) return null if (stubReference !is FirStubReference) return null
val arguments = whenExpression.branches.map { it.result } val argumentList = buildArgumentList {
arguments += whenExpression.branches.map { it.result }
}
val reference = generateCalleeReferenceWithCandidate( val reference = generateCalleeReferenceWithCandidate(
whenSelectFunction, whenSelectFunction,
arguments, argumentList,
SyntheticCallableId.WHEN.callableName SyntheticCallableId.WHEN.callableName
) ?: return null // TODO ) ?: return null // TODO
@@ -67,18 +70,18 @@ class FirSyntheticCallGenerator(
val stubReference = tryExpression.calleeReference val stubReference = tryExpression.calleeReference
assert(stubReference is FirStubReference) assert(stubReference is FirStubReference)
val arguments = mutableListOf<FirExpression>() val argumentList = buildArgumentList {
with(tryExpression) {
with(tryExpression) { arguments += tryBlock
arguments += tryBlock catches.forEach {
catches.forEach { arguments += it.block
arguments += it.block }
} }
} }
val reference = generateCalleeReferenceWithCandidate( val reference = generateCalleeReferenceWithCandidate(
trySelectFunction, trySelectFunction,
arguments, argumentList,
SyntheticCallableId.TRY.callableName SyntheticCallableId.TRY.callableName
) ?: return null // TODO ) ?: return null // TODO
@@ -91,7 +94,7 @@ class FirSyntheticCallGenerator(
val reference = generateCalleeReferenceWithCandidate( val reference = generateCalleeReferenceWithCandidate(
checkNotNullFunction, checkNotNullFunction,
checkNotNullCall.arguments, checkNotNullCall.argumentList,
SyntheticCallableId.CHECK_NOT_NULL.callableName SyntheticCallableId.CHECK_NOT_NULL.callableName
) ?: return null // TODO ) ?: return null // TODO
@@ -102,11 +105,11 @@ class FirSyntheticCallGenerator(
callableReferenceAccess: FirCallableReferenceAccess, callableReferenceAccess: FirCallableReferenceAccess,
expectedTypeRef: FirTypeRef? expectedTypeRef: FirTypeRef?
): FirCallableReferenceAccess? { ): FirCallableReferenceAccess? {
val arguments = listOf(callableReferenceAccess) val argumentList = buildUnaryArgumentList(callableReferenceAccess)
val reference = val reference =
generateCalleeReferenceWithCandidate( generateCalleeReferenceWithCandidate(
idFunction, arguments, SyntheticCallableId.ID.callableName, CallKind.SyntheticIdForCallableReferencesResolution idFunction, argumentList, SyntheticCallableId.ID.callableName, CallKind.SyntheticIdForCallableReferencesResolution
) ?: return callableReferenceAccess.transformCalleeReference( ) ?: return callableReferenceAccess.transformCalleeReference(
StoreCalleeReference, StoreCalleeReference,
buildErrorNamedReference { buildErrorNamedReference {
@@ -116,20 +119,20 @@ class FirSyntheticCallGenerator(
) )
val fakeCallElement = buildFunctionCall { val fakeCallElement = buildFunctionCall {
calleeReference = reference calleeReference = reference
this.arguments += callableReferenceAccess this.argumentList = argumentList
} }
val argument = callCompleter.completeCall(fakeCallElement, expectedTypeRef).arguments[0] val argument = callCompleter.completeCall(fakeCallElement, expectedTypeRef).argument
return ((argument as? FirVarargArgumentsExpression)?.arguments?.get(0) ?: argument) as FirCallableReferenceAccess? return ((argument as? FirVarargArgumentsExpression)?.arguments?.get(0) ?: argument) as FirCallableReferenceAccess?
} }
private fun generateCalleeReferenceWithCandidate( private fun generateCalleeReferenceWithCandidate(
function: FirSimpleFunction, function: FirSimpleFunction,
arguments: List<FirExpression>, argumentList: FirArgumentList,
name: Name, name: Name,
callKind: CallKind = CallKind.SyntheticSelect callKind: CallKind = CallKind.SyntheticSelect
): FirNamedReferenceWithCandidate? { ): FirNamedReferenceWithCandidate? {
val callInfo = generateCallInfo(name, arguments, callKind) val callInfo = generateCallInfo(name, argumentList, callKind)
val candidate = generateCandidate(callInfo, function) val candidate = generateCandidate(callInfo, function)
val applicability = resolutionStageRunner.processCandidate(candidate) val applicability = resolutionStageRunner.processCandidate(candidate)
if (applicability <= CandidateApplicability.INAPPLICABLE) { if (applicability <= CandidateApplicability.INAPPLICABLE) {
@@ -145,11 +148,11 @@ class FirSyntheticCallGenerator(
explicitReceiverKind = ExplicitReceiverKind.NO_EXPLICIT_RECEIVER explicitReceiverKind = ExplicitReceiverKind.NO_EXPLICIT_RECEIVER
) )
private fun generateCallInfo(name: Name, arguments: List<FirExpression>, callKind: CallKind) = CallInfo( private fun generateCallInfo(name: Name, argumentList: FirArgumentList, callKind: CallKind) = CallInfo(
callKind = callKind, callKind = callKind,
name = name, name = name,
explicitReceiver = null, explicitReceiver = null,
arguments = arguments, argumentList = argumentList,
isSafeCall = false, isSafeCall = false,
isPotentialQualifierPart = false, isPotentialQualifierPart = false,
typeArguments = emptyList(), typeArguments = emptyList(),
@@ -102,7 +102,8 @@ class IntegerLiteralTypeApproximationTransformer(
else -> throw IllegalStateException() else -> throw IllegalStateException()
} }
return operatorCall.transformArguments(this, expectedType).compose() operatorCall.argumentList.transformArguments(this, expectedType)
return operatorCall.compose()
} }
// TODO: call outside // TODO: call outside
@@ -110,7 +111,8 @@ class IntegerLiteralTypeApproximationTransformer(
typeOperatorCall: FirTypeOperatorCall, typeOperatorCall: FirTypeOperatorCall,
data: ConeKotlinType? data: ConeKotlinType?
): CompositeTransformResult<FirStatement> { ): CompositeTransformResult<FirStatement> {
return typeOperatorCall.transformArguments(this, null).compose() typeOperatorCall.argumentList.transformArguments(this, null)
return typeOperatorCall.compose()
} }
} }
@@ -156,7 +158,7 @@ class IntegerOperatorsTypeUpdater(val approximator: IntegerLiteralTypeApproximat
else -> throw IllegalStateException() else -> throw IllegalStateException()
} }
else -> { else -> {
val argumentType = functionCall.arguments.first().typeRef.coneTypeUnsafe<ConeKotlinType>() val argumentType = functionCall.argument.typeRef.coneTypeUnsafe<ConeKotlinType>()
// TODO: handle overflow // TODO: handle overflow
when (argumentType) { when (argumentType) {
is ConeIntegerLiteralType -> { is ConeIntegerLiteralType -> {
@@ -208,7 +210,7 @@ private fun FirFunctionCall.toOperatorCall(): FirIntegerOperatorCall {
explicitReceiver, explicitReceiver,
dispatchReceiver, dispatchReceiver,
extensionReceiver, extensionReceiver,
arguments.toMutableList(), argumentList,
calleeReference, calleeReference,
) )
} }
@@ -88,6 +88,7 @@ object InvocationKindTransformer : FirTransformer<Nothing?>() {
if (invocationKindMapping.isEmpty()) { if (invocationKindMapping.isEmpty()) {
return functionCall.compose() return functionCall.compose()
} }
return functionCall.transformArguments(ArgumentsTransformer, invocationKindMapping to null).compose() functionCall.argumentList.transformArguments(ArgumentsTransformer, invocationKindMapping to null)
return functionCall.compose()
} }
} }
@@ -14,48 +14,6 @@ import org.jetbrains.kotlin.fir.scopes.impl.withReplacedConeType
import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.*
import org.jetbrains.kotlin.fir.visitors.* import org.jetbrains.kotlin.fir.visitors.*
internal object MapArguments : FirDefaultTransformer<Map<FirElement, FirElement>>() {
override fun <E : FirElement> transformElement(element: E, data: Map<FirElement, FirElement>): CompositeTransformResult<E> {
return ((data[element] ?: element) as E).compose()
}
override fun transformFunctionCall(
functionCall: FirFunctionCall,
data: Map<FirElement, FirElement>
): CompositeTransformResult<FirStatement> {
return (functionCall.transformArguments(this, data) as FirStatement).compose()
}
override fun transformWrappedArgumentExpression(
wrappedArgumentExpression: FirWrappedArgumentExpression,
data: Map<FirElement, FirElement>
): CompositeTransformResult<FirStatement> {
return (wrappedArgumentExpression.transformChildren(this, data) as FirStatement).compose()
}
override fun transformBlock(block: FirBlock, data: Map<FirElement, FirElement>): CompositeTransformResult<FirStatement> {
if (block.statements.isEmpty()) return block.compose()
val transformedStatement = block.statements.last().transformSingle(this@MapArguments, data)
when (block) {
is FirSingleExpressionBlock -> block.statement = transformedStatement
// TODO: dirty cast
else -> (block.statements as MutableList<FirStatement>)[block.statements.size - 1] = transformedStatement
}
return block.compose()
}
override fun transformCatch(catch: FirCatch, data: Map<FirElement, FirElement>): CompositeTransformResult<FirCatch> {
return catch.transformBlock(this, data).compose()
}
override fun transformWhenBranch(
whenBranch: FirWhenBranch,
data: Map<FirElement, FirElement>,
): CompositeTransformResult<FirWhenBranch> {
return whenBranch.transformResult(this, data).compose()
}
}
internal object StoreType : FirDefaultTransformer<FirTypeRef>() { internal object StoreType : FirDefaultTransformer<FirTypeRef>() {
override fun <E : FirElement> transformElement(element: E, data: FirTypeRef): CompositeTransformResult<E> { override fun <E : FirElement> transformElement(element: E, data: FirTypeRef): CompositeTransformResult<E> {
return element.compose() return element.compose()
@@ -168,7 +168,7 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) :
} }
val completionResult = callCompleter.completeCall(resultExpression, expectedTypeRef) val completionResult = callCompleter.completeCall(resultExpression, expectedTypeRef)
if (completionResult.typeRef is FirErrorTypeRef) { if (completionResult.typeRef is FirErrorTypeRef) {
completionResult.transformArguments(transformer, ResolutionMode.LambdaResolution(null)) completionResult.argumentList.transformArguments(transformer, ResolutionMode.LambdaResolution(null))
} }
completionResult completionResult
} catch (e: ProcessCanceledException) { } catch (e: ProcessCanceledException) {
@@ -238,13 +238,13 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) :
operatorCall.annotations.forEach { it.accept(this, data) } operatorCall.annotations.forEach { it.accept(this, data) }
@Suppress("NAME_SHADOWING") @Suppress("NAME_SHADOWING")
val operatorCall = operatorCall.transformArguments(this, ResolutionMode.ContextIndependent) operatorCall.argumentList.transformArguments(this, ResolutionMode.ContextIndependent)
val (leftArgument, rightArgument) = operatorCall.arguments val (leftArgument, rightArgument) = operatorCall.arguments
fun createFunctionCall(name: Name) = buildFunctionCall { fun createFunctionCall(name: Name) = buildFunctionCall {
source = operatorCall.source source = operatorCall.source
explicitReceiver = leftArgument explicitReceiver = leftArgument
arguments += rightArgument argumentList = buildUnaryArgumentList(rightArgument)
calleeReference = buildSimpleNamedReference { calleeReference = buildSimpleNamedReference {
source = operatorCall.source source = operatorCall.source
this.name = name this.name = name
@@ -279,7 +279,7 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) :
lhsReference!! lhsReference!!
else else
buildErrorNamedReference { buildErrorNamedReference {
source = operatorCall.arguments.first().source source = operatorCall.argument.source
diagnostic = FirVariableExpectedError() diagnostic = FirVariableExpectedError()
} }
} }
@@ -314,8 +314,8 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) :
typeOperatorCall: FirTypeOperatorCall, typeOperatorCall: FirTypeOperatorCall,
data: ResolutionMode, data: ResolutionMode,
): CompositeTransformResult<FirStatement> { ): CompositeTransformResult<FirStatement> {
val resolved = (transformExpression(typeOperatorCall, data).single as FirTypeOperatorCall) val resolved = transformExpression(typeOperatorCall, data).single as FirTypeOperatorCall
.transformArguments(integerLiteralTypeApproximator, null) resolved.argumentList.transformArguments(integerLiteralTypeApproximator, null)
val conversionTypeRef = resolved.conversionTypeRef.withTypeArgumentsForBareType(resolved.argument) val conversionTypeRef = resolved.conversionTypeRef.withTypeArgumentsForBareType(resolved.argument)
resolved.transformChildren(object : FirDefaultTransformer<Nothing?>() { resolved.transformChildren(object : FirDefaultTransformer<Nothing?>() {
override fun <E : FirElement> transformElement(element: E, data: Nothing?): CompositeTransformResult<E> { override fun <E : FirElement> transformElement(element: E, data: Nothing?): CompositeTransformResult<E> {
@@ -363,7 +363,7 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) :
return checkNotNullCall.compose() return checkNotNullCall.compose()
} }
checkNotNullCall.transformArguments(transformer, ResolutionMode.ContextDependent) checkNotNullCall.argumentList.transformArguments(transformer, ResolutionMode.ContextDependent)
val result = components.syntheticCallGenerator.generateCalleeForCheckNotNullCall(checkNotNullCall)?.let { val result = components.syntheticCallGenerator.generateCalleeForCheckNotNullCall(checkNotNullCall)?.let {
callCompleter.completeCall(it, data.expectedType) callCompleter.completeCall(it, data.expectedType)
@@ -535,11 +535,11 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) :
override fun transformAnnotationCall(annotationCall: FirAnnotationCall, data: ResolutionMode): CompositeTransformResult<FirStatement> { override fun transformAnnotationCall(annotationCall: FirAnnotationCall, data: ResolutionMode): CompositeTransformResult<FirStatement> {
dataFlowAnalyzer.enterAnnotationCall(annotationCall) dataFlowAnalyzer.enterAnnotationCall(annotationCall)
return (annotationCall.transformChildren(transformer, data) as FirAnnotationCall) return (annotationCall.transformChildren(transformer, data) as FirAnnotationCall).also {
// TODO: it's temporary incorrect solution until we design resolve and completion for annotation calls // TODO: it's temporary incorrect solution until we design resolve and completion for annotation calls
.transformArguments(integerLiteralTypeApproximator, null).also { it.argumentList.transformArguments(integerLiteralTypeApproximator, null)
dataFlowAnalyzer.exitAnnotationCall(it) dataFlowAnalyzer.exitAnnotationCall(it)
}.compose() }.compose()
} }
private fun ConeTypeProjection.toFirTypeProjection(): FirTypeProjection = when (this) { private fun ConeTypeProjection.toFirTypeProjection(): FirTypeProjection = when (this) {
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder
import org.jetbrains.kotlin.fir.builder.FirBuilderDsl import org.jetbrains.kotlin.fir.builder.FirBuilderDsl
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.FirArgumentList
import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirExpression
import org.jetbrains.kotlin.fir.expressions.FirFunctionCall import org.jetbrains.kotlin.fir.expressions.FirFunctionCall
import org.jetbrains.kotlin.fir.expressions.builder.FirCallBuilder import org.jetbrains.kotlin.fir.expressions.builder.FirCallBuilder
@@ -32,7 +33,7 @@ class FirIntegerOperatorCall @FirImplementationDetail constructor(
explicitReceiver: FirExpression?, explicitReceiver: FirExpression?,
dispatchReceiver: FirExpression, dispatchReceiver: FirExpression,
extensionReceiver: FirExpression, extensionReceiver: FirExpression,
arguments: MutableList<FirExpression>, argumentList: FirArgumentList,
calleeReference: FirNamedReference, calleeReference: FirNamedReference,
) : FirFunctionCallImpl( ) : FirFunctionCallImpl(
source, source,
@@ -43,7 +44,7 @@ class FirIntegerOperatorCall @FirImplementationDetail constructor(
explicitReceiver, explicitReceiver,
dispatchReceiver, dispatchReceiver,
extensionReceiver, extensionReceiver,
arguments, argumentList,
calleeReference, calleeReference,
) )
@@ -57,8 +58,8 @@ class FirIntegerOperatorCallBuilder : FirQualifiedAccessBuilder, FirCallBuilder,
override var explicitReceiver: FirExpression? = null override var explicitReceiver: FirExpression? = null
override var dispatchReceiver: FirExpression = FirNoReceiverExpression override var dispatchReceiver: FirExpression = FirNoReceiverExpression
override var extensionReceiver: FirExpression = FirNoReceiverExpression override var extensionReceiver: FirExpression = FirNoReceiverExpression
override val arguments: MutableList<FirExpression> = mutableListOf()
lateinit var calleeReference: FirNamedReference lateinit var calleeReference: FirNamedReference
override lateinit var argumentList: FirArgumentList
@OptIn(FirImplementationDetail::class) @OptIn(FirImplementationDetail::class)
override fun build(): FirIntegerOperatorCall { override fun build(): FirIntegerOperatorCall {
@@ -71,7 +72,7 @@ class FirIntegerOperatorCallBuilder : FirQualifiedAccessBuilder, FirCallBuilder,
explicitReceiver, explicitReceiver,
dispatchReceiver, dispatchReceiver,
extensionReceiver, extensionReceiver,
arguments, argumentList,
calleeReference, calleeReference,
) )
} }
@@ -19,11 +19,9 @@ abstract class FirAnnotationCall : FirExpression(), FirCall {
abstract override val source: FirSourceElement? abstract override val source: FirSourceElement?
abstract override val typeRef: FirTypeRef abstract override val typeRef: FirTypeRef
abstract override val annotations: List<FirAnnotationCall> abstract override val annotations: List<FirAnnotationCall>
abstract override val arguments: List<FirExpression> abstract override val argumentList: FirArgumentList
abstract val useSiteTarget: AnnotationUseSiteTarget? abstract val useSiteTarget: AnnotationUseSiteTarget?
abstract val annotationTypeRef: FirTypeRef abstract val annotationTypeRef: FirTypeRef
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitAnnotationCall(this, data) override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitAnnotationCall(this, data)
abstract override fun <D> transformArguments(transformer: FirTransformer<D>, data: D): FirAnnotationCall
} }
@@ -0,0 +1,25 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.fir.expressions
import org.jetbrains.kotlin.fir.FirElement
import org.jetbrains.kotlin.fir.FirPureAbstractElement
import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.visitors.*
/*
* This file was generated automatically
* DO NOT MODIFY IT MANUALLY
*/
abstract class FirArgumentList : FirPureAbstractElement(), FirElement {
abstract override val source: FirSourceElement?
abstract val arguments: List<FirExpression>
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitArgumentList(this, data)
abstract fun <D> transformArguments(transformer: FirTransformer<D>, data: D): FirArgumentList
}
@@ -18,9 +18,7 @@ abstract class FirArrayOfCall : FirExpression(), FirCall {
abstract override val source: FirSourceElement? abstract override val source: FirSourceElement?
abstract override val typeRef: FirTypeRef abstract override val typeRef: FirTypeRef
abstract override val annotations: List<FirAnnotationCall> abstract override val annotations: List<FirAnnotationCall>
abstract override val arguments: List<FirExpression> abstract override val argumentList: FirArgumentList
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitArrayOfCall(this, data) override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitArrayOfCall(this, data)
abstract override fun <D> transformArguments(transformer: FirTransformer<D>, data: D): FirArrayOfCall
} }
@@ -25,7 +25,7 @@ abstract class FirArraySetCall : FirPureAbstractElement(), FirQualifiedAccess, F
abstract override val dispatchReceiver: FirExpression abstract override val dispatchReceiver: FirExpression
abstract override val extensionReceiver: FirExpression abstract override val extensionReceiver: FirExpression
abstract override val calleeReference: FirReference abstract override val calleeReference: FirReference
abstract override val arguments: List<FirExpression> abstract override val argumentList: FirArgumentList
abstract val rValue: FirExpression abstract val rValue: FirExpression
abstract val operation: FirOperation abstract val operation: FirOperation
abstract val lValue: FirReference abstract val lValue: FirReference
@@ -43,8 +43,6 @@ abstract class FirArraySetCall : FirPureAbstractElement(), FirQualifiedAccess, F
abstract override fun <D> transformCalleeReference(transformer: FirTransformer<D>, data: D): FirArraySetCall abstract override fun <D> transformCalleeReference(transformer: FirTransformer<D>, data: D): FirArraySetCall
abstract override fun <D> transformArguments(transformer: FirTransformer<D>, data: D): FirArraySetCall
abstract fun <D> transformRValue(transformer: FirTransformer<D>, data: D): FirArraySetCall abstract fun <D> transformRValue(transformer: FirTransformer<D>, data: D): FirArraySetCall
abstract fun <D> transformIndexes(transformer: FirTransformer<D>, data: D): FirArraySetCall abstract fun <D> transformIndexes(transformer: FirTransformer<D>, data: D): FirArraySetCall
@@ -16,9 +16,9 @@ import org.jetbrains.kotlin.fir.visitors.*
interface FirCall : FirStatement { interface FirCall : FirStatement {
override val source: FirSourceElement? override val source: FirSourceElement?
override val annotations: List<FirAnnotationCall> override val annotations: List<FirAnnotationCall>
val arguments: List<FirExpression> val argumentList: FirArgumentList
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitCall(this, data) override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitCall(this, data)
fun <D> transformArguments(transformer: FirTransformer<D>, data: D): FirCall fun replaceArgumentList(newArgumentList: FirArgumentList)
} }
@@ -19,12 +19,10 @@ abstract class FirCheckNotNullCall : FirExpression(), FirCall, FirResolvable {
abstract override val source: FirSourceElement? abstract override val source: FirSourceElement?
abstract override val typeRef: FirTypeRef abstract override val typeRef: FirTypeRef
abstract override val annotations: List<FirAnnotationCall> abstract override val annotations: List<FirAnnotationCall>
abstract override val arguments: List<FirExpression> abstract override val argumentList: FirArgumentList
abstract override val calleeReference: FirReference abstract override val calleeReference: FirReference
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitCheckNotNullCall(this, data) override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitCheckNotNullCall(this, data)
abstract override fun <D> transformArguments(transformer: FirTransformer<D>, data: D): FirCheckNotNullCall
abstract override fun <D> transformCalleeReference(transformer: FirTransformer<D>, data: D): FirCheckNotNullCall abstract override fun <D> transformCalleeReference(transformer: FirTransformer<D>, data: D): FirCheckNotNullCall
} }
@@ -24,7 +24,7 @@ abstract class FirComponentCall : FirFunctionCall() {
abstract override val typeArguments: List<FirTypeProjection> abstract override val typeArguments: List<FirTypeProjection>
abstract override val dispatchReceiver: FirExpression abstract override val dispatchReceiver: FirExpression
abstract override val extensionReceiver: FirExpression abstract override val extensionReceiver: FirExpression
abstract override val arguments: List<FirExpression> abstract override val argumentList: FirArgumentList
abstract override val calleeReference: FirNamedReference abstract override val calleeReference: FirNamedReference
abstract override val explicitReceiver: FirExpression abstract override val explicitReceiver: FirExpression
abstract val componentIndex: Int abstract val componentIndex: Int
@@ -37,8 +37,6 @@ abstract class FirComponentCall : FirFunctionCall() {
abstract override fun <D> transformExtensionReceiver(transformer: FirTransformer<D>, data: D): FirComponentCall abstract override fun <D> transformExtensionReceiver(transformer: FirTransformer<D>, data: D): FirComponentCall
abstract override fun <D> transformArguments(transformer: FirTransformer<D>, data: D): FirComponentCall
abstract override fun <D> transformCalleeReference(transformer: FirTransformer<D>, data: D): FirComponentCall abstract override fun <D> transformCalleeReference(transformer: FirTransformer<D>, data: D): FirComponentCall
abstract override fun <D> transformExplicitReceiver(transformer: FirTransformer<D>, data: D): FirComponentCall abstract override fun <D> transformExplicitReceiver(transformer: FirTransformer<D>, data: D): FirComponentCall
@@ -20,7 +20,7 @@ abstract class FirDelegatedConstructorCall : FirPureAbstractElement(), FirResolv
abstract override val source: FirSourceElement? abstract override val source: FirSourceElement?
abstract override val calleeReference: FirReference abstract override val calleeReference: FirReference
abstract override val annotations: List<FirAnnotationCall> abstract override val annotations: List<FirAnnotationCall>
abstract override val arguments: List<FirExpression> abstract override val argumentList: FirArgumentList
abstract val constructedTypeRef: FirTypeRef abstract val constructedTypeRef: FirTypeRef
abstract val isThis: Boolean abstract val isThis: Boolean
abstract val isSuper: Boolean abstract val isSuper: Boolean
@@ -28,6 +28,4 @@ abstract class FirDelegatedConstructorCall : FirPureAbstractElement(), FirResolv
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitDelegatedConstructorCall(this, data) override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitDelegatedConstructorCall(this, data)
abstract override fun <D> transformCalleeReference(transformer: FirTransformer<D>, data: D): FirDelegatedConstructorCall abstract override fun <D> transformCalleeReference(transformer: FirTransformer<D>, data: D): FirDelegatedConstructorCall
abstract override fun <D> transformArguments(transformer: FirTransformer<D>, data: D): FirDelegatedConstructorCall
} }
@@ -25,7 +25,7 @@ abstract class FirFunctionCall : FirQualifiedAccessExpression(), FirCall {
abstract override val explicitReceiver: FirExpression? abstract override val explicitReceiver: FirExpression?
abstract override val dispatchReceiver: FirExpression abstract override val dispatchReceiver: FirExpression
abstract override val extensionReceiver: FirExpression abstract override val extensionReceiver: FirExpression
abstract override val arguments: List<FirExpression> abstract override val argumentList: FirArgumentList
abstract override val calleeReference: FirNamedReference abstract override val calleeReference: FirNamedReference
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitFunctionCall(this, data) override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitFunctionCall(this, data)
@@ -38,7 +38,5 @@ abstract class FirFunctionCall : FirQualifiedAccessExpression(), FirCall {
abstract override fun <D> transformExtensionReceiver(transformer: FirTransformer<D>, data: D): FirFunctionCall abstract override fun <D> transformExtensionReceiver(transformer: FirTransformer<D>, data: D): FirFunctionCall
abstract override fun <D> transformArguments(transformer: FirTransformer<D>, data: D): FirFunctionCall
abstract override fun <D> transformCalleeReference(transformer: FirTransformer<D>, data: D): FirFunctionCall abstract override fun <D> transformCalleeReference(transformer: FirTransformer<D>, data: D): FirFunctionCall
} }
@@ -18,10 +18,8 @@ abstract class FirGetClassCall : FirExpression(), FirCall {
abstract override val source: FirSourceElement? abstract override val source: FirSourceElement?
abstract override val typeRef: FirTypeRef abstract override val typeRef: FirTypeRef
abstract override val annotations: List<FirAnnotationCall> abstract override val annotations: List<FirAnnotationCall>
abstract override val arguments: List<FirExpression> abstract override val argumentList: FirArgumentList
abstract val argument: FirExpression abstract val argument: FirExpression
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitGetClassCall(this, data) override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitGetClassCall(this, data)
abstract override fun <D> transformArguments(transformer: FirTransformer<D>, data: D): FirGetClassCall
} }
@@ -18,10 +18,8 @@ abstract class FirOperatorCall : FirExpression(), FirCall {
abstract override val source: FirSourceElement? abstract override val source: FirSourceElement?
abstract override val typeRef: FirTypeRef abstract override val typeRef: FirTypeRef
abstract override val annotations: List<FirAnnotationCall> abstract override val annotations: List<FirAnnotationCall>
abstract override val arguments: List<FirExpression> abstract override val argumentList: FirArgumentList
abstract val operation: FirOperation abstract val operation: FirOperation
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitOperatorCall(this, data) override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitOperatorCall(this, data)
abstract override fun <D> transformArguments(transformer: FirTransformer<D>, data: D): FirOperatorCall
} }
@@ -17,10 +17,8 @@ import org.jetbrains.kotlin.fir.visitors.*
abstract class FirStringConcatenationCall : FirCall, FirExpression() { abstract class FirStringConcatenationCall : FirCall, FirExpression() {
abstract override val source: FirSourceElement? abstract override val source: FirSourceElement?
abstract override val annotations: List<FirAnnotationCall> abstract override val annotations: List<FirAnnotationCall>
abstract override val arguments: List<FirExpression> abstract override val argumentList: FirArgumentList
abstract override val typeRef: FirTypeRef abstract override val typeRef: FirTypeRef
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitStringConcatenationCall(this, data) override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitStringConcatenationCall(this, data)
abstract override fun <D> transformArguments(transformer: FirTransformer<D>, data: D): FirStringConcatenationCall
} }
@@ -18,11 +18,9 @@ abstract class FirTypeOperatorCall : FirExpression(), FirCall {
abstract override val source: FirSourceElement? abstract override val source: FirSourceElement?
abstract override val typeRef: FirTypeRef abstract override val typeRef: FirTypeRef
abstract override val annotations: List<FirAnnotationCall> abstract override val annotations: List<FirAnnotationCall>
abstract override val arguments: List<FirExpression> abstract override val argumentList: FirArgumentList
abstract val operation: FirOperation abstract val operation: FirOperation
abstract val conversionTypeRef: FirTypeRef abstract val conversionTypeRef: FirTypeRef
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitTypeOperatorCall(this, data) override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitTypeOperatorCall(this, data)
abstract override fun <D> transformArguments(transformer: FirTransformer<D>, data: D): FirTypeOperatorCall
} }
@@ -11,7 +11,8 @@ import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder
import org.jetbrains.kotlin.fir.builder.FirBuilderDsl import org.jetbrains.kotlin.fir.builder.FirBuilderDsl
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirArgumentList
import org.jetbrains.kotlin.fir.expressions.FirEmptyArgumentList
import org.jetbrains.kotlin.fir.expressions.builder.FirCallBuilder import org.jetbrains.kotlin.fir.expressions.builder.FirCallBuilder
import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder
import org.jetbrains.kotlin.fir.expressions.impl.FirAnnotationCallImpl import org.jetbrains.kotlin.fir.expressions.impl.FirAnnotationCallImpl
@@ -27,7 +28,7 @@ import org.jetbrains.kotlin.fir.visitors.*
class FirAnnotationCallBuilder : FirCallBuilder, FirAnnotationContainerBuilder, FirExpressionBuilder { class FirAnnotationCallBuilder : FirCallBuilder, FirAnnotationContainerBuilder, FirExpressionBuilder {
override var source: FirSourceElement? = null override var source: FirSourceElement? = null
override val annotations: MutableList<FirAnnotationCall> = mutableListOf() override val annotations: MutableList<FirAnnotationCall> = mutableListOf()
override val arguments: MutableList<FirExpression> = mutableListOf() override var argumentList: FirArgumentList = FirEmptyArgumentList
var useSiteTarget: AnnotationUseSiteTarget? = null var useSiteTarget: AnnotationUseSiteTarget? = null
lateinit var annotationTypeRef: FirTypeRef lateinit var annotationTypeRef: FirTypeRef
@@ -35,7 +36,7 @@ class FirAnnotationCallBuilder : FirCallBuilder, FirAnnotationContainerBuilder,
return FirAnnotationCallImpl( return FirAnnotationCallImpl(
source, source,
annotations, annotations,
arguments, argumentList,
useSiteTarget, useSiteTarget,
annotationTypeRef, annotationTypeRef,
) )
@@ -0,0 +1,41 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.fir.expressions.builder
import kotlin.contracts.*
import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.builder.FirBuilderDsl
import org.jetbrains.kotlin.fir.expressions.FirArgumentList
import org.jetbrains.kotlin.fir.expressions.FirExpression
import org.jetbrains.kotlin.fir.expressions.impl.FirArgumentListImpl
import org.jetbrains.kotlin.fir.visitors.*
/*
* This file was generated automatically
* DO NOT MODIFY IT MANUALLY
*/
@FirBuilderDsl
class FirArgumentListBuilder {
var source: FirSourceElement? = null
val arguments: MutableList<FirExpression> = mutableListOf()
fun build(): FirArgumentList {
return FirArgumentListImpl(
source,
arguments,
)
}
}
@OptIn(ExperimentalContracts::class)
inline fun buildArgumentList(init: FirArgumentListBuilder.() -> Unit = {}): FirArgumentList {
contract {
callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE)
}
return FirArgumentListBuilder().apply(init).build()
}
@@ -10,8 +10,8 @@ import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder
import org.jetbrains.kotlin.fir.builder.FirBuilderDsl import org.jetbrains.kotlin.fir.builder.FirBuilderDsl
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.FirArgumentList
import org.jetbrains.kotlin.fir.expressions.FirArrayOfCall import org.jetbrains.kotlin.fir.expressions.FirArrayOfCall
import org.jetbrains.kotlin.fir.expressions.FirExpression
import org.jetbrains.kotlin.fir.expressions.builder.FirCallBuilder import org.jetbrains.kotlin.fir.expressions.builder.FirCallBuilder
import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder
import org.jetbrains.kotlin.fir.expressions.impl.FirArrayOfCallImpl import org.jetbrains.kotlin.fir.expressions.impl.FirArrayOfCallImpl
@@ -28,13 +28,13 @@ import org.jetbrains.kotlin.fir.visitors.*
class FirArrayOfCallBuilder : FirCallBuilder, FirAnnotationContainerBuilder, FirExpressionBuilder { class FirArrayOfCallBuilder : FirCallBuilder, FirAnnotationContainerBuilder, FirExpressionBuilder {
override var source: FirSourceElement? = null override var source: FirSourceElement? = null
override val annotations: MutableList<FirAnnotationCall> = mutableListOf() override val annotations: MutableList<FirAnnotationCall> = mutableListOf()
override val arguments: MutableList<FirExpression> = mutableListOf() override lateinit var argumentList: FirArgumentList
override fun build(): FirArrayOfCall { override fun build(): FirArrayOfCall {
return FirArrayOfCallImpl( return FirArrayOfCallImpl(
source, source,
annotations, annotations,
arguments, argumentList,
) )
} }
@@ -48,7 +48,7 @@ class FirArrayOfCallBuilder : FirCallBuilder, FirAnnotationContainerBuilder, Fir
} }
@OptIn(ExperimentalContracts::class) @OptIn(ExperimentalContracts::class)
inline fun buildArrayOfCall(init: FirArrayOfCallBuilder.() -> Unit = {}): FirArrayOfCall { inline fun buildArrayOfCall(init: FirArrayOfCallBuilder.() -> Unit): FirArrayOfCall {
contract { contract {
callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE)
} }
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder
import org.jetbrains.kotlin.fir.builder.FirBuilderDsl import org.jetbrains.kotlin.fir.builder.FirBuilderDsl
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.FirArgumentList
import org.jetbrains.kotlin.fir.expressions.FirArraySetCall import org.jetbrains.kotlin.fir.expressions.FirArraySetCall
import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirExpression
import org.jetbrains.kotlin.fir.expressions.FirOperation import org.jetbrains.kotlin.fir.expressions.FirOperation
@@ -36,6 +37,7 @@ class FirArraySetCallBuilder : FirQualifiedAccessBuilder, FirAnnotationContainer
override var dispatchReceiver: FirExpression = FirNoReceiverExpression override var dispatchReceiver: FirExpression = FirNoReceiverExpression
override var extensionReceiver: FirExpression = FirNoReceiverExpression override var extensionReceiver: FirExpression = FirNoReceiverExpression
lateinit var calleeReference: FirReference lateinit var calleeReference: FirReference
lateinit var argumentList: FirArgumentList
lateinit var rValue: FirExpression lateinit var rValue: FirExpression
lateinit var operation: FirOperation lateinit var operation: FirOperation
val indexes: MutableList<FirExpression> = mutableListOf() val indexes: MutableList<FirExpression> = mutableListOf()
@@ -50,6 +52,7 @@ class FirArraySetCallBuilder : FirQualifiedAccessBuilder, FirAnnotationContainer
dispatchReceiver, dispatchReceiver,
extensionReceiver, extensionReceiver,
calleeReference, calleeReference,
argumentList,
rValue, rValue,
operation, operation,
indexes, indexes,
@@ -8,8 +8,8 @@ package org.jetbrains.kotlin.fir.expressions.builder
import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.builder.FirBuilderDsl import org.jetbrains.kotlin.fir.builder.FirBuilderDsl
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.FirArgumentList
import org.jetbrains.kotlin.fir.expressions.FirCall import org.jetbrains.kotlin.fir.expressions.FirCall
import org.jetbrains.kotlin.fir.expressions.FirExpression
import org.jetbrains.kotlin.fir.visitors.* import org.jetbrains.kotlin.fir.visitors.*
/* /*
@@ -21,7 +21,6 @@ import org.jetbrains.kotlin.fir.visitors.*
interface FirCallBuilder { interface FirCallBuilder {
abstract var source: FirSourceElement? abstract var source: FirSourceElement?
abstract val annotations: MutableList<FirAnnotationCall> abstract val annotations: MutableList<FirAnnotationCall>
abstract val arguments: MutableList<FirExpression> abstract var argumentList: FirArgumentList
fun build(): FirCall fun build(): FirCall
} }
@@ -10,8 +10,8 @@ import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder
import org.jetbrains.kotlin.fir.builder.FirBuilderDsl import org.jetbrains.kotlin.fir.builder.FirBuilderDsl
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.FirArgumentList
import org.jetbrains.kotlin.fir.expressions.FirCheckNotNullCall import org.jetbrains.kotlin.fir.expressions.FirCheckNotNullCall
import org.jetbrains.kotlin.fir.expressions.FirExpression
import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder
import org.jetbrains.kotlin.fir.expressions.impl.FirCheckNotNullCallImpl import org.jetbrains.kotlin.fir.expressions.impl.FirCheckNotNullCallImpl
import org.jetbrains.kotlin.fir.references.FirReference import org.jetbrains.kotlin.fir.references.FirReference
@@ -30,7 +30,7 @@ class FirCheckNotNullCallBuilder : FirAnnotationContainerBuilder, FirExpressionB
override var source: FirSourceElement? = null override var source: FirSourceElement? = null
override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null)
override val annotations: MutableList<FirAnnotationCall> = mutableListOf() override val annotations: MutableList<FirAnnotationCall> = mutableListOf()
val arguments: MutableList<FirExpression> = mutableListOf() lateinit var argumentList: FirArgumentList
var calleeReference: FirReference = FirStubReference var calleeReference: FirReference = FirStubReference
override fun build(): FirCheckNotNullCall { override fun build(): FirCheckNotNullCall {
@@ -38,7 +38,7 @@ class FirCheckNotNullCallBuilder : FirAnnotationContainerBuilder, FirExpressionB
source, source,
typeRef, typeRef,
annotations, annotations,
arguments, argumentList,
calleeReference, calleeReference,
) )
} }
@@ -46,7 +46,7 @@ class FirCheckNotNullCallBuilder : FirAnnotationContainerBuilder, FirExpressionB
} }
@OptIn(ExperimentalContracts::class) @OptIn(ExperimentalContracts::class)
inline fun buildCheckNotNullCall(init: FirCheckNotNullCallBuilder.() -> Unit = {}): FirCheckNotNullCall { inline fun buildCheckNotNullCall(init: FirCheckNotNullCallBuilder.() -> Unit): FirCheckNotNullCall {
contract { contract {
callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE)
} }
@@ -11,7 +11,9 @@ import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder
import org.jetbrains.kotlin.fir.builder.FirBuilderDsl import org.jetbrains.kotlin.fir.builder.FirBuilderDsl
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.FirArgumentList
import org.jetbrains.kotlin.fir.expressions.FirComponentCall import org.jetbrains.kotlin.fir.expressions.FirComponentCall
import org.jetbrains.kotlin.fir.expressions.FirEmptyArgumentList
import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirExpression
import org.jetbrains.kotlin.fir.expressions.builder.FirCallBuilder import org.jetbrains.kotlin.fir.expressions.builder.FirCallBuilder
import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder
@@ -35,7 +37,7 @@ class FirComponentCallBuilder : FirCallBuilder, FirAnnotationContainerBuilder, F
override var source: FirSourceElement? = null override var source: FirSourceElement? = null
override val annotations: MutableList<FirAnnotationCall> = mutableListOf() override val annotations: MutableList<FirAnnotationCall> = mutableListOf()
val typeArguments: MutableList<FirTypeProjection> = mutableListOf() val typeArguments: MutableList<FirTypeProjection> = mutableListOf()
override val arguments: MutableList<FirExpression> = mutableListOf() override var argumentList: FirArgumentList = FirEmptyArgumentList
lateinit var explicitReceiver: FirExpression lateinit var explicitReceiver: FirExpression
var componentIndex: Int by kotlin.properties.Delegates.notNull<Int>() var componentIndex: Int by kotlin.properties.Delegates.notNull<Int>()
@@ -44,7 +46,7 @@ class FirComponentCallBuilder : FirCallBuilder, FirAnnotationContainerBuilder, F
source, source,
annotations, annotations,
typeArguments, typeArguments,
arguments, argumentList,
explicitReceiver, explicitReceiver,
componentIndex, componentIndex,
) )
@@ -10,8 +10,9 @@ import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder
import org.jetbrains.kotlin.fir.builder.FirBuilderDsl import org.jetbrains.kotlin.fir.builder.FirBuilderDsl
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.FirArgumentList
import org.jetbrains.kotlin.fir.expressions.FirDelegatedConstructorCall import org.jetbrains.kotlin.fir.expressions.FirDelegatedConstructorCall
import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirEmptyArgumentList
import org.jetbrains.kotlin.fir.expressions.builder.FirCallBuilder import org.jetbrains.kotlin.fir.expressions.builder.FirCallBuilder
import org.jetbrains.kotlin.fir.expressions.impl.FirDelegatedConstructorCallImpl import org.jetbrains.kotlin.fir.expressions.impl.FirDelegatedConstructorCallImpl
import org.jetbrains.kotlin.fir.references.FirReference import org.jetbrains.kotlin.fir.references.FirReference
@@ -29,7 +30,7 @@ import org.jetbrains.kotlin.fir.visitors.*
class FirDelegatedConstructorCallBuilder : FirCallBuilder, FirAnnotationContainerBuilder { class FirDelegatedConstructorCallBuilder : FirCallBuilder, FirAnnotationContainerBuilder {
override var source: FirSourceElement? = null override var source: FirSourceElement? = null
override val annotations: MutableList<FirAnnotationCall> = mutableListOf() override val annotations: MutableList<FirAnnotationCall> = mutableListOf()
override val arguments: MutableList<FirExpression> = mutableListOf() override var argumentList: FirArgumentList = FirEmptyArgumentList
lateinit var constructedTypeRef: FirTypeRef lateinit var constructedTypeRef: FirTypeRef
var isThis: Boolean by kotlin.properties.Delegates.notNull<Boolean>() var isThis: Boolean by kotlin.properties.Delegates.notNull<Boolean>()
@@ -37,7 +38,7 @@ class FirDelegatedConstructorCallBuilder : FirCallBuilder, FirAnnotationContaine
return FirDelegatedConstructorCallImpl( return FirDelegatedConstructorCallImpl(
source, source,
annotations, annotations,
arguments, argumentList,
constructedTypeRef, constructedTypeRef,
isThis, isThis,
) )
@@ -11,6 +11,8 @@ import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder
import org.jetbrains.kotlin.fir.builder.FirBuilderDsl import org.jetbrains.kotlin.fir.builder.FirBuilderDsl
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.FirArgumentList
import org.jetbrains.kotlin.fir.expressions.FirEmptyArgumentList
import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirExpression
import org.jetbrains.kotlin.fir.expressions.FirFunctionCall import org.jetbrains.kotlin.fir.expressions.FirFunctionCall
import org.jetbrains.kotlin.fir.expressions.builder.FirCallBuilder import org.jetbrains.kotlin.fir.expressions.builder.FirCallBuilder
@@ -40,7 +42,7 @@ open class FirFunctionCallBuilder : FirQualifiedAccessBuilder, FirCallBuilder, F
override var explicitReceiver: FirExpression? = null override var explicitReceiver: FirExpression? = null
override var dispatchReceiver: FirExpression = FirNoReceiverExpression override var dispatchReceiver: FirExpression = FirNoReceiverExpression
override var extensionReceiver: FirExpression = FirNoReceiverExpression override var extensionReceiver: FirExpression = FirNoReceiverExpression
override val arguments: MutableList<FirExpression> = mutableListOf() override var argumentList: FirArgumentList = FirEmptyArgumentList
open lateinit var calleeReference: FirNamedReference open lateinit var calleeReference: FirNamedReference
@OptIn(FirImplementationDetail::class) @OptIn(FirImplementationDetail::class)
@@ -54,7 +56,7 @@ open class FirFunctionCallBuilder : FirQualifiedAccessBuilder, FirCallBuilder, F
explicitReceiver, explicitReceiver,
dispatchReceiver, dispatchReceiver,
extensionReceiver, extensionReceiver,
arguments, argumentList,
calleeReference, calleeReference,
) )
} }
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder
import org.jetbrains.kotlin.fir.builder.FirBuilderDsl import org.jetbrains.kotlin.fir.builder.FirBuilderDsl
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.FirArgumentList
import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirExpression
import org.jetbrains.kotlin.fir.expressions.FirGetClassCall import org.jetbrains.kotlin.fir.expressions.FirGetClassCall
import org.jetbrains.kotlin.fir.expressions.builder.FirCallBuilder import org.jetbrains.kotlin.fir.expressions.builder.FirCallBuilder
@@ -28,13 +29,13 @@ import org.jetbrains.kotlin.fir.visitors.*
class FirGetClassCallBuilder : FirCallBuilder, FirAnnotationContainerBuilder, FirExpressionBuilder { class FirGetClassCallBuilder : FirCallBuilder, FirAnnotationContainerBuilder, FirExpressionBuilder {
override var source: FirSourceElement? = null override var source: FirSourceElement? = null
override val annotations: MutableList<FirAnnotationCall> = mutableListOf() override val annotations: MutableList<FirAnnotationCall> = mutableListOf()
override val arguments: MutableList<FirExpression> = mutableListOf() override lateinit var argumentList: FirArgumentList
override fun build(): FirGetClassCall { override fun build(): FirGetClassCall {
return FirGetClassCallImpl( return FirGetClassCallImpl(
source, source,
annotations, annotations,
arguments, argumentList,
) )
} }
@@ -48,7 +49,7 @@ class FirGetClassCallBuilder : FirCallBuilder, FirAnnotationContainerBuilder, Fi
} }
@OptIn(ExperimentalContracts::class) @OptIn(ExperimentalContracts::class)
inline fun buildGetClassCall(init: FirGetClassCallBuilder.() -> Unit = {}): FirGetClassCall { inline fun buildGetClassCall(init: FirGetClassCallBuilder.() -> Unit): FirGetClassCall {
contract { contract {
callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE)
} }
@@ -10,7 +10,7 @@ import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder
import org.jetbrains.kotlin.fir.builder.FirBuilderDsl import org.jetbrains.kotlin.fir.builder.FirBuilderDsl
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirArgumentList
import org.jetbrains.kotlin.fir.expressions.FirOperation import org.jetbrains.kotlin.fir.expressions.FirOperation
import org.jetbrains.kotlin.fir.expressions.FirOperatorCall import org.jetbrains.kotlin.fir.expressions.FirOperatorCall
import org.jetbrains.kotlin.fir.expressions.builder.FirCallBuilder import org.jetbrains.kotlin.fir.expressions.builder.FirCallBuilder
@@ -30,14 +30,14 @@ import org.jetbrains.kotlin.fir.visitors.*
class FirOperatorCallBuilder : FirCallBuilder, FirAnnotationContainerBuilder, FirExpressionBuilder { class FirOperatorCallBuilder : FirCallBuilder, FirAnnotationContainerBuilder, FirExpressionBuilder {
override var source: FirSourceElement? = null override var source: FirSourceElement? = null
override val annotations: MutableList<FirAnnotationCall> = mutableListOf() override val annotations: MutableList<FirAnnotationCall> = mutableListOf()
override val arguments: MutableList<FirExpression> = mutableListOf() override lateinit var argumentList: FirArgumentList
lateinit var operation: FirOperation lateinit var operation: FirOperation
override fun build(): FirOperatorCall { override fun build(): FirOperatorCall {
return FirOperatorCallImpl( return FirOperatorCallImpl(
source, source,
annotations, annotations,
arguments, argumentList,
operation, operation,
) )
} }
@@ -10,7 +10,7 @@ import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder
import org.jetbrains.kotlin.fir.builder.FirBuilderDsl import org.jetbrains.kotlin.fir.builder.FirBuilderDsl
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirArgumentList
import org.jetbrains.kotlin.fir.expressions.FirStringConcatenationCall import org.jetbrains.kotlin.fir.expressions.FirStringConcatenationCall
import org.jetbrains.kotlin.fir.expressions.builder.FirCallBuilder import org.jetbrains.kotlin.fir.expressions.builder.FirCallBuilder
import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder
@@ -28,13 +28,13 @@ import org.jetbrains.kotlin.fir.visitors.*
class FirStringConcatenationCallBuilder : FirCallBuilder, FirAnnotationContainerBuilder, FirExpressionBuilder { class FirStringConcatenationCallBuilder : FirCallBuilder, FirAnnotationContainerBuilder, FirExpressionBuilder {
override var source: FirSourceElement? = null override var source: FirSourceElement? = null
override val annotations: MutableList<FirAnnotationCall> = mutableListOf() override val annotations: MutableList<FirAnnotationCall> = mutableListOf()
override val arguments: MutableList<FirExpression> = mutableListOf() override lateinit var argumentList: FirArgumentList
override fun build(): FirStringConcatenationCall { override fun build(): FirStringConcatenationCall {
return FirStringConcatenationCallImpl( return FirStringConcatenationCallImpl(
source, source,
annotations, annotations,
arguments, argumentList,
) )
} }
@@ -48,7 +48,7 @@ class FirStringConcatenationCallBuilder : FirCallBuilder, FirAnnotationContainer
} }
@OptIn(ExperimentalContracts::class) @OptIn(ExperimentalContracts::class)
inline fun buildStringConcatenationCall(init: FirStringConcatenationCallBuilder.() -> Unit = {}): FirStringConcatenationCall { inline fun buildStringConcatenationCall(init: FirStringConcatenationCallBuilder.() -> Unit): FirStringConcatenationCall {
contract { contract {
callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE)
} }
@@ -10,7 +10,8 @@ import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder
import org.jetbrains.kotlin.fir.builder.FirBuilderDsl import org.jetbrains.kotlin.fir.builder.FirBuilderDsl
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirArgumentList
import org.jetbrains.kotlin.fir.expressions.FirEmptyArgumentList
import org.jetbrains.kotlin.fir.expressions.FirOperation import org.jetbrains.kotlin.fir.expressions.FirOperation
import org.jetbrains.kotlin.fir.expressions.FirTypeOperatorCall import org.jetbrains.kotlin.fir.expressions.FirTypeOperatorCall
import org.jetbrains.kotlin.fir.expressions.builder.FirCallBuilder import org.jetbrains.kotlin.fir.expressions.builder.FirCallBuilder
@@ -29,7 +30,7 @@ import org.jetbrains.kotlin.fir.visitors.*
class FirTypeOperatorCallBuilder : FirCallBuilder, FirAnnotationContainerBuilder, FirExpressionBuilder { class FirTypeOperatorCallBuilder : FirCallBuilder, FirAnnotationContainerBuilder, FirExpressionBuilder {
override var source: FirSourceElement? = null override var source: FirSourceElement? = null
override val annotations: MutableList<FirAnnotationCall> = mutableListOf() override val annotations: MutableList<FirAnnotationCall> = mutableListOf()
override val arguments: MutableList<FirExpression> = mutableListOf() override var argumentList: FirArgumentList = FirEmptyArgumentList
lateinit var operation: FirOperation lateinit var operation: FirOperation
lateinit var conversionTypeRef: FirTypeRef lateinit var conversionTypeRef: FirTypeRef
@@ -37,7 +38,7 @@ class FirTypeOperatorCallBuilder : FirCallBuilder, FirAnnotationContainerBuilder
return FirTypeOperatorCallImpl( return FirTypeOperatorCallImpl(
source, source,
annotations, annotations,
arguments, argumentList,
operation, operation,
conversionTypeRef, conversionTypeRef,
) )
@@ -8,7 +8,7 @@ package org.jetbrains.kotlin.fir.expressions.impl
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirArgumentList
import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.FirTypeRef
import org.jetbrains.kotlin.fir.visitors.* import org.jetbrains.kotlin.fir.visitors.*
@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.fir.visitors.*
internal class FirAnnotationCallImpl( internal class FirAnnotationCallImpl(
override val source: FirSourceElement?, override val source: FirSourceElement?,
override val annotations: MutableList<FirAnnotationCall>, override val annotations: MutableList<FirAnnotationCall>,
override val arguments: MutableList<FirExpression>, override var argumentList: FirArgumentList,
override val useSiteTarget: AnnotationUseSiteTarget?, override val useSiteTarget: AnnotationUseSiteTarget?,
override var annotationTypeRef: FirTypeRef, override var annotationTypeRef: FirTypeRef,
) : FirAnnotationCall() { ) : FirAnnotationCall() {
@@ -28,21 +28,20 @@ internal class FirAnnotationCallImpl(
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) { override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
annotations.forEach { it.accept(visitor, data) } annotations.forEach { it.accept(visitor, data) }
arguments.forEach { it.accept(visitor, data) } argumentList.accept(visitor, data)
annotationTypeRef.accept(visitor, data) annotationTypeRef.accept(visitor, data)
} }
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirAnnotationCallImpl { override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirAnnotationCallImpl {
annotations.transformInplace(transformer, data) annotations.transformInplace(transformer, data)
transformArguments(transformer, data) argumentList = argumentList.transformSingle(transformer, data)
annotationTypeRef = annotationTypeRef.transformSingle(transformer, data) annotationTypeRef = annotationTypeRef.transformSingle(transformer, data)
return this return this
} }
override fun <D> transformArguments(transformer: FirTransformer<D>, data: D): FirAnnotationCallImpl {
arguments.transformInplace(transformer, data)
return this
}
override fun replaceTypeRef(newTypeRef: FirTypeRef) {} override fun replaceTypeRef(newTypeRef: FirTypeRef) {}
override fun replaceArgumentList(newArgumentList: FirArgumentList) {
argumentList = newArgumentList
}
} }
@@ -0,0 +1,35 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.fir.expressions.impl
import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.expressions.FirArgumentList
import org.jetbrains.kotlin.fir.expressions.FirExpression
import org.jetbrains.kotlin.fir.visitors.*
/*
* This file was generated automatically
* DO NOT MODIFY IT MANUALLY
*/
internal class FirArgumentListImpl(
override val source: FirSourceElement?,
override val arguments: MutableList<FirExpression>,
) : FirArgumentList() {
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
arguments.forEach { it.accept(visitor, data) }
}
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirArgumentListImpl {
transformArguments(transformer, data)
return this
}
override fun <D> transformArguments(transformer: FirTransformer<D>, data: D): FirArgumentListImpl {
arguments.transformInplace(transformer, data)
return this
}
}
@@ -7,8 +7,8 @@ package org.jetbrains.kotlin.fir.expressions.impl
import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.FirArgumentList
import org.jetbrains.kotlin.fir.expressions.FirArrayOfCall import org.jetbrains.kotlin.fir.expressions.FirArrayOfCall
import org.jetbrains.kotlin.fir.expressions.FirExpression
import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.FirTypeRef
import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl
import org.jetbrains.kotlin.fir.visitors.* import org.jetbrains.kotlin.fir.visitors.*
@@ -21,29 +21,28 @@ import org.jetbrains.kotlin.fir.visitors.*
internal class FirArrayOfCallImpl( internal class FirArrayOfCallImpl(
override val source: FirSourceElement?, override val source: FirSourceElement?,
override val annotations: MutableList<FirAnnotationCall>, override val annotations: MutableList<FirAnnotationCall>,
override val arguments: MutableList<FirExpression>, override var argumentList: FirArgumentList,
) : FirArrayOfCall() { ) : FirArrayOfCall() {
override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null)
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) { override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
typeRef.accept(visitor, data) typeRef.accept(visitor, data)
annotations.forEach { it.accept(visitor, data) } annotations.forEach { it.accept(visitor, data) }
arguments.forEach { it.accept(visitor, data) } argumentList.accept(visitor, data)
} }
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirArrayOfCallImpl { override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirArrayOfCallImpl {
typeRef = typeRef.transformSingle(transformer, data) typeRef = typeRef.transformSingle(transformer, data)
annotations.transformInplace(transformer, data) annotations.transformInplace(transformer, data)
transformArguments(transformer, data) argumentList = argumentList.transformSingle(transformer, data)
return this
}
override fun <D> transformArguments(transformer: FirTransformer<D>, data: D): FirArrayOfCallImpl {
arguments.transformInplace(transformer, data)
return this return this
} }
override fun replaceTypeRef(newTypeRef: FirTypeRef) { override fun replaceTypeRef(newTypeRef: FirTypeRef) {
typeRef = newTypeRef typeRef = newTypeRef
} }
override fun replaceArgumentList(newArgumentList: FirArgumentList) {
argumentList = newArgumentList
}
} }
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir.expressions.impl
import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.FirArgumentList
import org.jetbrains.kotlin.fir.expressions.FirArraySetCall import org.jetbrains.kotlin.fir.expressions.FirArraySetCall
import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirExpression
import org.jetbrains.kotlin.fir.expressions.FirOperation import org.jetbrains.kotlin.fir.expressions.FirOperation
@@ -29,11 +30,11 @@ internal class FirArraySetCallImpl(
override var dispatchReceiver: FirExpression, override var dispatchReceiver: FirExpression,
override var extensionReceiver: FirExpression, override var extensionReceiver: FirExpression,
override var calleeReference: FirReference, override var calleeReference: FirReference,
override var argumentList: FirArgumentList,
override var rValue: FirExpression, override var rValue: FirExpression,
override val operation: FirOperation, override val operation: FirOperation,
override val indexes: MutableList<FirExpression>, override val indexes: MutableList<FirExpression>,
) : FirArraySetCall(), FirModifiableQualifiedAccess { ) : FirArraySetCall(), FirModifiableQualifiedAccess {
override val arguments: List<FirExpression> get() = indexes + rValue
override var lValue: FirReference override var lValue: FirReference
get() = calleeReference get() = calleeReference
set(value) { set(value) {
@@ -51,6 +52,7 @@ internal class FirArraySetCallImpl(
extensionReceiver.accept(visitor, data) extensionReceiver.accept(visitor, data)
} }
calleeReference.accept(visitor, data) calleeReference.accept(visitor, data)
argumentList.accept(visitor, data)
rValue.accept(visitor, data) rValue.accept(visitor, data)
indexes.forEach { it.accept(visitor, data) } indexes.forEach { it.accept(visitor, data) }
} }
@@ -66,6 +68,7 @@ internal class FirArraySetCallImpl(
extensionReceiver = extensionReceiver.transformSingle(transformer, data) extensionReceiver = extensionReceiver.transformSingle(transformer, data)
} }
transformCalleeReference(transformer, data) transformCalleeReference(transformer, data)
argumentList = argumentList.transformSingle(transformer, data)
transformRValue(transformer, data) transformRValue(transformer, data)
transformIndexes(transformer, data) transformIndexes(transformer, data)
return this return this
@@ -96,10 +99,6 @@ internal class FirArraySetCallImpl(
return this return this
} }
override fun <D> transformArguments(transformer: FirTransformer<D>, data: D): FirArraySetCallImpl {
return this
}
override fun <D> transformRValue(transformer: FirTransformer<D>, data: D): FirArraySetCallImpl { override fun <D> transformRValue(transformer: FirTransformer<D>, data: D): FirArraySetCallImpl {
rValue = rValue.transformSingle(transformer, data) rValue = rValue.transformSingle(transformer, data)
return this return this
@@ -114,4 +113,8 @@ internal class FirArraySetCallImpl(
typeArguments.clear() typeArguments.clear()
typeArguments.addAll(newTypeArguments) typeArguments.addAll(newTypeArguments)
} }
override fun replaceArgumentList(newArgumentList: FirArgumentList) {
argumentList = newArgumentList
}
} }
@@ -7,8 +7,8 @@ package org.jetbrains.kotlin.fir.expressions.impl
import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.FirArgumentList
import org.jetbrains.kotlin.fir.expressions.FirCheckNotNullCall import org.jetbrains.kotlin.fir.expressions.FirCheckNotNullCall
import org.jetbrains.kotlin.fir.expressions.FirExpression
import org.jetbrains.kotlin.fir.references.FirReference import org.jetbrains.kotlin.fir.references.FirReference
import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.FirTypeRef
import org.jetbrains.kotlin.fir.visitors.* import org.jetbrains.kotlin.fir.visitors.*
@@ -22,29 +22,24 @@ internal class FirCheckNotNullCallImpl(
override val source: FirSourceElement?, override val source: FirSourceElement?,
override var typeRef: FirTypeRef, override var typeRef: FirTypeRef,
override val annotations: MutableList<FirAnnotationCall>, override val annotations: MutableList<FirAnnotationCall>,
override val arguments: MutableList<FirExpression>, override var argumentList: FirArgumentList,
override var calleeReference: FirReference, override var calleeReference: FirReference,
) : FirCheckNotNullCall() { ) : FirCheckNotNullCall() {
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) { override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
typeRef.accept(visitor, data) typeRef.accept(visitor, data)
annotations.forEach { it.accept(visitor, data) } annotations.forEach { it.accept(visitor, data) }
arguments.forEach { it.accept(visitor, data) } argumentList.accept(visitor, data)
calleeReference.accept(visitor, data) calleeReference.accept(visitor, data)
} }
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirCheckNotNullCallImpl { override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirCheckNotNullCallImpl {
typeRef = typeRef.transformSingle(transformer, data) typeRef = typeRef.transformSingle(transformer, data)
annotations.transformInplace(transformer, data) annotations.transformInplace(transformer, data)
transformArguments(transformer, data) argumentList = argumentList.transformSingle(transformer, data)
transformCalleeReference(transformer, data) transformCalleeReference(transformer, data)
return this return this
} }
override fun <D> transformArguments(transformer: FirTransformer<D>, data: D): FirCheckNotNullCallImpl {
arguments.transformInplace(transformer, data)
return this
}
override fun <D> transformCalleeReference(transformer: FirTransformer<D>, data: D): FirCheckNotNullCallImpl { override fun <D> transformCalleeReference(transformer: FirTransformer<D>, data: D): FirCheckNotNullCallImpl {
calleeReference = calleeReference.transformSingle(transformer, data) calleeReference = calleeReference.transformSingle(transformer, data)
return this return this
@@ -53,4 +48,8 @@ internal class FirCheckNotNullCallImpl(
override fun replaceTypeRef(newTypeRef: FirTypeRef) { override fun replaceTypeRef(newTypeRef: FirTypeRef) {
typeRef = newTypeRef typeRef = newTypeRef
} }
override fun replaceArgumentList(newArgumentList: FirArgumentList) {
argumentList = newArgumentList
}
} }
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.fir.expressions.impl
import org.jetbrains.kotlin.fir.FirImplementationDetail import org.jetbrains.kotlin.fir.FirImplementationDetail
import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.FirArgumentList
import org.jetbrains.kotlin.fir.expressions.FirComponentCall import org.jetbrains.kotlin.fir.expressions.FirComponentCall
import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirExpression
import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression
@@ -29,7 +30,7 @@ internal class FirComponentCallImpl(
override val source: FirSourceElement?, override val source: FirSourceElement?,
override val annotations: MutableList<FirAnnotationCall>, override val annotations: MutableList<FirAnnotationCall>,
override val typeArguments: MutableList<FirTypeProjection>, override val typeArguments: MutableList<FirTypeProjection>,
override val arguments: MutableList<FirExpression>, override var argumentList: FirArgumentList,
override var explicitReceiver: FirExpression, override var explicitReceiver: FirExpression,
override val componentIndex: Int, override val componentIndex: Int,
) : FirComponentCall() { ) : FirComponentCall() {
@@ -43,7 +44,7 @@ internal class FirComponentCallImpl(
typeRef.accept(visitor, data) typeRef.accept(visitor, data)
annotations.forEach { it.accept(visitor, data) } annotations.forEach { it.accept(visitor, data) }
typeArguments.forEach { it.accept(visitor, data) } typeArguments.forEach { it.accept(visitor, data) }
arguments.forEach { it.accept(visitor, data) } argumentList.accept(visitor, data)
calleeReference.accept(visitor, data) calleeReference.accept(visitor, data)
explicitReceiver.accept(visitor, data) explicitReceiver.accept(visitor, data)
if (dispatchReceiver !== explicitReceiver) { if (dispatchReceiver !== explicitReceiver) {
@@ -58,7 +59,7 @@ internal class FirComponentCallImpl(
typeRef = typeRef.transformSingle(transformer, data) typeRef = typeRef.transformSingle(transformer, data)
annotations.transformInplace(transformer, data) annotations.transformInplace(transformer, data)
transformTypeArguments(transformer, data) transformTypeArguments(transformer, data)
transformArguments(transformer, data) argumentList = argumentList.transformSingle(transformer, data)
transformCalleeReference(transformer, data) transformCalleeReference(transformer, data)
explicitReceiver = explicitReceiver.transformSingle(transformer, data) explicitReceiver = explicitReceiver.transformSingle(transformer, data)
return this return this
@@ -77,11 +78,6 @@ internal class FirComponentCallImpl(
return this return this
} }
override fun <D> transformArguments(transformer: FirTransformer<D>, data: D): FirComponentCallImpl {
arguments.transformInplace(transformer, data)
return this
}
override fun <D> transformCalleeReference(transformer: FirTransformer<D>, data: D): FirComponentCallImpl { override fun <D> transformCalleeReference(transformer: FirTransformer<D>, data: D): FirComponentCallImpl {
calleeReference = calleeReference.transformSingle(transformer, data) calleeReference = calleeReference.transformSingle(transformer, data)
return this return this
@@ -100,4 +96,8 @@ internal class FirComponentCallImpl(
typeArguments.clear() typeArguments.clear()
typeArguments.addAll(newTypeArguments) typeArguments.addAll(newTypeArguments)
} }
override fun replaceArgumentList(newArgumentList: FirArgumentList) {
argumentList = newArgumentList
}
} }
@@ -7,8 +7,8 @@ package org.jetbrains.kotlin.fir.expressions.impl
import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.FirArgumentList
import org.jetbrains.kotlin.fir.expressions.FirDelegatedConstructorCall import org.jetbrains.kotlin.fir.expressions.FirDelegatedConstructorCall
import org.jetbrains.kotlin.fir.expressions.FirExpression
import org.jetbrains.kotlin.fir.references.FirReference import org.jetbrains.kotlin.fir.references.FirReference
import org.jetbrains.kotlin.fir.references.impl.FirExplicitSuperReference import org.jetbrains.kotlin.fir.references.impl.FirExplicitSuperReference
import org.jetbrains.kotlin.fir.references.impl.FirExplicitThisReference import org.jetbrains.kotlin.fir.references.impl.FirExplicitThisReference
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.fir.visitors.*
internal class FirDelegatedConstructorCallImpl( internal class FirDelegatedConstructorCallImpl(
override val source: FirSourceElement?, override val source: FirSourceElement?,
override val annotations: MutableList<FirAnnotationCall>, override val annotations: MutableList<FirAnnotationCall>,
override val arguments: MutableList<FirExpression>, override var argumentList: FirArgumentList,
override var constructedTypeRef: FirTypeRef, override var constructedTypeRef: FirTypeRef,
override val isThis: Boolean, override val isThis: Boolean,
) : FirDelegatedConstructorCall() { ) : FirDelegatedConstructorCall() {
@@ -33,14 +33,14 @@ internal class FirDelegatedConstructorCallImpl(
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) { override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
calleeReference.accept(visitor, data) calleeReference.accept(visitor, data)
annotations.forEach { it.accept(visitor, data) } annotations.forEach { it.accept(visitor, data) }
arguments.forEach { it.accept(visitor, data) } argumentList.accept(visitor, data)
constructedTypeRef.accept(visitor, data) constructedTypeRef.accept(visitor, data)
} }
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirDelegatedConstructorCallImpl { override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirDelegatedConstructorCallImpl {
transformCalleeReference(transformer, data) transformCalleeReference(transformer, data)
annotations.transformInplace(transformer, data) annotations.transformInplace(transformer, data)
transformArguments(transformer, data) argumentList = argumentList.transformSingle(transformer, data)
constructedTypeRef = constructedTypeRef.transformSingle(transformer, data) constructedTypeRef = constructedTypeRef.transformSingle(transformer, data)
return this return this
} }
@@ -50,8 +50,7 @@ internal class FirDelegatedConstructorCallImpl(
return this return this
} }
override fun <D> transformArguments(transformer: FirTransformer<D>, data: D): FirDelegatedConstructorCallImpl { override fun replaceArgumentList(newArgumentList: FirArgumentList) {
arguments.transformInplace(transformer, data) argumentList = newArgumentList
return this
} }
} }
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.fir.expressions.impl
import org.jetbrains.kotlin.fir.FirImplementationDetail import org.jetbrains.kotlin.fir.FirImplementationDetail
import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.FirArgumentList
import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirExpression
import org.jetbrains.kotlin.fir.expressions.FirFunctionCall import org.jetbrains.kotlin.fir.expressions.FirFunctionCall
import org.jetbrains.kotlin.fir.expressions.impl.FirModifiableQualifiedAccess import org.jetbrains.kotlin.fir.expressions.impl.FirModifiableQualifiedAccess
@@ -30,7 +31,7 @@ open class FirFunctionCallImpl @FirImplementationDetail constructor(
override var explicitReceiver: FirExpression?, override var explicitReceiver: FirExpression?,
override var dispatchReceiver: FirExpression, override var dispatchReceiver: FirExpression,
override var extensionReceiver: FirExpression, override var extensionReceiver: FirExpression,
override val arguments: MutableList<FirExpression>, override var argumentList: FirArgumentList,
override var calleeReference: FirNamedReference, override var calleeReference: FirNamedReference,
) : FirFunctionCall(), FirModifiableQualifiedAccess { ) : FirFunctionCall(), FirModifiableQualifiedAccess {
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) { override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
@@ -44,7 +45,7 @@ open class FirFunctionCallImpl @FirImplementationDetail constructor(
if (extensionReceiver !== explicitReceiver && extensionReceiver !== dispatchReceiver) { if (extensionReceiver !== explicitReceiver && extensionReceiver !== dispatchReceiver) {
extensionReceiver.accept(visitor, data) extensionReceiver.accept(visitor, data)
} }
arguments.forEach { it.accept(visitor, data) } argumentList.accept(visitor, data)
calleeReference.accept(visitor, data) calleeReference.accept(visitor, data)
} }
@@ -59,7 +60,7 @@ open class FirFunctionCallImpl @FirImplementationDetail constructor(
if (extensionReceiver !== explicitReceiver && extensionReceiver !== dispatchReceiver) { if (extensionReceiver !== explicitReceiver && extensionReceiver !== dispatchReceiver) {
extensionReceiver = extensionReceiver.transformSingle(transformer, data) extensionReceiver = extensionReceiver.transformSingle(transformer, data)
} }
transformArguments(transformer, data) argumentList = argumentList.transformSingle(transformer, data)
transformCalleeReference(transformer, data) transformCalleeReference(transformer, data)
return this return this
} }
@@ -84,11 +85,6 @@ open class FirFunctionCallImpl @FirImplementationDetail constructor(
return this return this
} }
override fun <D> transformArguments(transformer: FirTransformer<D>, data: D): FirFunctionCallImpl {
arguments.transformInplace(transformer, data)
return this
}
override fun <D> transformCalleeReference(transformer: FirTransformer<D>, data: D): FirFunctionCallImpl { override fun <D> transformCalleeReference(transformer: FirTransformer<D>, data: D): FirFunctionCallImpl {
calleeReference = calleeReference.transformSingle(transformer, data) calleeReference = calleeReference.transformSingle(transformer, data)
return this return this
@@ -102,4 +98,8 @@ open class FirFunctionCallImpl @FirImplementationDetail constructor(
typeArguments.clear() typeArguments.clear()
typeArguments.addAll(newTypeArguments) typeArguments.addAll(newTypeArguments)
} }
override fun replaceArgumentList(newArgumentList: FirArgumentList) {
argumentList = newArgumentList
}
} }
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir.expressions.impl
import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.FirArgumentList
import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirExpression
import org.jetbrains.kotlin.fir.expressions.FirGetClassCall import org.jetbrains.kotlin.fir.expressions.FirGetClassCall
import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.FirTypeRef
@@ -21,30 +22,29 @@ import org.jetbrains.kotlin.fir.visitors.*
internal class FirGetClassCallImpl( internal class FirGetClassCallImpl(
override val source: FirSourceElement?, override val source: FirSourceElement?,
override val annotations: MutableList<FirAnnotationCall>, override val annotations: MutableList<FirAnnotationCall>,
override val arguments: MutableList<FirExpression>, override var argumentList: FirArgumentList,
) : FirGetClassCall() { ) : FirGetClassCall() {
override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null)
override val argument: FirExpression get() = arguments.first() override val argument: FirExpression get() = argumentList.arguments.first()
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) { override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
typeRef.accept(visitor, data) typeRef.accept(visitor, data)
annotations.forEach { it.accept(visitor, data) } annotations.forEach { it.accept(visitor, data) }
arguments.forEach { it.accept(visitor, data) } argumentList.accept(visitor, data)
} }
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirGetClassCallImpl { override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirGetClassCallImpl {
typeRef = typeRef.transformSingle(transformer, data) typeRef = typeRef.transformSingle(transformer, data)
annotations.transformInplace(transformer, data) annotations.transformInplace(transformer, data)
transformArguments(transformer, data) argumentList = argumentList.transformSingle(transformer, data)
return this
}
override fun <D> transformArguments(transformer: FirTransformer<D>, data: D): FirGetClassCallImpl {
arguments.transformInplace(transformer, data)
return this return this
} }
override fun replaceTypeRef(newTypeRef: FirTypeRef) { override fun replaceTypeRef(newTypeRef: FirTypeRef) {
typeRef = newTypeRef typeRef = newTypeRef
} }
override fun replaceArgumentList(newArgumentList: FirArgumentList) {
argumentList = newArgumentList
}
} }
@@ -7,7 +7,7 @@ package org.jetbrains.kotlin.fir.expressions.impl
import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirArgumentList
import org.jetbrains.kotlin.fir.expressions.FirOperation import org.jetbrains.kotlin.fir.expressions.FirOperation
import org.jetbrains.kotlin.fir.expressions.FirOperatorCall import org.jetbrains.kotlin.fir.expressions.FirOperatorCall
import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.FirTypeRef
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.fir.visitors.*
internal class FirOperatorCallImpl( internal class FirOperatorCallImpl(
override val source: FirSourceElement?, override val source: FirSourceElement?,
override val annotations: MutableList<FirAnnotationCall>, override val annotations: MutableList<FirAnnotationCall>,
override val arguments: MutableList<FirExpression>, override var argumentList: FirArgumentList,
override val operation: FirOperation, override val operation: FirOperation,
) : FirOperatorCall() { ) : FirOperatorCall() {
override var typeRef: FirTypeRef = if (operation in FirOperation.BOOLEANS) { override var typeRef: FirTypeRef = if (operation in FirOperation.BOOLEANS) {
@@ -35,22 +35,21 @@ internal class FirOperatorCallImpl(
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) { override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
typeRef.accept(visitor, data) typeRef.accept(visitor, data)
annotations.forEach { it.accept(visitor, data) } annotations.forEach { it.accept(visitor, data) }
arguments.forEach { it.accept(visitor, data) } argumentList.accept(visitor, data)
} }
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirOperatorCallImpl { override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirOperatorCallImpl {
typeRef = typeRef.transformSingle(transformer, data) typeRef = typeRef.transformSingle(transformer, data)
annotations.transformInplace(transformer, data) annotations.transformInplace(transformer, data)
transformArguments(transformer, data) argumentList = argumentList.transformSingle(transformer, data)
return this
}
override fun <D> transformArguments(transformer: FirTransformer<D>, data: D): FirOperatorCallImpl {
arguments.transformInplace(transformer, data)
return this return this
} }
override fun replaceTypeRef(newTypeRef: FirTypeRef) { override fun replaceTypeRef(newTypeRef: FirTypeRef) {
typeRef = newTypeRef typeRef = newTypeRef
} }
override fun replaceArgumentList(newArgumentList: FirArgumentList) {
argumentList = newArgumentList
}
} }
@@ -7,7 +7,7 @@ package org.jetbrains.kotlin.fir.expressions.impl
import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirArgumentList
import org.jetbrains.kotlin.fir.expressions.FirStringConcatenationCall import org.jetbrains.kotlin.fir.expressions.FirStringConcatenationCall
import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.FirTypeRef
import org.jetbrains.kotlin.fir.types.impl.FirImplicitStringTypeRef import org.jetbrains.kotlin.fir.types.impl.FirImplicitStringTypeRef
@@ -21,26 +21,25 @@ import org.jetbrains.kotlin.fir.visitors.*
internal class FirStringConcatenationCallImpl( internal class FirStringConcatenationCallImpl(
override val source: FirSourceElement?, override val source: FirSourceElement?,
override val annotations: MutableList<FirAnnotationCall>, override val annotations: MutableList<FirAnnotationCall>,
override val arguments: MutableList<FirExpression>, override var argumentList: FirArgumentList,
) : FirStringConcatenationCall() { ) : FirStringConcatenationCall() {
override var typeRef: FirTypeRef = FirImplicitStringTypeRef(source) override var typeRef: FirTypeRef = FirImplicitStringTypeRef(source)
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) { override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
annotations.forEach { it.accept(visitor, data) } annotations.forEach { it.accept(visitor, data) }
arguments.forEach { it.accept(visitor, data) } argumentList.accept(visitor, data)
typeRef.accept(visitor, data) typeRef.accept(visitor, data)
} }
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirStringConcatenationCallImpl { override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirStringConcatenationCallImpl {
annotations.transformInplace(transformer, data) annotations.transformInplace(transformer, data)
transformArguments(transformer, data) argumentList = argumentList.transformSingle(transformer, data)
typeRef = typeRef.transformSingle(transformer, data) typeRef = typeRef.transformSingle(transformer, data)
return this return this
} }
override fun <D> transformArguments(transformer: FirTransformer<D>, data: D): FirStringConcatenationCallImpl { override fun replaceArgumentList(newArgumentList: FirArgumentList) {
arguments.transformInplace(transformer, data) argumentList = newArgumentList
return this
} }
override fun replaceTypeRef(newTypeRef: FirTypeRef) { override fun replaceTypeRef(newTypeRef: FirTypeRef) {
@@ -7,7 +7,7 @@ package org.jetbrains.kotlin.fir.expressions.impl
import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirArgumentList
import org.jetbrains.kotlin.fir.expressions.FirOperation import org.jetbrains.kotlin.fir.expressions.FirOperation
import org.jetbrains.kotlin.fir.expressions.FirTypeOperatorCall import org.jetbrains.kotlin.fir.expressions.FirTypeOperatorCall
import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.FirTypeRef
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.fir.visitors.*
internal class FirTypeOperatorCallImpl( internal class FirTypeOperatorCallImpl(
override val source: FirSourceElement?, override val source: FirSourceElement?,
override val annotations: MutableList<FirAnnotationCall>, override val annotations: MutableList<FirAnnotationCall>,
override val arguments: MutableList<FirExpression>, override var argumentList: FirArgumentList,
override val operation: FirOperation, override val operation: FirOperation,
override var conversionTypeRef: FirTypeRef, override var conversionTypeRef: FirTypeRef,
) : FirTypeOperatorCall() { ) : FirTypeOperatorCall() {
@@ -31,24 +31,23 @@ internal class FirTypeOperatorCallImpl(
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) { override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
typeRef.accept(visitor, data) typeRef.accept(visitor, data)
annotations.forEach { it.accept(visitor, data) } annotations.forEach { it.accept(visitor, data) }
arguments.forEach { it.accept(visitor, data) } argumentList.accept(visitor, data)
conversionTypeRef.accept(visitor, data) conversionTypeRef.accept(visitor, data)
} }
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirTypeOperatorCallImpl { override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirTypeOperatorCallImpl {
typeRef = typeRef.transformSingle(transformer, data) typeRef = typeRef.transformSingle(transformer, data)
annotations.transformInplace(transformer, data) annotations.transformInplace(transformer, data)
transformArguments(transformer, data) argumentList = argumentList.transformSingle(transformer, data)
conversionTypeRef = conversionTypeRef.transformSingle(transformer, data) conversionTypeRef = conversionTypeRef.transformSingle(transformer, data)
return this return this
} }
override fun <D> transformArguments(transformer: FirTransformer<D>, data: D): FirTypeOperatorCallImpl {
arguments.transformInplace(transformer, data)
return this
}
override fun replaceTypeRef(newTypeRef: FirTypeRef) { override fun replaceTypeRef(newTypeRef: FirTypeRef) {
typeRef = newTypeRef typeRef = newTypeRef
} }
override fun replaceArgumentList(newArgumentList: FirArgumentList) {
argumentList = newArgumentList
}
} }
@@ -62,6 +62,7 @@ import org.jetbrains.kotlin.fir.expressions.FirConstExpression
import org.jetbrains.kotlin.fir.types.FirTypeProjection import org.jetbrains.kotlin.fir.types.FirTypeProjection
import org.jetbrains.kotlin.fir.types.FirStarProjection import org.jetbrains.kotlin.fir.types.FirStarProjection
import org.jetbrains.kotlin.fir.types.FirTypeProjectionWithVariance import org.jetbrains.kotlin.fir.types.FirTypeProjectionWithVariance
import org.jetbrains.kotlin.fir.expressions.FirArgumentList
import org.jetbrains.kotlin.fir.expressions.FirCall import org.jetbrains.kotlin.fir.expressions.FirCall
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.FirOperatorCall import org.jetbrains.kotlin.fir.expressions.FirOperatorCall
@@ -354,6 +355,10 @@ abstract class FirTransformer<in D> : FirVisitor<CompositeTransformResult<FirEle
return transformElement(typeProjectionWithVariance, data) return transformElement(typeProjectionWithVariance, data)
} }
open fun transformArgumentList(argumentList: FirArgumentList, data: D): CompositeTransformResult<FirArgumentList> {
return transformElement(argumentList, data)
}
open fun transformCall(call: FirCall, data: D): CompositeTransformResult<FirStatement> { open fun transformCall(call: FirCall, data: D): CompositeTransformResult<FirStatement> {
return transformElement(call, data) return transformElement(call, data)
} }
@@ -810,6 +815,10 @@ abstract class FirTransformer<in D> : FirVisitor<CompositeTransformResult<FirEle
return transformTypeProjectionWithVariance(typeProjectionWithVariance, data) return transformTypeProjectionWithVariance(typeProjectionWithVariance, data)
} }
final override fun visitArgumentList(argumentList: FirArgumentList, data: D): CompositeTransformResult<FirArgumentList> {
return transformArgumentList(argumentList, data)
}
final override fun visitCall(call: FirCall, data: D): CompositeTransformResult<FirStatement> { final override fun visitCall(call: FirCall, data: D): CompositeTransformResult<FirStatement> {
return transformCall(call, data) return transformCall(call, data)
} }
@@ -62,6 +62,7 @@ import org.jetbrains.kotlin.fir.expressions.FirConstExpression
import org.jetbrains.kotlin.fir.types.FirTypeProjection import org.jetbrains.kotlin.fir.types.FirTypeProjection
import org.jetbrains.kotlin.fir.types.FirStarProjection import org.jetbrains.kotlin.fir.types.FirStarProjection
import org.jetbrains.kotlin.fir.types.FirTypeProjectionWithVariance import org.jetbrains.kotlin.fir.types.FirTypeProjectionWithVariance
import org.jetbrains.kotlin.fir.expressions.FirArgumentList
import org.jetbrains.kotlin.fir.expressions.FirCall import org.jetbrains.kotlin.fir.expressions.FirCall
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.FirOperatorCall import org.jetbrains.kotlin.fir.expressions.FirOperatorCall
@@ -240,6 +241,8 @@ abstract class FirVisitor<out R, in D> {
open fun visitTypeProjectionWithVariance(typeProjectionWithVariance: FirTypeProjectionWithVariance, data: D): R = visitElement(typeProjectionWithVariance, data) open fun visitTypeProjectionWithVariance(typeProjectionWithVariance: FirTypeProjectionWithVariance, data: D): R = visitElement(typeProjectionWithVariance, data)
open fun visitArgumentList(argumentList: FirArgumentList, data: D): R = visitElement(argumentList, data)
open fun visitCall(call: FirCall, data: D): R = visitElement(call, data) open fun visitCall(call: FirCall, data: D): R = visitElement(call, data)
open fun visitAnnotationCall(annotationCall: FirAnnotationCall, data: D): R = visitElement(annotationCall, data) open fun visitAnnotationCall(annotationCall: FirAnnotationCall, data: D): R = visitElement(annotationCall, data)
@@ -62,6 +62,7 @@ import org.jetbrains.kotlin.fir.expressions.FirConstExpression
import org.jetbrains.kotlin.fir.types.FirTypeProjection import org.jetbrains.kotlin.fir.types.FirTypeProjection
import org.jetbrains.kotlin.fir.types.FirStarProjection import org.jetbrains.kotlin.fir.types.FirStarProjection
import org.jetbrains.kotlin.fir.types.FirTypeProjectionWithVariance import org.jetbrains.kotlin.fir.types.FirTypeProjectionWithVariance
import org.jetbrains.kotlin.fir.expressions.FirArgumentList
import org.jetbrains.kotlin.fir.expressions.FirCall import org.jetbrains.kotlin.fir.expressions.FirCall
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.FirOperatorCall import org.jetbrains.kotlin.fir.expressions.FirOperatorCall
@@ -352,6 +353,10 @@ abstract class FirVisitorVoid : FirVisitor<Unit, Nothing?>() {
visitElement(typeProjectionWithVariance) visitElement(typeProjectionWithVariance)
} }
open fun visitArgumentList(argumentList: FirArgumentList) {
visitElement(argumentList)
}
open fun visitCall(call: FirCall) { open fun visitCall(call: FirCall) {
visitElement(call) visitElement(call)
} }
@@ -808,6 +813,10 @@ abstract class FirVisitorVoid : FirVisitor<Unit, Nothing?>() {
visitTypeProjectionWithVariance(typeProjectionWithVariance) visitTypeProjectionWithVariance(typeProjectionWithVariance)
} }
final override fun visitArgumentList(argumentList: FirArgumentList, data: Nothing?) {
visitArgumentList(argumentList)
}
final override fun visitCall(call: FirCall, data: Nothing?) { final override fun visitCall(call: FirCall, data: Nothing?) {
visitCall(call) visitCall(call)
} }
@@ -0,0 +1,51 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.fir.expressions
import org.jetbrains.kotlin.fir.FirElement
import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.expressions.builder.buildArgumentList
import org.jetbrains.kotlin.fir.visitors.FirTransformer
import org.jetbrains.kotlin.fir.visitors.FirVisitor
fun buildUnaryArgumentList(argument: FirExpression): FirArgumentList = buildArgumentList {
arguments += argument
}
fun buildBinaryArgumentList(left: FirExpression, right: FirExpression): FirArgumentList = buildArgumentList {
arguments += left
arguments += right
}
abstract class FirAbstractArgumentList : FirArgumentList() {
override val source: FirSourceElement?
get() = null
override fun <D> transformArguments(transformer: FirTransformer<D>, data: D): FirArgumentList {
return this
}
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
// DO NOTHING
}
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirElement {
return this
}
}
object FirEmptyArgumentList : FirAbstractArgumentList() {
override val arguments: List<FirExpression>
get() = emptyList()
}
class FirArraySetArgumentList(
private val rValue: FirExpression,
private val indexes: List<FirExpression>
) : FirAbstractArgumentList() {
override val arguments: List<FirExpression>
get() = indexes + rValue
}
@@ -34,7 +34,9 @@ fun <T> buildConstOrErrorExpression(source: FirSourceElement?, kind: FirConstKin
this.diagnostic = diagnostic this.diagnostic = diagnostic
} }
inline val FirCall.argument: FirExpression get() = arguments.first() inline val FirCall.arguments: List<FirExpression> get() = argumentList.arguments
inline val FirCall.argument: FirExpression get() = argumentList.arguments.first()
fun FirExpression.toResolvedCallableReference(): FirResolvedNamedReference? { fun FirExpression.toResolvedCallableReference(): FirResolvedNamedReference? {
return (this as? FirQualifiedAccess)?.calleeReference as? FirResolvedNamedReference return (this as? FirQualifiedAccess)?.calleeReference as? FirResolvedNamedReference
@@ -101,6 +101,10 @@ object BuilderConfigurator : AbstractBuilderConfigurator<FirTreeBuilder>(FirTree
builder(annotationCall) { builder(annotationCall) {
parents += callBuilder parents += callBuilder
default("argumentList") {
value = "FirEmptyArgumentList"
}
useTypes(emptyArgumentListType)
} }
builder(arrayOfCall) { builder(arrayOfCall) {
@@ -122,6 +126,10 @@ object BuilderConfigurator : AbstractBuilderConfigurator<FirTreeBuilder>(FirTree
builder(componentCall) { builder(componentCall) {
parents += callBuilder parents += callBuilder
default("argumentList") {
value = "FirEmptyArgumentList"
}
useTypes(emptyArgumentListType)
} }
builder(whileLoop) { builder(whileLoop) {
@@ -140,6 +148,10 @@ object BuilderConfigurator : AbstractBuilderConfigurator<FirTreeBuilder>(FirTree
builder(delegatedConstructorCall) { builder(delegatedConstructorCall) {
parents += callBuilder parents += callBuilder
default("argumentList") {
value = "FirEmptyArgumentList"
}
useTypes(emptyArgumentListType)
} }
builder(functionCall) { builder(functionCall) {
@@ -148,6 +160,10 @@ object BuilderConfigurator : AbstractBuilderConfigurator<FirTreeBuilder>(FirTree
defaultFalse("safe") defaultFalse("safe")
defaultNoReceivers() defaultNoReceivers()
openBuilder() openBuilder()
default("argumentList") {
value = "FirEmptyArgumentList"
}
useTypes(emptyArgumentListType)
} }
builder(qualifiedAccessExpression) { builder(qualifiedAccessExpression) {
@@ -172,6 +188,10 @@ object BuilderConfigurator : AbstractBuilderConfigurator<FirTreeBuilder>(FirTree
builder(typeOperatorCall) { builder(typeOperatorCall) {
parents += callBuilder parents += callBuilder
default("argumentList") {
value = "FirEmptyArgumentList"
}
useTypes(emptyArgumentListType)
} }
builder(stringConcatenationCall) { builder(stringConcatenationCall) {
@@ -76,6 +76,7 @@ object FirTreeBuilder : AbstractFirTreeBuilder() {
val typeProjection = element("TypeProjection", TypeRef) val typeProjection = element("TypeProjection", TypeRef)
val starProjection = element("StarProjection", TypeRef, typeProjection) val starProjection = element("StarProjection", TypeRef, typeProjection)
val typeProjectionWithVariance = element("TypeProjectionWithVariance", TypeRef, typeProjection) val typeProjectionWithVariance = element("TypeProjectionWithVariance", TypeRef, typeProjection)
val argumentList = element("ArgumentList", Expression)
val call = element("Call", Expression, statement) // TODO: may smth like `CallWithArguments` or `ElementWithArguments`? val call = element("Call", Expression, statement) // TODO: may smth like `CallWithArguments` or `ElementWithArguments`?
val annotationCall = element("AnnotationCall", Expression, expression, call) val annotationCall = element("AnnotationCall", Expression, expression, call)
val operatorCall = element("OperatorCall", Expression, expression, call) val operatorCall = element("OperatorCall", Expression, expression, call)
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.fir.tree.generator
import org.jetbrains.kotlin.fir.tree.generator.context.AbstractFirTreeImplementationConfigurator import org.jetbrains.kotlin.fir.tree.generator.context.AbstractFirTreeImplementationConfigurator
import org.jetbrains.kotlin.fir.tree.generator.model.Implementation.Kind.Object import org.jetbrains.kotlin.fir.tree.generator.model.Implementation.Kind.Object
import org.jetbrains.kotlin.fir.tree.generator.model.Implementation.Kind.OpenClass import org.jetbrains.kotlin.fir.tree.generator.model.Implementation.Kind.OpenClass
import org.jetbrains.kotlin.fir.tree.generator.model.Type
object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() { object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() {
fun configureImplementations() { fun configureImplementations() {
@@ -89,10 +88,6 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
impl(arraySetCall) { impl(arraySetCall) {
parents += modifiableQualifiedAccess parents += modifiableQualifiedAccess
default("arguments") {
value = "indexes + rValue"
withGetter = true
}
default("lValue") { default("lValue") {
value = "calleeReference" value = "calleeReference"
customSetter = "calleeReference = value" customSetter = "calleeReference = value"
@@ -174,7 +169,7 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
impl(getClassCall) { impl(getClassCall) {
default("argument") { default("argument") {
value = "arguments.first()" value = "argumentList.arguments.first()"
withGetter = true withGetter = true
} }
} }
@@ -105,10 +105,14 @@ object NodeConfigurator : AbstractFieldConfigurator<FirTreeBuilder>(FirTreeBuild
+annotations +annotations
} }
call.configure { argumentList.configure {
+arguments.withTransform() +arguments.withTransform()
} }
call.configure {
+field(argumentList, withReplace = true)
}
block.configure { block.configure {
+fieldList(statement).withTransform() +fieldList(statement).withTransform()
+typeRefField +typeRefField
@@ -60,7 +60,7 @@ val delegateFieldSymbolType = type("fir.symbols.impl", "FirDelegateFieldSymbol")
val classSymbolType = type("fir.symbols.impl", "FirClassSymbol") val classSymbolType = type("fir.symbols.impl", "FirClassSymbol")
val classLikeSymbolType = type("fir.symbols.impl", "FirClassLikeSymbol<*>") val classLikeSymbolType = type("fir.symbols.impl", "FirClassLikeSymbol<*>")
val typeParameterSymbolType = type("fir.symbols.impl", "FirTypeParameterSymbol") val typeParameterSymbolType = type("fir.symbols.impl", "FirTypeParameterSymbol")
val emptyArgumentListType = type("fir.expressions", "FirEmptyArgumentList")
val firScopeProviderType = type("fir.scopes", "FirScopeProvider") val firScopeProviderType = type("fir.scopes", "FirScopeProvider")
val pureAbstractElementType = generatedType("FirPureAbstractElement") val pureAbstractElementType = generatedType("FirPureAbstractElement")