[FIR] add vararg arguments support, improve vararg parameters support
This commit is contained in:
committed by
Mikhail Glukhikh
parent
069fbffaa3
commit
188abc243a
@@ -59,7 +59,7 @@ fun ConeKotlinType.toIrType(
|
||||
return when (this) {
|
||||
is ConeKotlinErrorType -> createErrorType()
|
||||
is ConeLookupTagBasedType -> {
|
||||
val irSymbol = getPrimitiveArrayType(this.classId, irBuiltIns) ?: run {
|
||||
val irSymbol = getArrayType(this.classId, irBuiltIns) ?: run {
|
||||
val firSymbol = this.lookupTag.toSymbol(session) ?: return createErrorType()
|
||||
firSymbol.toIrSymbol(session, declarationStorage)
|
||||
}
|
||||
@@ -87,8 +87,9 @@ fun ConeKotlinType.toIrType(
|
||||
}
|
||||
}
|
||||
|
||||
private fun getPrimitiveArrayType(classId: ClassId?, irBuiltIns: IrBuiltIns): IrClassifierSymbol? {
|
||||
private fun getArrayType(classId: ClassId?, irBuiltIns: IrBuiltIns): IrClassifierSymbol? {
|
||||
val irType = when (classId) {
|
||||
ClassId(FqName("kotlin"), FqName("Array"), false) -> return irBuiltIns.arrayClass
|
||||
ClassId(FqName("kotlin"), FqName("BooleanArray"), false) -> irBuiltIns.booleanType
|
||||
ClassId(FqName("kotlin"), FqName("ByteArray"), false) -> irBuiltIns.byteType
|
||||
ClassId(FqName("kotlin"), FqName("CharArray"), false) -> irBuiltIns.charType
|
||||
|
||||
+6
-1
@@ -23,7 +23,10 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.arrayElementType
|
||||
import org.jetbrains.kotlin.fir.types.coneTypeSafe
|
||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.*
|
||||
@@ -686,7 +689,9 @@ class Fir2IrDeclarationStorage(
|
||||
IrValueParameterImpl(
|
||||
startOffset, endOffset, origin, symbol,
|
||||
valueParameter.name, index, type,
|
||||
null, valueParameter.isCrossinline, valueParameter.isNoinline
|
||||
if (!valueParameter.isVararg) null
|
||||
else valueParameter.returnTypeRef.coneTypeSafe<ConeKotlinType>()?.arrayElementType(session)?.toIrType(session, this, irBuiltIns),
|
||||
valueParameter.isCrossinline, valueParameter.isNoinline
|
||||
).apply {
|
||||
descriptor.bind(this)
|
||||
if (valueParameter.defaultValue != null) {
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.jetbrains.kotlin.fir.visitors.FirDefaultVisitor
|
||||
import org.jetbrains.kotlin.fir.visitors.transformSingle
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.IrStatement
|
||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||
import org.jetbrains.kotlin.ir.builders.*
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFieldImpl
|
||||
@@ -674,6 +675,18 @@ class Fir2IrVisitor(
|
||||
return wrappedArgumentExpression.expression.toIrExpression()
|
||||
}
|
||||
|
||||
override fun visitVarargArgumentsExpression(varargArgumentsExpression: FirVarargArgumentsExpression, data: Any?): IrElement {
|
||||
val irReturnType = varargArgumentsExpression.typeRef.toIrType(session, declarationStorage)
|
||||
return IrVarargImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, irReturnType,
|
||||
varargArgumentsExpression.varargElementType.toIrType(session, declarationStorage),
|
||||
varargArgumentsExpression.arguments.map { arg ->
|
||||
arg.toIrExpression().run {
|
||||
if (arg is FirSpreadArgumentExpression) IrSpreadElementImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, this)
|
||||
else this
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun FirReference.statementOrigin(): IrStatementOrigin? {
|
||||
return when (this) {
|
||||
is FirPropertyFromParameterResolvedNamedReference -> IrStatementOrigin.INITIALIZE_PROPERTY_FROM_PARAMETER
|
||||
|
||||
+42
-8
@@ -9,6 +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.impl.FirFunctionCallImpl
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirVarargArgumentsExpressionImpl
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirResolvedCallableReferenceImpl
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirResolvedNamedReferenceImpl
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.Candidate
|
||||
@@ -32,6 +34,7 @@ import org.jetbrains.kotlin.fir.visitors.transformSingle
|
||||
import org.jetbrains.kotlin.types.AbstractTypeApproximator
|
||||
import org.jetbrains.kotlin.types.TypeApproximatorConfiguration
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
import java.lang.Math.min
|
||||
|
||||
class FirCallCompletionResultsWriterTransformer(
|
||||
override val session: FirSession,
|
||||
@@ -189,7 +192,36 @@ class FirCallCompletionResultsWriterTransformer(
|
||||
}
|
||||
else -> {
|
||||
resultType = typeRef.substituteTypeRef(subCandidate)
|
||||
result.transformArguments(this, subCandidate.createArgumentsMapping()).transformExplicitReceiver(integerApproximator, null)
|
||||
val vararg = subCandidate.argumentMapping?.values?.firstOrNull { it.isVararg }
|
||||
result.transformArguments(this, subCandidate.createArgumentsMapping()).apply {
|
||||
if (vararg != null && this is FirFunctionCallImpl) {
|
||||
// Create a FirVarargArgumentExpression for the vararg arguments
|
||||
val resolvedArrayType = vararg.returnTypeRef.substitute(subCandidate)
|
||||
val resolvedElementType = resolvedArrayType.arrayElementType(session)
|
||||
val varargArgument = FirVarargArgumentsExpressionImpl(
|
||||
null,
|
||||
vararg.returnTypeRef.withReplacedConeType(resolvedElementType)
|
||||
)
|
||||
varargArgument.replaceTypeRef(
|
||||
vararg.returnTypeRef.withReplacedConeType(
|
||||
vararg.returnTypeRef.substitute(
|
||||
subCandidate
|
||||
)
|
||||
)
|
||||
)
|
||||
var firstIndex = arguments.size
|
||||
for ((i, arg) in arguments.withIndex()) {
|
||||
if (subCandidate.argumentMapping!![arg]?.isVararg ?: false) {
|
||||
firstIndex = min(firstIndex, i)
|
||||
varargArgument.arguments.add(arg)
|
||||
}
|
||||
}
|
||||
for (arg in varargArgument.arguments) {
|
||||
arguments.remove(arg)
|
||||
}
|
||||
arguments.add(firstIndex, varargArgument)
|
||||
}
|
||||
}.transformExplicitReceiver(integerApproximator, null)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,14 +231,16 @@ class FirCallCompletionResultsWriterTransformer(
|
||||
).compose()
|
||||
}
|
||||
|
||||
private fun FirTypeRef.substitute(candidate: Candidate): ConeKotlinType =
|
||||
coneTypeUnsafe<ConeKotlinType>()
|
||||
.let { candidate.substitutor.substituteOrSelf(it) }
|
||||
.let { finalSubstitutor.substituteOrSelf(it) }
|
||||
|
||||
private fun Candidate.createArgumentsMapping(): ExpectedArgumentType? {
|
||||
return argumentMapping?.map { (argument, valueParameter) ->
|
||||
val expectedType = valueParameter.returnTypeRef.coneTypeUnsafe<ConeKotlinType>()
|
||||
.let { substitutor.substituteOrSelf(it) }
|
||||
.let { finalSubstitutor.substituteOrSelf(it) }
|
||||
|
||||
argument.expandArgument() to expectedType
|
||||
}
|
||||
val expectedType = valueParameter.returnTypeRef.substitute(this)
|
||||
argument.unwrapArgument() to expectedType
|
||||
}
|
||||
?.toMap()?.toExpectedType()
|
||||
}
|
||||
|
||||
@@ -330,7 +364,7 @@ private fun ExpectedArgumentType.getExpectedType(argument: FirExpression): ConeK
|
||||
private fun Map<FirExpression, ConeKotlinType>.toExpectedType(): ExpectedArgumentType = ExpectedArgumentType.ArgumentsMap(this)
|
||||
fun ConeKotlinType.toExpectedType(): ExpectedArgumentType = ExpectedArgumentType.ExpectedType(this)
|
||||
|
||||
private fun FirExpression.expandArgument(): FirExpression = when (this) {
|
||||
private fun FirExpression.unwrapArgument(): FirExpression = when (this) {
|
||||
is FirWrappedArgumentExpression -> expression
|
||||
else -> this
|
||||
}
|
||||
|
||||
+2
-1
@@ -122,7 +122,8 @@ class FirSyntheticCallGenerator(
|
||||
)
|
||||
val fakeCallElement = FirFunctionCallImpl(null).copy(calleeReference = reference, arguments = arguments)
|
||||
|
||||
return callCompleter.completeCall(fakeCallElement, expectedTypeRef).arguments[0] as FirCallableReferenceAccess?
|
||||
val argument = callCompleter.completeCall(fakeCallElement, expectedTypeRef).arguments[0]
|
||||
return ((argument as? FirVarargArgumentsExpression)?.arguments?.get(0) ?: argument) as FirCallableReferenceAccess?
|
||||
}
|
||||
|
||||
private fun generateCalleeReferenceWithCandidate(
|
||||
|
||||
@@ -17,7 +17,7 @@ FILE: default.kt
|
||||
R|/bar|(Int(1), Double(2.0), Boolean(true), String(my))
|
||||
<Inapplicable(PARAMETER_MAPPING_ERROR): [/bar]>#(Int(1), Boolean(true))
|
||||
R|/baz|(Int(1))
|
||||
R|/baz|(Int(1), String(my), String(yours))
|
||||
R|/baz|(Int(1), vararg(String(my), String(yours)))
|
||||
R|/baz|(Int(1), z = Boolean(true))
|
||||
<Inapplicable(INAPPLICABLE): [/baz]>#(Int(0), String(), Boolean(false))
|
||||
}
|
||||
|
||||
@@ -5,12 +5,12 @@ FILE: vararg.kt
|
||||
}
|
||||
public final fun test(): R|kotlin/Unit| {
|
||||
R|/foo|(Int(1))
|
||||
R|/foo|(Int(1), String())
|
||||
R|/foo|(Int(1), String(my), String(yours))
|
||||
R|/foo|(Int(1), *R|kotlin/arrayOf|<R|kotlin/String|>(String(my), String(yours)))
|
||||
R|/foo|(Int(1), vararg(String()))
|
||||
R|/foo|(Int(1), vararg(String(my), String(yours)))
|
||||
R|/foo|(Int(1), vararg(*R|kotlin/arrayOf|<R|kotlin/String|>(vararg(String(my), String(yours)))))
|
||||
<Inapplicable(INAPPLICABLE): [/foo]>#(String())
|
||||
<Inapplicable(INAPPLICABLE): [/foo]>#(Int(1), Int(2))
|
||||
R|/bar|(Int(1), z = Boolean(true), y = *R|kotlin/arrayOf|<R|kotlin/String|>(String(my), String(yours)))
|
||||
R|/bar|(Int(1), z = Boolean(true), vararg(y = *R|kotlin/arrayOf|<R|kotlin/String|>(vararg(String(my), String(yours)))))
|
||||
<Inapplicable(PARAMETER_MAPPING_ERROR): [/bar]>#(Int(0), z = Boolean(false), y = String(), y = String(other))
|
||||
<Inapplicable(PARAMETER_MAPPING_ERROR): [/bar]>#(Int(0), String(), Boolean(true))
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ FILE: postponedLambdas.kt
|
||||
public final inline fun foo(vararg x: R|kotlin/Array<kotlin/Any>|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun test(a: R|kotlin/Any|, b: R|kotlin/Any|, c: R|kotlin/Any|): R|kotlin/Unit| {
|
||||
R|/foo|(R|<local>/a|, foo@fun <anonymous>(): R|kotlin/String| <kind=UNKNOWN> {
|
||||
R|/foo|(vararg(R|<local>/a|, R|<local>/b|), foo@fun <anonymous>(): R|kotlin/String| <kind=UNKNOWN> {
|
||||
String()
|
||||
}
|
||||
, R|<local>/b|)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -45,6 +45,6 @@ FILE: enumEntryUse.kt
|
||||
R|/use|(Q|TestEnum|.R|/TestEnum.FIRST|)
|
||||
R|/useEnum|(Q|TestEnum|.R|/TestEnum.SECOND|)
|
||||
R|/useEnum|(Q|TestEnum|.R|/TestEnum.THIRD|)
|
||||
R|/useVararg|(Q|TestEnum|.R|/TestEnum.FIRST|, Q|TestEnum|.R|/TestEnum.SECOND|)
|
||||
R|/useVararg|(vararg(Q|TestEnum|.R|/TestEnum.FIRST|, Q|TestEnum|.R|/TestEnum.SECOND|))
|
||||
<Inapplicable(INAPPLICABLE): [/useVararg]>#(Int(1), Int(2), Int(3), Int(4), Int(5))
|
||||
}
|
||||
|
||||
@@ -5,5 +5,5 @@ FILE: vararg.kt
|
||||
}
|
||||
public final fun main(): R|kotlin/Unit| {
|
||||
R|/foo|()
|
||||
R|/foo|(String(!))
|
||||
R|/foo|(vararg(String(!)))
|
||||
}
|
||||
|
||||
+1
-1
@@ -61,7 +61,7 @@ FILE: problems2.kt
|
||||
|
||||
}
|
||||
public final fun test(): R|kotlin/Unit| {
|
||||
Q|Some|.R|/Some.WithPrimary.WithPrimary|(Int(42), R|kotlin/arrayOf|<R|kotlin/String|>(String(alpha), String(omega)))
|
||||
Q|Some|.R|/Some.WithPrimary.WithPrimary|(Int(42), R|kotlin/arrayOf|<R|kotlin/String|>(vararg(String(alpha), String(omega))))
|
||||
}
|
||||
public final class KonanTarget : R|kotlin/Any| {
|
||||
public constructor(name: R|kotlin/String|): R|KonanTarget| {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
FILE: addAllOnJavaCollection.kt
|
||||
public final fun foo(): R|kotlin/Unit| {
|
||||
lval y: R|kotlin/collections/List<kotlin/String>| = R|kotlin/collections/listOf|<R|kotlin/String|>(String(Alpha), String(Beta))
|
||||
lval y: R|kotlin/collections/List<kotlin/String>| = R|kotlin/collections/listOf|<R|kotlin/String|>(vararg(String(Alpha), String(Beta)))
|
||||
lval x: R|java/util/LinkedHashSet<kotlin/String>| = R|java/util/LinkedHashSet.LinkedHashSet|<R|kotlin/String|>().R|kotlin/apply|<R|java/util/LinkedHashSet<kotlin/String>|>(<L> = apply@fun R|java/util/LinkedHashSet<kotlin/String>|.<anonymous>(): R|kotlin/Unit| <kind=EXACTLY_ONCE> {
|
||||
this@R|special/anonymous|.R|FakeOverride<java/util/AbstractCollection.addAll: R|kotlin/Boolean|>|(R|<local>/y|)
|
||||
}
|
||||
|
||||
@@ -4,5 +4,5 @@ FILE: arrayInLocal.kt
|
||||
^convert R|<local>/paths|.R|kotlin/collections/toList|<R|kotlin/String|>().R|kotlin/collections/toTypedArray|<R|kotlin/String|>()
|
||||
}
|
||||
|
||||
R|<local>/convert|(String(1), String(2), String(3))
|
||||
R|<local>/convert|(vararg(String(1), String(2), String(3)))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
FILE: backingField.kt
|
||||
public final var myProperty: R|kotlin/collections/List<kotlin/Int>| = R|kotlin/collections/listOf|<R|kotlin/Int|>(Int(1), Int(2), Int(3))
|
||||
public final var myProperty: R|kotlin/collections/List<kotlin/Int>| = R|kotlin/collections/listOf|<R|kotlin/Int|>(vararg(Int(1), Int(2), Int(3)))
|
||||
public get(): R|kotlin/collections/List<kotlin/Int>| {
|
||||
^ F|/myProperty|.R|kotlin/collections/plus|<R|kotlin/Int|>(F|/myProperty|)
|
||||
}
|
||||
|
||||
@@ -7,31 +7,31 @@ FILE: topLevelResolve.kt
|
||||
lval c: R|kotlin/Char| = Char(a).R|kotlin/Char.plus|(Int(1))
|
||||
lval s: R|kotlin/String| = String(.).R|kotlin/String.plus|(String(..))
|
||||
lval ss: R|kotlin/String| = String().R|kotlin/String.plus|(Int(1))
|
||||
lval list: R|kotlin/collections/List<kotlin/Int>| = R|kotlin/collections/listOf|<R|kotlin/Int|>(Int(1), Int(2), Int(3)).R|kotlin/collections/plus|<R|kotlin/Int|>(Int(4))
|
||||
lval listAndList: R|kotlin/collections/List<kotlin/Int>| = R|kotlin/collections/listOf|<R|kotlin/Int|>(Int(4), Int(5), Int(6)).R|kotlin/collections/plus|<R|kotlin/Int|>(R|kotlin/collections/listOf|<R|kotlin/Int|>(Int(7), Int(8)))
|
||||
lval mutableList: R|kotlin/collections/List<kotlin/Int>| = R|kotlin/collections/mutableListOf|<R|kotlin/Int|>(Int(9), Int(10)).R|kotlin/collections/plus|<R|kotlin/Int|>(R|kotlin/collections/listOf|<R|kotlin/Int|>(Int(11), Int(12), Int(13)))
|
||||
lval setAndList: R|kotlin/collections/Set<kotlin/Int>| = R|kotlin/collections/setOf|<R|kotlin/Int|>(Int(0)).R|kotlin/collections/plus|<R|kotlin/Int|>(R|kotlin/collections/listOf|<R|kotlin/Int|>(Int(1), Int(2)))
|
||||
lval list: R|kotlin/collections/List<kotlin/Int>| = R|kotlin/collections/listOf|<R|kotlin/Int|>(vararg(Int(1), Int(2), Int(3))).R|kotlin/collections/plus|<R|kotlin/Int|>(Int(4))
|
||||
lval listAndList: R|kotlin/collections/List<kotlin/Int>| = R|kotlin/collections/listOf|<R|kotlin/Int|>(vararg(Int(4), Int(5), Int(6))).R|kotlin/collections/plus|<R|kotlin/Int|>(R|kotlin/collections/listOf|<R|kotlin/Int|>(vararg(Int(7), Int(8))))
|
||||
lval mutableList: R|kotlin/collections/List<kotlin/Int>| = R|kotlin/collections/mutableListOf|<R|kotlin/Int|>(vararg(Int(9), Int(10))).R|kotlin/collections/plus|<R|kotlin/Int|>(R|kotlin/collections/listOf|<R|kotlin/Int|>(vararg(Int(11), Int(12), Int(13))))
|
||||
lval setAndList: R|kotlin/collections/Set<kotlin/Int>| = R|kotlin/collections/setOf|<R|kotlin/Int|>(Int(0)).R|kotlin/collections/plus|<R|kotlin/Int|>(R|kotlin/collections/listOf|<R|kotlin/Int|>(vararg(Int(1), Int(2))))
|
||||
lval stringAndList: R|kotlin/String| = String().R|kotlin/String.plus|(R|kotlin/collections/emptyList|<R|kotlin/Boolean|>())
|
||||
lval map: R|kotlin/collections/Map<kotlin/String, kotlin/Int>| = R|kotlin/collections/mapOf|<R|kotlin/String|, R|kotlin/Int|>(String().R|kotlin/to|<R|kotlin/String|, R|kotlin/Int|>(Int(1)), String(.).R|kotlin/to|<R|kotlin/String|, R|kotlin/Int|>(Int(2))).R|kotlin/collections/plus|<R|kotlin/String|, R|kotlin/Int|>(String(..).R|kotlin/to|<R|kotlin/String|, R|kotlin/Int|>(Int(3)))
|
||||
lval map: R|kotlin/collections/Map<kotlin/String, kotlin/Int>| = R|kotlin/collections/mapOf|<R|kotlin/String|, R|kotlin/Int|>(String().R|kotlin/to|<R|kotlin/String|, R|kotlin/Int|>(Int(1)), String(.).R|kotlin/to|<R|kotlin/String|, R|kotlin/Int|>(Int(2)), vararg()).R|kotlin/collections/plus|<R|kotlin/String|, R|kotlin/Int|>(String(..).R|kotlin/to|<R|kotlin/String|, R|kotlin/Int|>(Int(3)))
|
||||
lval mapAndMap: R|kotlin/collections/Map<kotlin/String, kotlin/Int>| = R|kotlin/collections/mapOf|<R|kotlin/String|, R|kotlin/Int|>(String(-).R|kotlin/to|<R|kotlin/String|, R|kotlin/Int|>(Int(4))).R|kotlin/collections/plus|<R|kotlin/String|, R|kotlin/Int|>(R|kotlin/collections/mapOf|<R|kotlin/String|, R|kotlin/Int|>(String(_).R|kotlin/to|<R|kotlin/String|, R|kotlin/Int|>(Int(5))))
|
||||
}
|
||||
public final fun <T> id(arg: R|T|): R|T| {
|
||||
^id R|<local>/arg|
|
||||
}
|
||||
public final fun testMap(): R|kotlin/Unit| {
|
||||
lval first: R|kotlin/collections/List<kotlin/Int>| = R|kotlin/collections/listOf|<R|kotlin/Int|>(Int(1), Int(2), Int(3)).R|kotlin/collections/map|<R|kotlin/Int|, R|kotlin/Int|>(<L> = map@fun <anonymous>(it: R|kotlin/Int|): R|kotlin/Int| <kind=UNKNOWN> {
|
||||
lval first: R|kotlin/collections/List<kotlin/Int>| = R|kotlin/collections/listOf|<R|kotlin/Int|>(vararg(Int(1), Int(2), Int(3))).R|kotlin/collections/map|<R|kotlin/Int|, R|kotlin/Int|>(<L> = map@fun <anonymous>(it: R|kotlin/Int|): R|kotlin/Int| <kind=UNKNOWN> {
|
||||
R|<local>/it|.R|kotlin/Int.times|(Int(2))
|
||||
}
|
||||
)
|
||||
lval second: R|kotlin/collections/List<kotlin/Int>| = R|kotlin/intArrayOf|(Int(4), Int(5), Int(6)).R|kotlin/collections/map|<R|kotlin/Int|>(<L> = map@fun <anonymous>(it: R|kotlin/Int|): R|kotlin/Int| <kind=UNKNOWN> {
|
||||
lval second: R|kotlin/collections/List<kotlin/Int>| = R|kotlin/intArrayOf|(vararg(Int(4), Int(5), Int(6))).R|kotlin/collections/map|<R|kotlin/Int|>(<L> = map@fun <anonymous>(it: R|kotlin/Int|): R|kotlin/Int| <kind=UNKNOWN> {
|
||||
R|<local>/it|.R|kotlin/Int.times|(Int(2))
|
||||
}
|
||||
)
|
||||
lval withId: R|kotlin/collections/List<kotlin/Int>| = R|kotlin/collections/listOf|<R|kotlin/Int|>(Int(1), Int(2), Int(3)).R|kotlin/collections/map|<R|kotlin/Int|, R|kotlin/Int|>(<L> = map@fun <anonymous>(it: R|kotlin/Int|): R|kotlin/Int| <kind=UNKNOWN> {
|
||||
lval withId: R|kotlin/collections/List<kotlin/Int>| = R|kotlin/collections/listOf|<R|kotlin/Int|>(vararg(Int(1), Int(2), Int(3))).R|kotlin/collections/map|<R|kotlin/Int|, R|kotlin/Int|>(<L> = map@fun <anonymous>(it: R|kotlin/Int|): R|kotlin/Int| <kind=UNKNOWN> {
|
||||
R|/id|<R|kotlin/Int|>(R|<local>/it|)
|
||||
}
|
||||
)
|
||||
lval stringToInt: R|kotlin/collections/List<kotlin/Int>| = R|kotlin/collections/listOf|<R|kotlin/String|>(String(alpha), String(omega)).R|kotlin/collections/map|<R|kotlin/String|, R|kotlin/Int|>(<L> = map@fun <anonymous>(it: R|kotlin/String|): R|kotlin/Int| <kind=UNKNOWN> {
|
||||
lval stringToInt: R|kotlin/collections/List<kotlin/Int>| = R|kotlin/collections/listOf|<R|kotlin/String|>(vararg(String(alpha), String(omega))).R|kotlin/collections/map|<R|kotlin/String|, R|kotlin/Int|>(<L> = map@fun <anonymous>(it: R|kotlin/String|): R|kotlin/Int| <kind=UNKNOWN> {
|
||||
R|<local>/it|.R|kotlin/String.length|
|
||||
}
|
||||
)
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* 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.FirPureAbstractElement
|
||||
import org.jetbrains.kotlin.fir.FirSourceElement
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||
import org.jetbrains.kotlin.fir.visitors.*
|
||||
|
||||
/*
|
||||
* This file was generated automatically
|
||||
* DO NOT MODIFY IT MANUALLY
|
||||
*/
|
||||
|
||||
abstract class FirVarargArgumentsExpression : FirPureAbstractElement(), FirExpression {
|
||||
abstract override val source: FirSourceElement?
|
||||
abstract override val typeRef: FirTypeRef
|
||||
abstract override val annotations: List<FirAnnotationCall>
|
||||
abstract val arguments: List<FirExpression>
|
||||
abstract val varargElementType: FirTypeRef
|
||||
|
||||
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitVarargArgumentsExpression(this, data)
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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.FirAnnotationCall
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirVarargArgumentsExpression
|
||||
import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl
|
||||
import org.jetbrains.kotlin.fir.visitors.*
|
||||
|
||||
/*
|
||||
* This file was generated automatically
|
||||
* DO NOT MODIFY IT MANUALLY
|
||||
*/
|
||||
|
||||
class FirVarargArgumentsExpressionImpl(
|
||||
override val source: FirSourceElement?,
|
||||
override var varargElementType: FirTypeRef
|
||||
) : FirVarargArgumentsExpression(), FirAbstractAnnotatedElement {
|
||||
override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null)
|
||||
override val annotations: MutableList<FirAnnotationCall> = mutableListOf()
|
||||
override val arguments: MutableList<FirExpression> = mutableListOf()
|
||||
|
||||
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) }
|
||||
varargElementType.accept(visitor, data)
|
||||
}
|
||||
|
||||
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirVarargArgumentsExpressionImpl {
|
||||
typeRef = typeRef.transformSingle(transformer, data)
|
||||
annotations.transformInplace(transformer, data)
|
||||
arguments.transformInplace(transformer, data)
|
||||
varargElementType = varargElementType.transformSingle(transformer, data)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun replaceTypeRef(newTypeRef: FirTypeRef) {
|
||||
typeRef = newTypeRef
|
||||
}
|
||||
}
|
||||
@@ -92,6 +92,7 @@ import org.jetbrains.kotlin.fir.expressions.FirWrappedArgumentExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirLambdaArgumentExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirSpreadArgumentExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirNamedArgumentExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirVarargArgumentsExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier
|
||||
import org.jetbrains.kotlin.fir.expressions.FirResolvedReifiedParameterReference
|
||||
import org.jetbrains.kotlin.fir.expressions.FirReturnExpression
|
||||
@@ -474,6 +475,10 @@ abstract class FirTransformer<in D> : FirVisitor<CompositeTransformResult<FirEle
|
||||
return transformElement(namedArgumentExpression, data)
|
||||
}
|
||||
|
||||
open fun transformVarargArgumentsExpression(varargArgumentsExpression: FirVarargArgumentsExpression, data: D): CompositeTransformResult<FirStatement> {
|
||||
return transformElement(varargArgumentsExpression, data)
|
||||
}
|
||||
|
||||
open fun transformResolvedQualifier(resolvedQualifier: FirResolvedQualifier, data: D): CompositeTransformResult<FirStatement> {
|
||||
return transformElement(resolvedQualifier, data)
|
||||
}
|
||||
@@ -930,6 +935,10 @@ abstract class FirTransformer<in D> : FirVisitor<CompositeTransformResult<FirEle
|
||||
return transformNamedArgumentExpression(namedArgumentExpression, data)
|
||||
}
|
||||
|
||||
final override fun visitVarargArgumentsExpression(varargArgumentsExpression: FirVarargArgumentsExpression, data: D): CompositeTransformResult<FirStatement> {
|
||||
return transformVarargArgumentsExpression(varargArgumentsExpression, data)
|
||||
}
|
||||
|
||||
final override fun visitResolvedQualifier(resolvedQualifier: FirResolvedQualifier, data: D): CompositeTransformResult<FirStatement> {
|
||||
return transformResolvedQualifier(resolvedQualifier, data)
|
||||
}
|
||||
|
||||
@@ -92,6 +92,7 @@ import org.jetbrains.kotlin.fir.expressions.FirWrappedArgumentExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirLambdaArgumentExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirSpreadArgumentExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirNamedArgumentExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirVarargArgumentsExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier
|
||||
import org.jetbrains.kotlin.fir.expressions.FirResolvedReifiedParameterReference
|
||||
import org.jetbrains.kotlin.fir.expressions.FirReturnExpression
|
||||
@@ -300,6 +301,8 @@ abstract class FirVisitor<out R, in D> {
|
||||
|
||||
open fun visitNamedArgumentExpression(namedArgumentExpression: FirNamedArgumentExpression, data: D): R = visitElement(namedArgumentExpression, data)
|
||||
|
||||
open fun visitVarargArgumentsExpression(varargArgumentsExpression: FirVarargArgumentsExpression, data: D): R = visitElement(varargArgumentsExpression, data)
|
||||
|
||||
open fun visitResolvedQualifier(resolvedQualifier: FirResolvedQualifier, data: D): R = visitElement(resolvedQualifier, data)
|
||||
|
||||
open fun visitResolvedReifiedParameterReference(resolvedReifiedParameterReference: FirResolvedReifiedParameterReference, data: D): R = visitElement(resolvedReifiedParameterReference, data)
|
||||
|
||||
@@ -92,6 +92,7 @@ import org.jetbrains.kotlin.fir.expressions.FirWrappedArgumentExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirLambdaArgumentExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirSpreadArgumentExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirNamedArgumentExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirVarargArgumentsExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier
|
||||
import org.jetbrains.kotlin.fir.expressions.FirResolvedReifiedParameterReference
|
||||
import org.jetbrains.kotlin.fir.expressions.FirReturnExpression
|
||||
@@ -472,6 +473,10 @@ abstract class FirVisitorVoid : FirVisitor<Unit, Nothing?>() {
|
||||
visitElement(namedArgumentExpression)
|
||||
}
|
||||
|
||||
open fun visitVarargArgumentsExpression(varargArgumentsExpression: FirVarargArgumentsExpression) {
|
||||
visitElement(varargArgumentsExpression)
|
||||
}
|
||||
|
||||
open fun visitResolvedQualifier(resolvedQualifier: FirResolvedQualifier) {
|
||||
visitElement(resolvedQualifier)
|
||||
}
|
||||
@@ -928,6 +933,10 @@ abstract class FirVisitorVoid : FirVisitor<Unit, Nothing?>() {
|
||||
visitNamedArgumentExpression(namedArgumentExpression)
|
||||
}
|
||||
|
||||
final override fun visitVarargArgumentsExpression(varargArgumentsExpression: FirVarargArgumentsExpression, data: Nothing?) {
|
||||
visitVarargArgumentsExpression(varargArgumentsExpression)
|
||||
}
|
||||
|
||||
final override fun visitResolvedQualifier(resolvedQualifier: FirResolvedQualifier, data: Nothing?) {
|
||||
visitResolvedQualifier(resolvedQualifier)
|
||||
}
|
||||
|
||||
@@ -659,6 +659,12 @@ class FirRenderer(builder: StringBuilder) : FirVisitorVoid() {
|
||||
lambdaArgumentExpression.expression.accept(this)
|
||||
}
|
||||
|
||||
override fun visitVarargArgumentsExpression(varargArgumentsExpression: FirVarargArgumentsExpression) {
|
||||
print("vararg(")
|
||||
varargArgumentsExpression.arguments.renderSeparated()
|
||||
print(")")
|
||||
}
|
||||
|
||||
override fun visitCall(call: FirCall) {
|
||||
print("(")
|
||||
call.arguments.renderSeparated()
|
||||
|
||||
+1
@@ -107,6 +107,7 @@ object FirTreeBuilder : AbstractFirTreeBuilder() {
|
||||
val lambdaArgumentExpression = element("LambdaArgumentExpression", Expression, wrappedArgumentExpression)
|
||||
val spreadArgumentExpression = element("SpreadArgumentExpression", Expression, wrappedArgumentExpression)
|
||||
val namedArgumentExpression = element("NamedArgumentExpression", Expression, wrappedArgumentExpression)
|
||||
val varargArgumentsExpression = element("VarargArgumentsExpression", Expression, expression)
|
||||
|
||||
val resolvedQualifier = element("ResolvedQualifier", Expression, expression)
|
||||
val resolvedReifiedParameterReference = element("ResolvedReifiedParameterReference", Expression, expression)
|
||||
|
||||
+5
@@ -426,6 +426,11 @@ object NodeConfigurator : AbstractFieldConfigurator<FirTreeBuilder>(FirTreeBuild
|
||||
+name
|
||||
}
|
||||
|
||||
varargArgumentsExpression.configure {
|
||||
+fieldList("arguments", expression)
|
||||
+field("varargElementType", typeRef)
|
||||
}
|
||||
|
||||
resolvedQualifier.configure {
|
||||
+field("packageFqName", fqNameType)
|
||||
+field("relativeClassFqName", fqNameType, nullable = true)
|
||||
|
||||
Reference in New Issue
Block a user