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