diff --git a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/components/KtFirCallResolver.kt b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/components/KtFirCallResolver.kt index 1ec6171aa10..6ae824e8153 100644 --- a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/components/KtFirCallResolver.kt +++ b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/components/KtFirCallResolver.kt @@ -48,7 +48,6 @@ import org.jetbrains.kotlin.fir.references.* import org.jetbrains.kotlin.fir.resolve.calls.AbstractCandidate import org.jetbrains.kotlin.fir.resolve.calls.Candidate import org.jetbrains.kotlin.fir.resolve.createConeDiagnosticForCandidateWithError -import org.jetbrains.kotlin.fir.expressions.unwrapSmartcastExpression import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeDiagnosticWithCandidates import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeHiddenCandidateError import org.jetbrains.kotlin.fir.resolve.fullyExpandedType @@ -790,9 +789,8 @@ internal class KtFirCallResolver( } private fun FirExpression.toKtReceiverValue(): KtReceiverValue? { - val psi = psi - return when (this) { - is FirSmartCastExpression -> { + return when { + this is FirSmartCastExpression -> { val result = originalExpression.toKtReceiverValue() if (result != null && isStable) { KtSmartCastedReceiverValue(result, smartcastType.coneType.asKtType()) @@ -800,21 +798,17 @@ internal class KtFirCallResolver( result } } - is FirThisReceiverExpression -> { - if (psi == null) { - val implicitPartiallyAppliedSymbol = when (val partiallyAppliedSymbol = calleeReference.boundSymbol) { - is FirClassSymbol<*> -> partiallyAppliedSymbol.toKtSymbol() - is FirCallableSymbol<*> -> firSymbolBuilder.callableBuilder.buildExtensionReceiverSymbol(partiallyAppliedSymbol) - ?: return null - else -> return null - } - KtImplicitReceiverValue(implicitPartiallyAppliedSymbol, typeRef.coneType.asKtType()) - } else { - if (psi !is KtExpression) return null - psi.toExplicitReceiverValue(typeRef.coneType.asKtType()) + this is FirThisReceiverExpression && this.isImplicit -> { + val implicitPartiallyAppliedSymbol = when (val partiallyAppliedSymbol = calleeReference.boundSymbol) { + is FirClassSymbol<*> -> partiallyAppliedSymbol.toKtSymbol() + is FirCallableSymbol<*> -> firSymbolBuilder.callableBuilder.buildExtensionReceiverSymbol(partiallyAppliedSymbol) + ?: return null + else -> return null } + KtImplicitReceiverValue(implicitPartiallyAppliedSymbol, typeRef.coneType.asKtType()) } else -> { + val psi = psi if (psi !is KtExpression) return null psi.toExplicitReceiverValue(typeRef.coneType.asKtType()) } diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt index a912d66b304..5b606c81d18 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt @@ -92,6 +92,12 @@ internal fun FirQualifiedAccessExpression.convertWithOffsets( return convertWithOffsets(this.calleeReference, f) } +internal fun FirThisReceiverExpression.convertWithOffsets( + f: (startOffset: Int, endOffset: Int) -> T +): T { + return source.convertWithOffsets(f) +} + internal fun FirStatement.convertWithOffsets( calleeReference: FirReference, f: (startOffset: Int, endOffset: Int) -> T diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeSteppingTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeSteppingTestGenerated.java index 5403b642f48..ba61c8d7621 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeSteppingTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeSteppingTestGenerated.java @@ -247,6 +247,18 @@ public class FirLightTreeSteppingTestGenerated extends AbstractFirLightTreeStepp runTest("compiler/testData/debug/stepping/iincStepping.kt"); } + @Test + @TestMetadata("implicitThis.kt") + public void testImplicitThis() throws Exception { + runTest("compiler/testData/debug/stepping/implicitThis.kt"); + } + + @Test + @TestMetadata("implicitThisOnInvoke.kt") + public void testImplicitThisOnInvoke() throws Exception { + runTest("compiler/testData/debug/stepping/implicitThisOnInvoke.kt"); + } + @Test @TestMetadata("inTheEndOfLambdaArgumentOfInlineCall.kt") public void testInTheEndOfLambdaArgumentOfInlineCall() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiSteppingTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiSteppingTestGenerated.java index 2cab1594591..ddf501ae4dc 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiSteppingTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiSteppingTestGenerated.java @@ -247,6 +247,18 @@ public class FirPsiSteppingTestGenerated extends AbstractFirPsiSteppingTest { runTest("compiler/testData/debug/stepping/iincStepping.kt"); } + @Test + @TestMetadata("implicitThis.kt") + public void testImplicitThis() throws Exception { + runTest("compiler/testData/debug/stepping/implicitThis.kt"); + } + + @Test + @TestMetadata("implicitThisOnInvoke.kt") + public void testImplicitThisOnInvoke() throws Exception { + runTest("compiler/testData/debug/stepping/implicitThisOnInvoke.kt"); + } + @Test @TestMetadata("inTheEndOfLambdaArgumentOfInlineCall.kt") public void testInTheEndOfLambdaArgumentOfInlineCall() throws Exception { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt index 1f7d6418b50..87b08053180 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt @@ -99,6 +99,11 @@ class FirCallResolver( // We need desugaring val resultFunctionCall = if (candidate != null && candidate.callInfo != result.info) { + // This branch support case for the call of the type `a.invoke()` + // 1. Handle candidate for `a` + (resolvedReceiver?.calleeReference as? FirNamedReferenceWithCandidate)?.candidate?.updateSourcesOfReceivers() + // 2. Handle candidate for `invoke` + candidate.updateSourcesOfReceivers() functionCall.copyAsImplicitInvokeCall { explicitReceiver = candidate.callInfo.explicitReceiver dispatchReceiver = candidate.dispatchReceiverExpression() @@ -107,6 +112,7 @@ class FirCallResolver( contextReceiverArguments.addAll(candidate.contextReceiverArguments()) } } else { + candidate?.updateSourcesOfReceivers() functionCall } val typeRef = components.typeFromCallee(resultFunctionCall) @@ -344,6 +350,7 @@ class FirCallResolver( qualifiedAccess.replaceCalleeReference(nameReference) if (reducedCandidates.size == 1) { val candidate = reducedCandidates.single() + candidate.updateSourcesOfReceivers() qualifiedAccess.apply { replaceDispatchReceiver(candidate.dispatchReceiverExpression()) replaceExtensionReceiver(candidate.chosenExtensionReceiverExpression()) @@ -419,6 +426,7 @@ class FirCallResolver( } val chosenCandidate = reducedCandidates.single() + chosenCandidate.updateSourcesOfReceivers() constraintSystemBuilder.runTransaction { chosenCandidate.outerConstraintBuilderEffect!!(this) @@ -596,6 +604,7 @@ class FirCallResolver( return call.apply { call.replaceCalleeReference(nameReference) val singleCandidate = reducedCandidates.singleOrNull() + singleCandidate?.updateSourcesOfReceivers() if (singleCandidate != null) { val symbol = singleCandidate.symbol if (symbol is FirConstructorSymbol && symbol.fir.isInner) { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Candidate.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Candidate.kt index fc759f8b92a..011ad3ed6b2 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Candidate.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Candidate.kt @@ -5,8 +5,12 @@ package org.jetbrains.kotlin.fir.resolve.calls +import org.jetbrains.kotlin.KtFakeSourceElementKind +import org.jetbrains.kotlin.fakeElement +import org.jetbrains.kotlin.fir.FirElement import org.jetbrains.kotlin.fir.declarations.FirValueParameter -import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.* +import org.jetbrains.kotlin.fir.expressions.builder.buildThisReceiverExpressionCopy import org.jetbrains.kotlin.fir.expressions.impl.FirExpressionStub import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression import org.jetbrains.kotlin.fir.resolve.inference.InferenceComponents @@ -16,6 +20,7 @@ import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.fir.types.ConeTypeVariable +import org.jetbrains.kotlin.fir.visitors.FirTransformer import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemOperation import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintSystemError @@ -103,16 +108,46 @@ class Candidate( var passedStages: Int = 0 - // FirExpressionStub can be located here in case of callable reference resolution - fun dispatchReceiverExpression(): FirExpression = - dispatchReceiver?.takeIf { it !is FirExpressionStub } ?: FirNoReceiverExpression + private var sourcesWereUpdated = false // FirExpressionStub can be located here in case of callable reference resolution - fun chosenExtensionReceiverExpression(): FirExpression = - chosenExtensionReceiver?.takeIf { it !is FirExpressionStub } ?: FirNoReceiverExpression + fun dispatchReceiverExpression(): FirExpression { + return dispatchReceiver?.takeIf { it !is FirExpressionStub } ?: FirNoReceiverExpression + } - fun contextReceiverArguments(): List = - contextReceiverArguments ?: emptyList() + // FirExpressionStub can be located here in case of callable reference resolution + fun chosenExtensionReceiverExpression(): FirExpression { + return chosenExtensionReceiver?.takeIf { it !is FirExpressionStub } ?: FirNoReceiverExpression + } + + fun contextReceiverArguments(): List { + return contextReceiverArguments ?: emptyList() + } + + // In case of implicit receivers we want to update corresponding sources to generate correct offset. This method must be called only + // once when candidate was selected and confirmed to be correct one. + fun updateSourcesOfReceivers() { + require(!sourcesWereUpdated) + sourcesWereUpdated = true + + dispatchReceiver = dispatchReceiver?.tryToSetSourceForImplicitReceiver() + chosenExtensionReceiver = chosenExtensionReceiver?.tryToSetSourceForImplicitReceiver() + contextReceiverArguments = contextReceiverArguments?.map { it.tryToSetSourceForImplicitReceiver() } + } + + private fun FirExpression.tryToSetSourceForImplicitReceiver(): FirExpression { + return when { + this is FirSmartCastExpression -> { + this.apply { replaceOriginalExpression(this.originalExpression.tryToSetSourceForImplicitReceiver()) } + } + this is FirThisReceiverExpression && isImplicit -> { + buildThisReceiverExpressionCopy(this) { + source = callInfo.callSite.source?.fakeElement(KtFakeSourceElementKind.ImplicitReceiver) + } + } + else -> this + } + } var hasVisibleBackingField = false diff --git a/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/dfa/VariableStorageImpl.kt b/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/dfa/VariableStorageImpl.kt index 7ac652bda0d..2f9c44c2cea 100644 --- a/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/dfa/VariableStorageImpl.kt +++ b/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/dfa/VariableStorageImpl.kt @@ -144,13 +144,13 @@ class VariableStorageImpl(private val session: FirSession) : VariableStorage() { } private fun FirBasedSymbol<*>.getStability(originalFir: FirElement): PropertyStability? { + if (originalFir is FirThisReceiverExpression) return PropertyStability.STABLE_VALUE when (this) { is FirAnonymousObjectSymbol -> return null is FirFunctionSymbol<*>, is FirClassSymbol<*>, is FirBackingFieldSymbol -> return PropertyStability.STABLE_VALUE } - if (originalFir is FirThisReceiverExpression) return PropertyStability.STABLE_VALUE if (this !is FirVariableSymbol<*>) return null if (this is FirFieldSymbol && !this.isFinal) return PropertyStability.MUTABLE_PROPERTY diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirSmartCastExpression.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirSmartCastExpression.kt index 040fd1a0199..df354e22298 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirSmartCastExpression.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirSmartCastExpression.kt @@ -38,6 +38,8 @@ abstract class FirSmartCastExpression : FirExpression() { abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) + abstract fun replaceOriginalExpression(newOriginalExpression: FirExpression) + abstract override fun transformAnnotations(transformer: FirTransformer, data: D): FirSmartCastExpression abstract fun transformOriginalExpression(transformer: FirTransformer, data: D): FirSmartCastExpression diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirThisReceiverExpressionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirThisReceiverExpressionBuilder.kt index 15926360b02..852f5a8e059 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirThisReceiverExpressionBuilder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirThisReceiverExpressionBuilder.kt @@ -84,3 +84,19 @@ inline fun buildThisReceiverExpression(init: FirThisReceiverExpressionBuilder.() } return FirThisReceiverExpressionBuilder().apply(init).build() } + +@OptIn(ExperimentalContracts::class) +inline fun buildThisReceiverExpressionCopy(original: FirThisReceiverExpression, init: FirThisReceiverExpressionBuilder.() -> Unit): FirThisReceiverExpression { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + val copyBuilder = FirThisReceiverExpressionBuilder() + copyBuilder.typeRef = original.typeRef + copyBuilder.annotations.addAll(original.annotations) + copyBuilder.contextReceiverArguments.addAll(original.contextReceiverArguments) + copyBuilder.typeArguments.addAll(original.typeArguments) + copyBuilder.source = original.source + copyBuilder.calleeReference = original.calleeReference + copyBuilder.isImplicit = original.isImplicit + return copyBuilder.apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirSmartCastExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirSmartCastExpressionImpl.kt index 5f2923d4a20..d2e36441e79 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirSmartCastExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirSmartCastExpressionImpl.kt @@ -69,4 +69,8 @@ internal class FirSmartCastExpressionImpl( override fun replaceTypeRef(newTypeRef: FirTypeRef) { typeRef = newTypeRef } + + override fun replaceOriginalExpression(newOriginalExpression: FirExpression) { + originalExpression = newOriginalExpression + } } diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/BuilderConfigurator.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/BuilderConfigurator.kt index c4653c73b67..dfe1f22fa58 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/BuilderConfigurator.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/BuilderConfigurator.kt @@ -257,6 +257,7 @@ object BuilderConfigurator : AbstractBuilderConfigurator(FirTree builder(thisReceiverExpression) { parents += qualifiedAccessExpressionBuilder default("isImplicit", "false") + withCopy() } builder(thisReference, "FirExplicitThisReference") { diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt index dbacfc60535..41bbb3e632b 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt @@ -562,7 +562,7 @@ object NodeConfigurator : AbstractFieldConfigurator(FirTreeBuild smartCastExpression.configure { +typeRefField - +field("originalExpression", expression).withTransform() + +field("originalExpression", expression, withReplace = true).withTransform() +field("typesFromSmartCast", "Collection", null, customType = coneKotlinTypeType) +field("smartcastType", typeRef) +field("smartcastTypeWithoutNullableNothing", typeRef, nullable = true) diff --git a/compiler/testData/codegen/bytecodeText/coroutines/debug/localVariableCorrectLabel.kt b/compiler/testData/codegen/bytecodeText/coroutines/debug/localVariableCorrectLabel.kt index 8ddd4c23c39..ec2ecfdab77 100644 --- a/compiler/testData/codegen/bytecodeText/coroutines/debug/localVariableCorrectLabel.kt +++ b/compiler/testData/codegen/bytecodeText/coroutines/debug/localVariableCorrectLabel.kt @@ -20,5 +20,3 @@ suspend fun SequenceScope.awaitSeq(): Int = 42 // JVM_TEMPLATES // 1 LINENUMBER 9 L18 // 1 LOCALVARIABLE a I L[0-9]+ L18 - -// IGNORE_BACKEND_K2: JVM_IR diff --git a/compiler/testData/debug/localVariables/receiverMangling/labeledThisParameterLabel.kt b/compiler/testData/debug/localVariables/receiverMangling/labeledThisParameterLabel.kt index 11e7a6ed067..2959aa158d4 100644 --- a/compiler/testData/debug/localVariables/receiverMangling/labeledThisParameterLabel.kt +++ b/compiler/testData/debug/localVariables/receiverMangling/labeledThisParameterLabel.kt @@ -1,5 +1,5 @@ -// IGNORE_BACKEND_K2_LIGHT_TREE: JVM_IR -// Reason: KT-56755 + + // FILE: test.kt fun blockFun(blockArg: String.() -> Unit) = "OK".blockArg() diff --git a/compiler/testData/debug/localVariables/receiverMangling/simpleCapturedReceiver.kt b/compiler/testData/debug/localVariables/receiverMangling/simpleCapturedReceiver.kt index 11e7a6ed067..2959aa158d4 100644 --- a/compiler/testData/debug/localVariables/receiverMangling/simpleCapturedReceiver.kt +++ b/compiler/testData/debug/localVariables/receiverMangling/simpleCapturedReceiver.kt @@ -1,5 +1,5 @@ -// IGNORE_BACKEND_K2_LIGHT_TREE: JVM_IR -// Reason: KT-56755 + + // FILE: test.kt fun blockFun(blockArg: String.() -> Unit) = "OK".blockArg() diff --git a/compiler/testData/debug/localVariables/receiverMangling/simpleCapturedReceiverWithLabel.kt b/compiler/testData/debug/localVariables/receiverMangling/simpleCapturedReceiverWithLabel.kt index 7446fa41231..feb6d28072e 100644 --- a/compiler/testData/debug/localVariables/receiverMangling/simpleCapturedReceiverWithLabel.kt +++ b/compiler/testData/debug/localVariables/receiverMangling/simpleCapturedReceiverWithLabel.kt @@ -1,5 +1,5 @@ -// IGNORE_BACKEND_K2_LIGHT_TREE: JVM_IR -// Reason: KT-56755 + + // FILE: test.kt fun blockFun(blockArg: String.() -> Unit) = "OK".blockArg() diff --git a/compiler/testData/debug/localVariables/receiverMangling/simpleCapturedReceiverWithParenthesis.kt b/compiler/testData/debug/localVariables/receiverMangling/simpleCapturedReceiverWithParenthesis.kt index 901ef63654e..78b6db52518 100644 --- a/compiler/testData/debug/localVariables/receiverMangling/simpleCapturedReceiverWithParenthesis.kt +++ b/compiler/testData/debug/localVariables/receiverMangling/simpleCapturedReceiverWithParenthesis.kt @@ -1,5 +1,5 @@ -// IGNORE_BACKEND_K2_LIGHT_TREE: JVM_IR -// Reason: KT-56755 + + // FILE: test.kt fun blockFun(blockArg: String.() -> Unit) = "OK".blockArg() diff --git a/compiler/testData/debug/stepping/implicitThis.kt b/compiler/testData/debug/stepping/implicitThis.kt new file mode 100644 index 00000000000..2c0e6c33730 --- /dev/null +++ b/compiler/testData/debug/stepping/implicitThis.kt @@ -0,0 +1,68 @@ +// FILE: test.kt + +fun box() { + A().test() +} + +class A { + fun test() { + //Breakpoint! + foo() + prop + prop = 2 + } + + companion object { + private fun foo() { + val a = 1 + } + + private var prop: Int = 2 + get() { + return 1 + } + set(i: Int) { + field = i + } + } +} + +// EXPECTATIONS JVM JVM_IR +// test.kt:4 box +// test.kt:20 +// test.kt:15 +// test.kt:20 +// test.kt:20 +// test.kt:4 box + +// test.kt:7 +// test.kt:4 box +// test.kt:10 test +// test.kt:17 foo +// test.kt:18 foo +// test.kt:11 test +// test.kt:22 getProp +// test.kt:11 test +// test.kt:12 test +// test.kt:25 setProp +// test.kt:26 setProp +// test.kt:13 test +// test.kt:5 box + +// EXPECTATIONS JS_IR +// test.kt:4 box +// test.kt:7 +// test.kt:20 +// test.kt:15 +// test.kt:7 +// test.kt:4 box +// test.kt:10 test +// test.kt:10 test +// test.kt:17 foo +// test.kt:18 foo +// test.kt:11 test +// test.kt:11 test +// test.kt:22 +// test.kt:12 test +// test.kt:13 test +// test.kt:5 box diff --git a/compiler/testData/debug/stepping/implicitThisOnInvoke.kt b/compiler/testData/debug/stepping/implicitThisOnInvoke.kt new file mode 100644 index 00000000000..8c62fd155fd --- /dev/null +++ b/compiler/testData/debug/stepping/implicitThisOnInvoke.kt @@ -0,0 +1,45 @@ +// FILE: test.kt + +fun box() { + test(B(A())) +} + +class A + +class B(val a: A) { + operator fun A.invoke() {} +} + +fun test(b: B) { + with(b) { + a() + } +} + +// EXPECTATIONS JVM JVM_IR +// test.kt:4 box +// test.kt:7 +// test.kt:4 box +// test.kt:9 +// test.kt:4 box +// test.kt:14 test + +// test.kt:15 test +// test.kt:9 getA +// test.kt:15 test +// test.kt:10 invoke +// test.kt:16 test +// test.kt:14 test +// test.kt:17 test +// test.kt:5 box + +// EXPECTATIONS JS_IR +// test.kt:4 box +// test.kt:7 +// test.kt:4 box +// test.kt:9 +// test.kt:9 +// test.kt:4 box +// test.kt:10 invoke +// test.kt:17 test +// test.kt:5 box diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrSteppingWithBytecodeInlinerTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrSteppingWithBytecodeInlinerTestGenerated.java index e6a10f1c466..a69ab2012f9 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrSteppingWithBytecodeInlinerTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrSteppingWithBytecodeInlinerTestGenerated.java @@ -247,6 +247,18 @@ public class IrSteppingWithBytecodeInlinerTestGenerated extends AbstractIrSteppi runTest("compiler/testData/debug/stepping/iincStepping.kt"); } + @Test + @TestMetadata("implicitThis.kt") + public void testImplicitThis() throws Exception { + runTest("compiler/testData/debug/stepping/implicitThis.kt"); + } + + @Test + @TestMetadata("implicitThisOnInvoke.kt") + public void testImplicitThisOnInvoke() throws Exception { + runTest("compiler/testData/debug/stepping/implicitThisOnInvoke.kt"); + } + @Test @TestMetadata("inTheEndOfLambdaArgumentOfInlineCall.kt") public void testInTheEndOfLambdaArgumentOfInlineCall() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrSteppingWithIrInlinerTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrSteppingWithIrInlinerTestGenerated.java index b984aa13acc..93139bdb342 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrSteppingWithIrInlinerTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrSteppingWithIrInlinerTestGenerated.java @@ -247,6 +247,18 @@ public class IrSteppingWithIrInlinerTestGenerated extends AbstractIrSteppingWith runTest("compiler/testData/debug/stepping/iincStepping.kt"); } + @Test + @TestMetadata("implicitThis.kt") + public void testImplicitThis() throws Exception { + runTest("compiler/testData/debug/stepping/implicitThis.kt"); + } + + @Test + @TestMetadata("implicitThisOnInvoke.kt") + public void testImplicitThisOnInvoke() throws Exception { + runTest("compiler/testData/debug/stepping/implicitThisOnInvoke.kt"); + } + @Test @TestMetadata("inTheEndOfLambdaArgumentOfInlineCall.kt") public void testInTheEndOfLambdaArgumentOfInlineCall() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/SteppingTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/SteppingTestGenerated.java index a781d13ca33..8b5fcbdd75e 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/SteppingTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/SteppingTestGenerated.java @@ -247,6 +247,18 @@ public class SteppingTestGenerated extends AbstractSteppingTest { runTest("compiler/testData/debug/stepping/iincStepping.kt"); } + @Test + @TestMetadata("implicitThis.kt") + public void testImplicitThis() throws Exception { + runTest("compiler/testData/debug/stepping/implicitThis.kt"); + } + + @Test + @TestMetadata("implicitThisOnInvoke.kt") + public void testImplicitThisOnInvoke() throws Exception { + runTest("compiler/testData/debug/stepping/implicitThisOnInvoke.kt"); + } + @Test @TestMetadata("inTheEndOfLambdaArgumentOfInlineCall.kt") public void testInTheEndOfLambdaArgumentOfInlineCall() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsSteppingTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsSteppingTestGenerated.java index d499eadc2ed..06830f30d84 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsSteppingTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsSteppingTestGenerated.java @@ -247,6 +247,18 @@ public class IrJsSteppingTestGenerated extends AbstractIrJsSteppingTest { runTest("compiler/testData/debug/stepping/iincStepping.kt"); } + @Test + @TestMetadata("implicitThis.kt") + public void testImplicitThis() throws Exception { + runTest("compiler/testData/debug/stepping/implicitThis.kt"); + } + + @Test + @TestMetadata("implicitThisOnInvoke.kt") + public void testImplicitThisOnInvoke() throws Exception { + runTest("compiler/testData/debug/stepping/implicitThisOnInvoke.kt"); + } + @Test @TestMetadata("inTheEndOfLambdaArgumentOfInlineCall.kt") public void testInTheEndOfLambdaArgumentOfInlineCall() throws Exception {