[IR] Align captured receiver variable naming with old BE

This commit is contained in:
Kristoffer Andersen
2020-11-02 16:10:16 +01:00
committed by max-kammerer
parent 7732fc38e0
commit 5967e8295e
21 changed files with 176 additions and 46 deletions
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.backend.common.lower
import org.jetbrains.kotlin.backend.common.BodyLoweringPass
import org.jetbrains.kotlin.backend.common.CommonBackendContext
import org.jetbrains.kotlin.backend.common.descriptors.synthesizedName
import org.jetbrains.kotlin.backend.common.descriptors.synthesizedString
import org.jetbrains.kotlin.backend.common.ir.*
import org.jetbrains.kotlin.backend.common.runOnFilePostfix
@@ -765,18 +766,22 @@ class LocalDeclarationsLowering(
if (isSpecial) asString().substring(1, asString().length - 1) else asString()
private fun suggestNameForCapturedValue(declaration: IrValueDeclaration, usedNames: MutableSet<String>): Name {
if (declaration is IrValueParameter && declaration.name.asString() == "<this>") {
if (declaration.isDispatchReceiver()) {
if (declaration is IrValueParameter) {
if (declaration.name.asString() == "<this>" && declaration.isDispatchReceiver()) {
return findFirstUnusedName("this\$0", usedNames) {
"this\$$it"
}
} else if (declaration.isExtensionReceiver()) {
} else if (declaration.name.asString() == "<this>" && declaration.isExtensionReceiver()) {
val parentNameSuffix = declaration.parentNameSuffixForExtensionReceiver
return findFirstUnusedName("\$this_$parentNameSuffix", usedNames) {
"\$this_$parentNameSuffix\$$it"
}
} else if (declaration.isCapturedReceiver()) {
val baseName = declaration.name.asString().removePrefix(CAPTURED_RECEIVER_PREFIX)
return findFirstUnusedName("\$this_$baseName", usedNames) {
"\$this_$baseName\$$it"
}
}
// TODO captured extension receivers of extension lambdas?
}
val base = if (declaration.name.isSpecial)
declaration.name.stripSpecialMarkers()
@@ -810,6 +815,11 @@ class LocalDeclarationsLowering(
return parentFun.extensionReceiverParameter == this
}
private val CAPTURED_RECEIVER_PREFIX = "\$this\$"
private fun IrValueParameter.isCapturedReceiver(): Boolean =
name.asString().startsWith(CAPTURED_RECEIVER_PREFIX)
private val IrValueParameter.parentNameSuffixForExtensionReceiver: String
get() {
val parentFun = parent as? IrSimpleFunction
@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.psi2ir.generators
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
@@ -19,6 +20,8 @@ import org.jetbrains.kotlin.ir.expressions.impl.IrReturnImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrSetFieldImpl
import org.jetbrains.kotlin.ir.types.impl.IrUninitializedType
import org.jetbrains.kotlin.ir.util.declareSimpleFunctionWithOverrides
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.name.Name.isValidIdentifier
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.pureEndOffset
import org.jetbrains.kotlin.psi.psiUtil.pureStartOffset
@@ -26,6 +29,7 @@ import org.jetbrains.kotlin.psi2ir.isConstructorDelegatingToSuper
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator
import org.jetbrains.kotlin.resolve.descriptorUtil.isAnnotationConstructor
import org.jetbrains.kotlin.resolve.descriptorUtil.isEffectivelyExternal
@@ -328,17 +332,50 @@ class FunctionGenerator(declarationGenerator: DeclarationGenerator) : Declaratio
receiverParameterDescriptor: ReceiverParameterDescriptor,
ktElement: KtPureElement?,
irOwnerElement: IrElement
): IrValueParameter =
declareParameter(receiverParameterDescriptor, ktElement, irOwnerElement)
): IrValueParameter {
if (context.languageVersionSettings.supportsFeature(LanguageFeature.NewCapturedReceiverFieldNamingConvention)) {
if (ktElement is KtFunctionLiteral) {
val name = getCallLabelForLambdaArgument(ktElement, this.context.bindingContext)?.let {
it.takeIf(Name::isValidIdentifier) ?: "\$receiver"
}
return declareParameter(receiverParameterDescriptor, ktElement, irOwnerElement, name = Name.identifier("\$this\$$name"))
}
}
return declareParameter(receiverParameterDescriptor, ktElement, irOwnerElement)
}
private fun declareParameter(descriptor: ParameterDescriptor, ktElement: KtPureElement?, irOwnerElement: IrElement) =
private fun getCallLabelForLambdaArgument(declaration: KtFunctionLiteral, bindingContext: BindingContext): String? {
val lambdaExpression = declaration.parent as? KtLambdaExpression ?: return null
val lambdaExpressionParent = lambdaExpression.parent
if (lambdaExpressionParent is KtLabeledExpression) {
lambdaExpressionParent.name?.let { return it }
}
val callExpression = when (val argument = lambdaExpression.parent) {
is KtLambdaArgument -> {
argument.parent as? KtCallExpression ?: return null
}
is KtValueArgument -> {
val valueArgumentList = argument.parent as? KtValueArgumentList ?: return null
valueArgumentList.parent as? KtCallExpression ?: return null
}
else -> return null
}
val call = callExpression.getResolvedCall(bindingContext) ?: return null
return call.resultingDescriptor.name.asString()
}
private fun declareParameter(descriptor: ParameterDescriptor, ktElement: KtPureElement?, irOwnerElement: IrElement, name: Name? = null) =
context.symbolTable.declareValueParameter(
ktElement?.pureStartOffset ?: irOwnerElement.startOffset,
ktElement?.pureEndOffset ?: irOwnerElement.endOffset,
IrDeclarationOrigin.DEFINED,
descriptor, descriptor.type.toIrType(),
(descriptor as? ValueParameterDescriptor)?.varargElementType?.toIrType()
)
(descriptor as? ValueParameterDescriptor)?.varargElementType?.toIrType(),
name
)
private fun generateDefaultAnnotationParameterValue(
valueExpression: KtExpression,
@@ -31,6 +31,7 @@ import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
import org.jetbrains.kotlin.ir.symbols.*
import org.jetbrains.kotlin.ir.symbols.impl.*
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.descriptorUtil.isEffectivelyExternal
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DescriptorWithContainerSource
@@ -907,9 +908,10 @@ class SymbolTable(
descriptor: ParameterDescriptor,
type: IrType,
varargElementType: IrType? = null,
name: Name? = null,
valueParameterFactory: (IrValueParameterSymbol) -> IrValueParameter = {
irFactory.createValueParameter(
startOffset, endOffset, origin, it, nameProvider.nameForDeclaration(descriptor),
startOffset, endOffset, origin, it, name ?: nameProvider.nameForDeclaration(descriptor),
descriptor.indexOrMinusOne, type, varargElementType, descriptor.isCrossinline, descriptor.isNoinline, false
)
}
@@ -29,7 +29,7 @@ public final class CrossinlineKt$box$1$invokeSuspend$$inlined$filter$1$2$1 {
public final class CrossinlineKt$box$1$invokeSuspend$$inlined$filter$1$2 {
// source: 'crossinline.kt'
enclosing method CrossinlineKt$box$1$invokeSuspend$$inlined$filter$1.consume(LSink;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
synthetic final field $this_anonymous$inlined: Sink
synthetic final field $this_source$inlined: Sink
inner (anonymous) class CrossinlineKt$box$1$invokeSuspend$$inlined$filter$1$2
inner (anonymous) class CrossinlineKt$box$1$invokeSuspend$$inlined$filter$1$2$1
public method <init>(p0: Sink): void
@@ -147,7 +147,7 @@ public final class CrossinlineKt$filter$lambda-3$$inlined$consumeEach$1 {
// source: 'crossinline.kt'
enclosing method CrossinlineKt.filter(LSourceCrossinline;Lkotlin/jvm/functions/Function1;)LSourceCrossinline;
synthetic final field $predicate$inlined: kotlin.jvm.functions.Function1
synthetic final field $this_anonymous$inlined: Sink
synthetic final field $this_source$inlined: Sink
inner (anonymous) class CrossinlineKt$filter$lambda-3$$inlined$consumeEach$1
inner (anonymous) class CrossinlineKt$filter$lambda-3$$inlined$consumeEach$1$1
public method <init>(p0: kotlin.jvm.functions.Function1, p1: Sink): void
@@ -96,7 +96,7 @@ public final class TcoContinuationKt$foo$$inlined$map$1$2$1 {
public final class TcoContinuationKt$foo$$inlined$map$1$2 {
// source: 'tcoContinuation.kt'
enclosing method TcoContinuationKt$foo$$inlined$map$1.collect(LFlowCollector;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
synthetic final field $this_anonymous$inlined: FlowCollector
synthetic final field $this_flow$inlined: FlowCollector
inner (anonymous) class TcoContinuationKt$foo$$inlined$map$1$2
inner (anonymous) class TcoContinuationKt$foo$$inlined$map$1$2$1
public method <init>(p0: FlowCollector): void
@@ -143,7 +143,7 @@ public final class TcoContinuationKt$map$$inlined$transform$1$2$1 {
public final class TcoContinuationKt$map$$inlined$transform$1$2 {
// source: 'tcoContinuation.kt'
enclosing method TcoContinuationKt$map$$inlined$transform$1.collect(LFlowCollector;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
synthetic final field $this_anonymous$inlined: FlowCollector
synthetic final field $this_flow$inlined: FlowCollector
synthetic final field $transformer$inlined$1: kotlin.jvm.functions.Function2
inner (anonymous) class TcoContinuationKt$map$$inlined$transform$1$2
inner (anonymous) class TcoContinuationKt$map$$inlined$transform$1$2$1
@@ -206,7 +206,7 @@ public final class TcoContinuationKt$transform$lambda-1$$inlined$collect$1$1 {
public final class TcoContinuationKt$transform$lambda-1$$inlined$collect$1 {
// source: 'tcoContinuation.kt'
enclosing method TcoContinuationKt.transform(LFlow;Lkotlin/jvm/functions/Function3;)LFlow;
synthetic final field $this_anonymous$inlined: FlowCollector
synthetic final field $this_flow$inlined: FlowCollector
synthetic final field $transformer$inlined: kotlin.jvm.functions.Function3
inner (anonymous) class TcoContinuationKt$transform$lambda-1$$inlined$collect$1
inner (anonymous) class TcoContinuationKt$transform$lambda-1$$inlined$collect$1$1
@@ -0,0 +1,19 @@
// FILE: test.kt
fun foo(block: Long.() -> String): String {
return 1L.block()
}
fun box() {
foo {
"OK"
}
}
// LOCAL VARIABLES
// test.kt:8 box:
// test.kt:4 foo: block:kotlin.jvm.functions.Function1=TestKt$box$1
// test.kt:9 invoke: $this$foo:long=1:long
// test.kt:4 foo: block:kotlin.jvm.functions.Function1=TestKt$box$1
// test.kt:8 box:
// test.kt:11 box:
@@ -0,0 +1,13 @@
// FILE: test.kt
fun String.foo(a: Int) {}
fun box() {
"OK".foo(42)
}
// LOCAL VARIABLES
// test.kt:7 box:
// test.kt:4 foo: $this$foo:java.lang.String="OK":java.lang.String, a:int=42:int
// test.kt:8 box:
+1 -1
View File
@@ -22,7 +22,7 @@ FILE fqName:<root> fileName:/initValInLambda.kt
$receiver: CONST Int type=kotlin.Int value=1
block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<kotlin.Int, kotlin.Unit> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:kotlin.Int) returnType:kotlin.Unit
$receiver: VALUE_PARAMETER name:<this> type:kotlin.Int
$receiver: VALUE_PARAMETER name:$this$run type:kotlin.Int
BLOCK_BODY
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final]' type=kotlin.Unit origin=null
receiver: GET_VAR '<this>: <root>.TestInitValInLambdaCalledOnce declared in <root>.TestInitValInLambdaCalledOnce' type=<root>.TestInitValInLambdaCalledOnce origin=null
@@ -6,7 +6,7 @@ FILE fqName:<root> fileName:/lambdaInDataClassDefaultParameter.kt
EXPRESSION_BODY
FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function2<<root>.A, kotlin.String, kotlin.Unit> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:<root>.A, it:kotlin.String) returnType:kotlin.Unit
$receiver: VALUE_PARAMETER name:<this> type:<root>.A
$receiver: VALUE_PARAMETER name:$this$null type:<root>.A
VALUE_PARAMETER name:it index:0 type:kotlin.String
BLOCK_BODY
RETURN type=kotlin.Nothing from='local final fun <anonymous> (it: kotlin.String): kotlin.Unit declared in <root>.A.<init>'
@@ -18,7 +18,7 @@ FILE fqName:<root> fileName:/lambdas.kt
EXPRESSION_BODY
FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function2<kotlin.Any, kotlin.Any, kotlin.Int> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:kotlin.Any, it:kotlin.Any) returnType:kotlin.Int
$receiver: VALUE_PARAMETER name:<this> type:kotlin.Any
$receiver: VALUE_PARAMETER name:$this$null type:kotlin.Any
VALUE_PARAMETER name:it index:0 type:kotlin.Any
BLOCK_BODY
RETURN type=kotlin.Nothing from='local final fun <anonymous> (it: kotlin.Any): kotlin.Int declared in <root>.test2'
+2 -2
View File
@@ -26,11 +26,11 @@ FILE fqName:<root> fileName:/kt37570.kt
$receiver: CALL 'public final fun a (): kotlin.String declared in <root>' type=kotlin.String origin=null
block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<kotlin.String, kotlin.Unit> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:kotlin.String) returnType:kotlin.Unit
$receiver: VALUE_PARAMETER name:<this> type:kotlin.String
$receiver: VALUE_PARAMETER name:$this$apply type:kotlin.String
BLOCK_BODY
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.String visibility:private [final]' type=kotlin.Unit origin=null
receiver: GET_VAR '<this>: <root>.A declared in <root>.A' type=<root>.A origin=null
value: GET_VAR '<this>: kotlin.String declared in <root>.A.<anonymous>' type=kotlin.String origin=null
value: GET_VAR '$this$apply: kotlin.String declared in <root>.A.<anonymous>' type=kotlin.String origin=null
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
+2 -2
View File
@@ -61,12 +61,12 @@ FILE fqName:<root> fileName:/AllCandidates.kt
<R>: @[FlexibleNullability] A of <root>.allCandidatesResult?
block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<@[FlexibleNullability] <root>.OverloadResolutionResultsImpl<@[FlexibleNullability] A of <root>.allCandidatesResult?>?, kotlin.Unit> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:@[FlexibleNullability] <root>.OverloadResolutionResultsImpl<@[FlexibleNullability] A of <root>.allCandidatesResult?>?) returnType:kotlin.Unit
$receiver: VALUE_PARAMETER name:<this> type:@[FlexibleNullability] <root>.OverloadResolutionResultsImpl<@[FlexibleNullability] A of <root>.allCandidatesResult?>?
$receiver: VALUE_PARAMETER name:$this$apply type:@[FlexibleNullability] <root>.OverloadResolutionResultsImpl<@[FlexibleNullability] A of <root>.allCandidatesResult?>?
BLOCK_BODY
CALL 'public open fun setAllCandidates (allCandidates: @[FlexibleNullability] kotlin.collections.MutableCollection<@[FlexibleNullability] <root>.ResolvedCall<@[FlexibleNullability] D of <root>.OverloadResolutionResultsImpl?>?>?): kotlin.Unit declared in <root>.OverloadResolutionResultsImpl' type=kotlin.Unit origin=EQ
<1>: @[FlexibleNullability] A of <root>.allCandidatesResult?
$this: TYPE_OP type=<root>.OverloadResolutionResultsImpl<@[FlexibleNullability] A of <root>.allCandidatesResult?> origin=IMPLICIT_NOTNULL typeOperand=<root>.OverloadResolutionResultsImpl<@[FlexibleNullability] A of <root>.allCandidatesResult?>
GET_VAR '<this>: @[FlexibleNullability] <root>.OverloadResolutionResultsImpl<@[FlexibleNullability] A of <root>.allCandidatesResult?>? declared in <root>.allCandidatesResult.<anonymous>' type=@[FlexibleNullability] <root>.OverloadResolutionResultsImpl<@[FlexibleNullability] A of <root>.allCandidatesResult?>? origin=null
GET_VAR '$this$apply: @[FlexibleNullability] <root>.OverloadResolutionResultsImpl<@[FlexibleNullability] A of <root>.allCandidatesResult?>? declared in <root>.allCandidatesResult.<anonymous>' type=@[FlexibleNullability] <root>.OverloadResolutionResultsImpl<@[FlexibleNullability] A of <root>.allCandidatesResult?>? origin=null
allCandidates: CALL 'public final fun map <T, R> (transform: kotlin.Function1<T of kotlin.collections.map, R of kotlin.collections.map>): kotlin.collections.List<R of kotlin.collections.map> [inline] declared in kotlin.collections' type=kotlin.collections.List<<root>.ResolvedCall<A of <root>.allCandidatesResult>> origin=null
<T>: <root>.MyCandidate
<R>: <root>.ResolvedCall<A of <root>.allCandidatesResult>
+2 -2
View File
@@ -8,8 +8,8 @@ FILE fqName:<root> fileName:/extensionLambda.kt
$receiver: CONST String type=kotlin.String value="42"
block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<kotlin.String, kotlin.Int> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:kotlin.String) returnType:kotlin.Int
$receiver: VALUE_PARAMETER name:<this> type:kotlin.String
$receiver: VALUE_PARAMETER name:$this$run type:kotlin.String
BLOCK_BODY
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.Int declared in <root>.test1'
CALL 'public open fun <get-length> (): kotlin.Int declared in kotlin.String' type=kotlin.Int origin=GET_PROPERTY
$this: GET_VAR '<this>: kotlin.String declared in <root>.test1.<anonymous>' type=kotlin.String origin=null
$this: GET_VAR '$this$run: kotlin.String declared in <root>.test1.<anonymous>' type=kotlin.String origin=null
@@ -92,7 +92,7 @@ FILE fqName:<root> fileName:/multipleImplicitReceivers.kt
receiver: GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=<root>.A
block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<<root>.A, kotlin.Int> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:<root>.A) returnType:kotlin.Int
$receiver: VALUE_PARAMETER name:<this> type:<root>.A
$receiver: VALUE_PARAMETER name:$this$with type:<root>.A
BLOCK_BODY
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.Int declared in <root>.test'
CALL 'public final fun with <T, R> (receiver: T of kotlin.with, block: @[ExtensionFunctionType] kotlin.Function1<T of kotlin.with, R of kotlin.with>): R of kotlin.with [inline] declared in kotlin' type=kotlin.Int origin=null
@@ -101,7 +101,7 @@ FILE fqName:<root> fileName:/multipleImplicitReceivers.kt
receiver: GET_VAR 'fooImpl: <root>.IFoo declared in <root>.test' type=<root>.IFoo origin=null
block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<<root>.IFoo, kotlin.Int> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:<root>.IFoo) returnType:kotlin.Int
$receiver: VALUE_PARAMETER name:<this> type:<root>.IFoo
$receiver: VALUE_PARAMETER name:$this$with type:<root>.IFoo
BLOCK_BODY
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.Int declared in <root>.test.<anonymous>'
CALL 'public final fun with <T, R> (receiver: T of kotlin.with, block: @[ExtensionFunctionType] kotlin.Function1<T of kotlin.with, R of kotlin.with>): R of kotlin.with [inline] declared in kotlin' type=kotlin.Int origin=null
@@ -110,11 +110,11 @@ FILE fqName:<root> fileName:/multipleImplicitReceivers.kt
receiver: GET_VAR 'invokeImpl: <root>.IInvoke declared in <root>.test' type=<root>.IInvoke origin=null
block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<<root>.IInvoke, kotlin.Int> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:<root>.IInvoke) returnType:kotlin.Int
$receiver: VALUE_PARAMETER name:<this> type:<root>.IInvoke
$receiver: VALUE_PARAMETER name:$this$with type:<root>.IInvoke
BLOCK_BODY
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.Int declared in <root>.test.<anonymous>.<anonymous>'
CALL 'public open fun invoke (): kotlin.Int [operator] declared in <root>.IInvoke' type=kotlin.Int origin=INVOKE
$this: GET_VAR '<this>: <root>.IInvoke declared in <root>.test.<anonymous>.<anonymous>.<anonymous>' type=<root>.IInvoke origin=null
$this: GET_VAR '$this$with: <root>.IInvoke declared in <root>.test.<anonymous>.<anonymous>.<anonymous>' type=<root>.IInvoke origin=null
$receiver: CALL 'public open fun <get-foo> (): <root>.B declared in <root>.IFoo' type=<root>.B origin=GET_PROPERTY
$this: GET_VAR '<this>: <root>.IFoo declared in <root>.test.<anonymous>.<anonymous>' type=<root>.IFoo origin=null
$receiver: GET_VAR '<this>: <root>.A declared in <root>.test.<anonymous>' type=<root>.A origin=null
$this: GET_VAR '$this$with: <root>.IFoo declared in <root>.test.<anonymous>.<anonymous>' type=<root>.IFoo origin=null
$receiver: GET_VAR '$this$with: <root>.A declared in <root>.test.<anonymous>' type=<root>.A origin=null
+2 -2
View File
@@ -24,11 +24,11 @@ FILE fqName:<root> fileName:/builtinMap.kt
p0: GET_VAR '<this>: kotlin.collections.Map<out K1 of <root>.plus, V1 of <root>.plus> declared in <root>.plus' type=kotlin.collections.Map<out K1 of <root>.plus, V1 of <root>.plus> origin=null
block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<java.util.LinkedHashMap<@[FlexibleNullability] K1 of <root>.plus?, @[FlexibleNullability] V1 of <root>.plus?>{ kotlin.collections.LinkedHashMap<@[FlexibleNullability] K1 of <root>.plus?, @[FlexibleNullability] V1 of <root>.plus?> }, kotlin.Unit> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:java.util.LinkedHashMap<@[FlexibleNullability] K1 of <root>.plus?, @[FlexibleNullability] V1 of <root>.plus?>{ kotlin.collections.LinkedHashMap<@[FlexibleNullability] K1 of <root>.plus?, @[FlexibleNullability] V1 of <root>.plus?> }) returnType:kotlin.Unit
$receiver: VALUE_PARAMETER name:<this> type:java.util.LinkedHashMap<@[FlexibleNullability] K1 of <root>.plus?, @[FlexibleNullability] V1 of <root>.plus?>{ kotlin.collections.LinkedHashMap<@[FlexibleNullability] K1 of <root>.plus?, @[FlexibleNullability] V1 of <root>.plus?> }
$receiver: VALUE_PARAMETER name:$this$apply type:java.util.LinkedHashMap<@[FlexibleNullability] K1 of <root>.plus?, @[FlexibleNullability] V1 of <root>.plus?>{ kotlin.collections.LinkedHashMap<@[FlexibleNullability] K1 of <root>.plus?, @[FlexibleNullability] V1 of <root>.plus?> }
BLOCK_BODY
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
CALL 'public open fun put (key: @[EnhancedNullability] K of java.util.LinkedHashMap, value: @[EnhancedNullability] V of java.util.LinkedHashMap): @[EnhancedNullability] V of java.util.LinkedHashMap? [fake_override] declared in java.util.LinkedHashMap' type=@[EnhancedNullability] V1 of <root>.plus? origin=null
$this: GET_VAR '<this>: java.util.LinkedHashMap<@[FlexibleNullability] K1 of <root>.plus?, @[FlexibleNullability] V1 of <root>.plus?>{ kotlin.collections.LinkedHashMap<@[FlexibleNullability] K1 of <root>.plus?, @[FlexibleNullability] V1 of <root>.plus?> } declared in <root>.plus.<anonymous>' type=java.util.LinkedHashMap<@[FlexibleNullability] K1 of <root>.plus?, @[FlexibleNullability] V1 of <root>.plus?>{ kotlin.collections.LinkedHashMap<@[FlexibleNullability] K1 of <root>.plus?, @[FlexibleNullability] V1 of <root>.plus?> } origin=null
$this: GET_VAR '$this$apply: java.util.LinkedHashMap<@[FlexibleNullability] K1 of <root>.plus?, @[FlexibleNullability] V1 of <root>.plus?>{ kotlin.collections.LinkedHashMap<@[FlexibleNullability] K1 of <root>.plus?, @[FlexibleNullability] V1 of <root>.plus?> } declared in <root>.plus.<anonymous>' type=java.util.LinkedHashMap<@[FlexibleNullability] K1 of <root>.plus?, @[FlexibleNullability] V1 of <root>.plus?>{ kotlin.collections.LinkedHashMap<@[FlexibleNullability] K1 of <root>.plus?, @[FlexibleNullability] V1 of <root>.plus?> } origin=null
key: CALL 'public final fun <get-first> (): A of kotlin.Pair declared in kotlin.Pair' type=K1 of <root>.plus origin=GET_PROPERTY
$this: GET_VAR 'pair: kotlin.Pair<K1 of <root>.plus, V1 of <root>.plus> declared in <root>.plus' type=kotlin.Pair<K1 of <root>.plus, V1 of <root>.plus> origin=null
value: CALL 'public final fun <get-second> (): B of kotlin.Pair declared in kotlin.Pair' type=V1 of <root>.plus origin=GET_PROPERTY
@@ -12,19 +12,19 @@ FILE fqName:<root> fileName:/castsInsideCoroutineInference.kt
<T>: R of <root>.scopedFlow
block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction1<<root>.FlowCollector<R of <root>.scopedFlow>, kotlin.Unit> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:<root>.FlowCollector<R of <root>.scopedFlow>) returnType:kotlin.Unit [suspend]
$receiver: VALUE_PARAMETER name:<this> type:<root>.FlowCollector<R of <root>.scopedFlow>
$receiver: VALUE_PARAMETER name:$this$flow type:<root>.FlowCollector<R of <root>.scopedFlow>
BLOCK_BODY
VAR name:collector type:<root>.FlowCollector<R of <root>.scopedFlow> [val]
GET_VAR '<this>: <root>.FlowCollector<R of <root>.scopedFlow> declared in <root>.scopedFlow.<anonymous>' type=<root>.FlowCollector<R of <root>.scopedFlow> origin=null
GET_VAR '$this$flow: <root>.FlowCollector<R of <root>.scopedFlow> declared in <root>.scopedFlow.<anonymous>' type=<root>.FlowCollector<R of <root>.scopedFlow> origin=null
CALL 'public final fun flowScope <R> (block: @[ExtensionFunctionType] kotlin.coroutines.SuspendFunction1<<root>.CoroutineScope, R of <root>.flowScope>): R of <root>.flowScope [suspend] declared in <root>' type=kotlin.Unit origin=null
<R>: kotlin.Unit
block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction1<<root>.CoroutineScope, kotlin.Unit> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:<root>.CoroutineScope) returnType:kotlin.Unit [suspend]
$receiver: VALUE_PARAMETER name:<this> type:<root>.CoroutineScope
$receiver: VALUE_PARAMETER name:$this$flowScope type:<root>.CoroutineScope
BLOCK_BODY
CALL 'public abstract fun invoke (p1: P1 of kotlin.coroutines.SuspendFunction2, p2: P2 of kotlin.coroutines.SuspendFunction2): R of kotlin.coroutines.SuspendFunction2 [suspend,operator] declared in kotlin.coroutines.SuspendFunction2' type=kotlin.Unit origin=INVOKE
$this: GET_VAR 'block: @[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<<root>.CoroutineScope, <root>.FlowCollector<R of <root>.scopedFlow>, kotlin.Unit> declared in <root>.scopedFlow' type=@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<<root>.CoroutineScope, <root>.FlowCollector<R of <root>.scopedFlow>, kotlin.Unit> origin=VARIABLE_AS_FUNCTION
p1: GET_VAR '<this>: <root>.CoroutineScope declared in <root>.scopedFlow.<anonymous>.<anonymous>' type=<root>.CoroutineScope origin=null
p1: GET_VAR '$this$flowScope: <root>.CoroutineScope declared in <root>.scopedFlow.<anonymous>.<anonymous>' type=<root>.CoroutineScope origin=null
p2: GET_VAR 'val collector: <root>.FlowCollector<R of <root>.scopedFlow> [val] declared in <root>.scopedFlow.<anonymous>' type=<root>.FlowCollector<R of <root>.scopedFlow> origin=null
FUN name:onCompletion visibility:public modality:FINAL <T> ($receiver:<root>.Flow<T of <root>.onCompletion>, action:@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<<root>.FlowCollector<T of <root>.onCompletion>, @[ParameterName(name = 'cause')] kotlin.Throwable?, kotlin.Unit>) returnType:<root>.Flow<T of <root>.onCompletion>
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
@@ -36,12 +36,12 @@ FILE fqName:<root> fileName:/castsInsideCoroutineInference.kt
<T>: T of <root>.onCompletion
block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction1<<root>.FlowCollector<T of <root>.onCompletion>, kotlin.Unit> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:<root>.FlowCollector<T of <root>.onCompletion>) returnType:kotlin.Unit [suspend]
$receiver: VALUE_PARAMETER name:<this> type:<root>.FlowCollector<T of <root>.onCompletion>
$receiver: VALUE_PARAMETER name:$this$unsafeFlow type:<root>.FlowCollector<T of <root>.onCompletion>
BLOCK_BODY
VAR name:safeCollector type:<root>.SafeCollector<T of <root>.onCompletion> [val]
CONSTRUCTOR_CALL 'public constructor <init> (collector: <root>.FlowCollector<T of <root>.SafeCollector>) [primary] declared in <root>.SafeCollector' type=<root>.SafeCollector<T of <root>.onCompletion> origin=null
<class: T>: T of <root>.onCompletion
collector: GET_VAR '<this>: <root>.FlowCollector<T of <root>.onCompletion> declared in <root>.onCompletion.<anonymous>' type=<root>.FlowCollector<T of <root>.onCompletion> origin=null
collector: GET_VAR '$this$unsafeFlow: <root>.FlowCollector<T of <root>.onCompletion> declared in <root>.onCompletion.<anonymous>' type=<root>.FlowCollector<T of <root>.onCompletion> origin=null
CALL 'public final fun invokeSafely <T> (action: @[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<<root>.FlowCollector<T of <root>.invokeSafely>, @[ParameterName(name = 'cause')] kotlin.Throwable?, kotlin.Unit>): kotlin.Unit [suspend] declared in <root>' type=kotlin.Unit origin=null
<T>: T of <root>.onCompletion
$receiver: GET_VAR 'val safeCollector: <root>.SafeCollector<T of <root>.onCompletion> [val] declared in <root>.onCompletion.<anonymous>' type=<root>.SafeCollector<T of <root>.onCompletion> origin=null
@@ -73,7 +73,7 @@ FILE fqName:<root> fileName:/castsInsideCoroutineInference.kt
$receiver: GET_VAR '<this>: <root>.Flow<T of <root>.onCompletion> declared in <root>.onCompletion' type=<root>.Flow<T of <root>.onCompletion> origin=null
action: FUN_EXPR type=@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<<root>.FlowCollector<T of <root>.onCompletion>, @[ParameterName(name = 'cause')] kotlin.Throwable?, kotlin.Unit> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:<root>.FlowCollector<T of <root>.onCompletion>, it:kotlin.Throwable?) returnType:kotlin.Unit [suspend]
$receiver: VALUE_PARAMETER name:<this> type:<root>.FlowCollector<T of <root>.onCompletion>
$receiver: VALUE_PARAMETER name:$this$onCompletion type:<root>.FlowCollector<T of <root>.onCompletion>
VALUE_PARAMETER name:it index:0 type:kotlin.Throwable?
BLOCK_BODY
CALL 'public abstract fun invoke (p1: P1 of kotlin.coroutines.SuspendFunction1): R of kotlin.coroutines.SuspendFunction1 [suspend,operator] declared in kotlin.coroutines.SuspendFunction1' type=kotlin.Unit origin=INVOKE
@@ -89,12 +89,12 @@ FILE fqName:<root> fileName:/castsInsideCoroutineInference.kt
$receiver: GET_VAR '<this>: <root>.CoroutineScope declared in <root>.asFairChannel' type=<root>.CoroutineScope origin=null
block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction1<<root>.ProducerScope<kotlin.Any>, kotlin.Unit> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:<root>.ProducerScope<kotlin.Any>) returnType:kotlin.Unit [suspend]
$receiver: VALUE_PARAMETER name:<this> type:<root>.ProducerScope<kotlin.Any>
$receiver: VALUE_PARAMETER name:$this$produce type:<root>.ProducerScope<kotlin.Any>
BLOCK_BODY
VAR name:channel type:<root>.ChannelCoroutine<kotlin.Any> [val]
TYPE_OP type=<root>.ChannelCoroutine<kotlin.Any> origin=CAST typeOperand=<root>.ChannelCoroutine<kotlin.Any>
CALL 'public abstract fun <get-channel> (): <root>.SendChannel<E of <root>.ProducerScope> declared in <root>.ProducerScope' type=<root>.SendChannel<kotlin.Any> origin=GET_PROPERTY
$this: GET_VAR '<this>: <root>.ProducerScope<kotlin.Any> declared in <root>.asFairChannel.<anonymous>' type=<root>.ProducerScope<kotlin.Any> origin=null
$this: GET_VAR '$this$produce: <root>.ProducerScope<kotlin.Any> declared in <root>.asFairChannel.<anonymous>' type=<root>.ProducerScope<kotlin.Any> origin=null
CALL 'public final fun collect <T> (action: kotlin.coroutines.SuspendFunction1<@[ParameterName(name = 'value')] T of <root>.collect, kotlin.Unit>): kotlin.Unit [inline,suspend] declared in <root>' type=kotlin.Unit origin=null
<T>: kotlin.Any?
$receiver: GET_VAR 'flow: <root>.Flow<*> declared in <root>.asFairChannel' type=<root>.Flow<*> origin=null
@@ -127,7 +127,7 @@ FILE fqName:<root> fileName:/castsInsideCoroutineInference.kt
$receiver: GET_VAR '<this>: <root>.CoroutineScope declared in <root>.asChannel' type=<root>.CoroutineScope origin=null
block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction1<<root>.ProducerScope<kotlin.Any>, kotlin.Unit> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:<root>.ProducerScope<kotlin.Any>) returnType:kotlin.Unit [suspend]
$receiver: VALUE_PARAMETER name:<this> type:<root>.ProducerScope<kotlin.Any>
$receiver: VALUE_PARAMETER name:$this$produce type:<root>.ProducerScope<kotlin.Any>
BLOCK_BODY
CALL 'public final fun collect <T> (action: kotlin.coroutines.SuspendFunction1<@[ParameterName(name = 'value')] T of <root>.collect, kotlin.Unit>): kotlin.Unit [inline,suspend] declared in <root>' type=kotlin.Unit origin=null
<T>: kotlin.Any?
@@ -139,7 +139,7 @@ FILE fqName:<root> fileName:/castsInsideCoroutineInference.kt
RETURN type=kotlin.Nothing from='local final fun <anonymous> (value: kotlin.Any?): kotlin.Unit [suspend] declared in <root>.asChannel.<anonymous>'
CALL 'public abstract fun send (e: E of <root>.SendChannel): kotlin.Unit [suspend] declared in <root>.SendChannel' type=kotlin.Unit origin=null
$this: CALL 'public abstract fun <get-channel> (): <root>.SendChannel<E of <root>.ProducerScope> declared in <root>.ProducerScope' type=<root>.SendChannel<kotlin.Any> origin=GET_PROPERTY
$this: GET_VAR '<this>: <root>.ProducerScope<kotlin.Any> declared in <root>.asChannel.<anonymous>' type=<root>.ProducerScope<kotlin.Any> origin=null
$this: GET_VAR '$this$produce: <root>.ProducerScope<kotlin.Any> declared in <root>.asChannel.<anonymous>' type=<root>.ProducerScope<kotlin.Any> origin=null
e: BLOCK type=kotlin.Any origin=ELVIS
VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.Any? [val]
GET_VAR 'value: kotlin.Any? declared in <root>.asChannel.<anonymous>.<anonymous>' type=kotlin.Any? origin=null
@@ -67,6 +67,12 @@ public class IrLocalVariableTestGenerated extends AbstractIrLocalVariableTest {
runTest("compiler/testData/debug/localVariables/jvmOverloads.kt");
}
@Test
@TestMetadata("lambdaWithExtensionReceiver.kt")
public void testLambdaWithExtensionReceiver() throws Exception {
runTest("compiler/testData/debug/localVariables/lambdaWithExtensionReceiver.kt");
}
@Test
@TestMetadata("localFun.kt")
public void testLocalFun() throws Exception {
@@ -85,6 +91,26 @@ public class IrLocalVariableTestGenerated extends AbstractIrLocalVariableTest {
runTest("compiler/testData/debug/localVariables/underscoreNames.kt");
}
@TestMetadata("compiler/testData/debug/localVariables/receiverMangling")
@TestDataPath("$PROJECT_ROOT")
@RunWith(BlockJUnit4ClassRunner.class)
public static class ReceiverMangling extends AbstractIrLocalVariableTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath);
}
@Test
public void testAllFilesPresentInReceiverMangling() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/debug/localVariables/receiverMangling"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("compiler/testData/debug/localVariables/receiverMangling/simple.kt");
}
}
@TestMetadata("compiler/testData/debug/localVariables/suspend")
@TestDataPath("$PROJECT_ROOT")
@RunWith(BlockJUnit4ClassRunner.class)
@@ -67,6 +67,12 @@ public class LocalVariableTestGenerated extends AbstractLocalVariableTest {
runTest("compiler/testData/debug/localVariables/jvmOverloads.kt");
}
@Test
@TestMetadata("lambdaWithExtensionReceiver.kt")
public void testLambdaWithExtensionReceiver() throws Exception {
runTest("compiler/testData/debug/localVariables/lambdaWithExtensionReceiver.kt");
}
@Test
@TestMetadata("localFun.kt")
public void testLocalFun() throws Exception {
@@ -85,6 +91,26 @@ public class LocalVariableTestGenerated extends AbstractLocalVariableTest {
runTest("compiler/testData/debug/localVariables/underscoreNames.kt");
}
@TestMetadata("compiler/testData/debug/localVariables/receiverMangling")
@TestDataPath("$PROJECT_ROOT")
@RunWith(BlockJUnit4ClassRunner.class)
public static class ReceiverMangling extends AbstractLocalVariableTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
}
@Test
public void testAllFilesPresentInReceiverMangling() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/debug/localVariables/receiverMangling"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
}
@Test
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("compiler/testData/debug/localVariables/receiverMangling/simple.kt");
}
}
@TestMetadata("compiler/testData/debug/localVariables/suspend")
@TestDataPath("$PROJECT_ROOT")
@RunWith(BlockJUnit4ClassRunner.class)
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
LineBreakpoint created at thisLabels.kt:6
LineBreakpoint created at thisLabels.kt:8
LineBreakpoint created at thisLabels.kt:10
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
LineBreakpoint created at hideSyntheticThis.kt:6
Run Java
Connected to the target VM
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
LineBreakpoint created at lambdaAsValueArgument.kt:19
Run Java
Connected to the target VM