diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index 3fac79aa049..28f9a48719a 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -2425,7 +2425,8 @@ public class ExpressionCodegen extends KtVisitor impleme private CallGenerator getOrCreateCallGenerator( @NotNull CallableDescriptor descriptor, @Nullable KtElement callElement, - @Nullable TypeParameterMappings typeParameterMappings + @Nullable TypeParameterMappings typeParameterMappings, + boolean isDefaultCompilation ) { if (callElement == null) return defaultCallGenerator; @@ -2437,12 +2438,12 @@ public class ExpressionCodegen extends KtVisitor impleme if (!isInline) return defaultCallGenerator; FunctionDescriptor original = DescriptorUtils.unwrapFakeOverride((FunctionDescriptor) descriptor.getOriginal()); - return new InlineCodegen(this, state, original, callElement, typeParameterMappings); + return new InlineCodegen(this, state, original, callElement, typeParameterMappings, isDefaultCompilation); } @NotNull protected CallGenerator getOrCreateCallGeneratorForDefaultImplBody(@NotNull FunctionDescriptor descriptor, @Nullable KtNamedFunction function) { - return getOrCreateCallGenerator(descriptor, function, null); + return getOrCreateCallGenerator(descriptor, function, null, true); } @NotNull @@ -2473,8 +2474,7 @@ public class ExpressionCodegen extends KtVisitor impleme } } return getOrCreateCallGenerator( - resolvedCall.getResultingDescriptor(), resolvedCall.getCall().getCallElement(), mappings - ); + resolvedCall.getResultingDescriptor(), resolvedCall.getCall().getCallElement(), mappings, false); } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCodegen.java index 7626f1ef08f..103d2d04262 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCodegen.java @@ -85,6 +85,7 @@ public class InlineCodegen extends CallGenerator { private final ReifiedTypeInliner reifiedTypeInliner; @Nullable private final TypeParameterMappings typeParameterMappings; + private final boolean isDefaultCompilation; private LambdaInfo activeLambda; @@ -95,11 +96,12 @@ public class InlineCodegen extends CallGenerator { @NotNull GenerationState state, @NotNull FunctionDescriptor function, @NotNull KtElement callElement, - @Nullable TypeParameterMappings typeParameterMappings + @Nullable TypeParameterMappings typeParameterMappings, + boolean isDefaultCompilation ) { assert InlineUtil.isInline(function) || InlineUtil.isArrayConstructorWithLambda(function) : "InlineCodegen can inline only inline functions and array constructors: " + function; - + this.isDefaultCompilation = isDefaultCompilation; this.state = state; this.typeMapper = state.getTypeMapper(); this.codegen = codegen; @@ -274,7 +276,7 @@ public class InlineCodegen extends CallGenerator { InliningContext info = new RootInliningContext( expressionMap, state, codegen.getInlineNameGenerator().subGenerator(jvmSignature.getAsmMethod().getName()), - codegen.getContext(), callElement, getInlineCallSiteInfo(), reifiedTypeInliner, typeParameterMappings + codegen.getContext(), callElement, getInlineCallSiteInfo(), reifiedTypeInliner, typeParameterMappings, isDefaultCompilation ); MethodInliner inliner = new MethodInliner(node, parameters, info, new FieldRemapper(null, null, parameters), isSameModule, diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/MethodInliner.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/MethodInliner.java index f8bb0885bbb..1c8002071ce 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/MethodInliner.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/MethodInliner.java @@ -370,7 +370,10 @@ public class MethodInliner { @NotNull String name, @NotNull String desc, String signature, @NotNull Label start, @NotNull Label end, int index ) { if (isInliningLambda || InlineCodegenUtil.GENERATE_SMAP) { - String varSuffix = inliningContext.isRoot() && !InlineCodegenUtil.isFakeLocalVariableForInline(name) ? INLINE_FUN_VAR_SUFFIX : ""; + String varSuffix = inliningContext.isRoot() && + !((RootInliningContext) inliningContext).isDefaultCompilation && + !InlineCodegenUtil.isFakeLocalVariableForInline(name) ? + INLINE_FUN_VAR_SUFFIX : ""; String varName = !varSuffix.isEmpty() && name.equals("this") ? name + "_" : name; super.visitLocalVariable(varName + varSuffix, desc, signature, start, end, getNewIndex(index)); } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/RootInliningContext.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/RootInliningContext.java index 194a787ee4e..ebd44db9186 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/RootInliningContext.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/RootInliningContext.java @@ -28,6 +28,7 @@ public class RootInliningContext extends InliningContext { public final CodegenContext startContext; private final InlineCallSiteInfo inlineCallSiteInfo; public final TypeParameterMappings typeParameterMappings; + public final boolean isDefaultCompilation; public final KtElement callElement; public RootInliningContext( @@ -38,13 +39,15 @@ public class RootInliningContext extends InliningContext { @NotNull KtElement callElement, @NotNull InlineCallSiteInfo classNameToInline, @NotNull ReifiedTypeInliner inliner, - @Nullable TypeParameterMappings typeParameterMappings + @Nullable TypeParameterMappings typeParameterMappings, + boolean isDefaultCompilation ) { super(null, map, state, nameGenerator, TypeRemapper.createRoot(typeParameterMappings), inliner, false, false); this.callElement = callElement; this.startContext = startContext; this.inlineCallSiteInfo = classNameToInline; this.typeParameterMappings = typeParameterMappings; + this.isDefaultCompilation = isDefaultCompilation; } @Override diff --git a/idea/testData/debugger/tinyApp/outs/remappedParameterInInline.out b/idea/testData/debugger/tinyApp/outs/remappedParameterInInline.out index d02d5b11259..90073502a67 100644 --- a/idea/testData/debugger/tinyApp/outs/remappedParameterInInline.out +++ b/idea/testData/debugger/tinyApp/outs/remappedParameterInInline.out @@ -1,8 +1,11 @@ LineBreakpoint created at remappedParameterInInline.kt:7 +LineBreakpoint created at remappedParameterInInline.kt:14 !JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !OUTPUT_PATH!;!KOTLIN_RUNTIME!;!CUSTOM_LIBRARY!;!RT_JAR! remappedParameterInInline.RemappedParameterInInlineKt Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' remappedParameterInInline.kt:7 Compile bytecode for p +remappedParameterInInline.kt:14 +Compile bytecode for p Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' Process finished with exit code 0 diff --git a/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/remappedParameterInInline.kt b/idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/remappedParameterInInline.kt similarity index 63% rename from idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/remappedParameterInInline.kt rename to idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/remappedParameterInInline.kt index b82643834bc..7a40e9173ce 100644 --- a/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/remappedParameterInInline.kt +++ b/idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/remappedParameterInInline.kt @@ -7,8 +7,16 @@ inline fun watch(p: String, f: (String) -> Int) { f(p) } +inline fun inlineDefault(p: Int = 1, f: (Int) -> Unit) { + // EXPRESSION: p + // RESULT: 1: I + //Breakpoint! + f(p) +} + fun main(args: Array) { val local = "mno" watch(local) { it.length } -} + inlineDefault { it } +} diff --git a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionTestGenerated.java index ccb3c44a7b0..560a5bf2f3a 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionTestGenerated.java @@ -772,6 +772,12 @@ public class KotlinEvaluateExpressionTestGenerated extends AbstractKotlinEvaluat doMultipleBreakpointsTest(fileName); } + @TestMetadata("remappedParameterInInline.kt") + public void testRemappedParameterInInline() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/remappedParameterInInline.kt"); + doMultipleBreakpointsTest(fileName); + } + @TestMetadata("whenEntry.kt") public void testWhenEntry() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/whenEntry.kt");