KT-10670: Debugger: Evaluate Expression/Watches fail for inline function parameter initialized with default value
#KT-10670 Fixed
This commit is contained in:
@@ -2425,7 +2425,8 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
private CallGenerator getOrCreateCallGenerator(
|
private CallGenerator getOrCreateCallGenerator(
|
||||||
@NotNull CallableDescriptor descriptor,
|
@NotNull CallableDescriptor descriptor,
|
||||||
@Nullable KtElement callElement,
|
@Nullable KtElement callElement,
|
||||||
@Nullable TypeParameterMappings typeParameterMappings
|
@Nullable TypeParameterMappings typeParameterMappings,
|
||||||
|
boolean isDefaultCompilation
|
||||||
) {
|
) {
|
||||||
if (callElement == null) return defaultCallGenerator;
|
if (callElement == null) return defaultCallGenerator;
|
||||||
|
|
||||||
@@ -2437,12 +2438,12 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
if (!isInline) return defaultCallGenerator;
|
if (!isInline) return defaultCallGenerator;
|
||||||
|
|
||||||
FunctionDescriptor original = DescriptorUtils.unwrapFakeOverride((FunctionDescriptor) descriptor.getOriginal());
|
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
|
@NotNull
|
||||||
protected CallGenerator getOrCreateCallGeneratorForDefaultImplBody(@NotNull FunctionDescriptor descriptor, @Nullable KtNamedFunction function) {
|
protected CallGenerator getOrCreateCallGeneratorForDefaultImplBody(@NotNull FunctionDescriptor descriptor, @Nullable KtNamedFunction function) {
|
||||||
return getOrCreateCallGenerator(descriptor, function, null);
|
return getOrCreateCallGenerator(descriptor, function, null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -2473,8 +2474,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return getOrCreateCallGenerator(
|
return getOrCreateCallGenerator(
|
||||||
resolvedCall.getResultingDescriptor(), resolvedCall.getCall().getCallElement(), mappings
|
resolvedCall.getResultingDescriptor(), resolvedCall.getCall().getCallElement(), mappings, false);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ public class InlineCodegen extends CallGenerator {
|
|||||||
|
|
||||||
private final ReifiedTypeInliner reifiedTypeInliner;
|
private final ReifiedTypeInliner reifiedTypeInliner;
|
||||||
@Nullable private final TypeParameterMappings typeParameterMappings;
|
@Nullable private final TypeParameterMappings typeParameterMappings;
|
||||||
|
private final boolean isDefaultCompilation;
|
||||||
|
|
||||||
private LambdaInfo activeLambda;
|
private LambdaInfo activeLambda;
|
||||||
|
|
||||||
@@ -95,11 +96,12 @@ public class InlineCodegen extends CallGenerator {
|
|||||||
@NotNull GenerationState state,
|
@NotNull GenerationState state,
|
||||||
@NotNull FunctionDescriptor function,
|
@NotNull FunctionDescriptor function,
|
||||||
@NotNull KtElement callElement,
|
@NotNull KtElement callElement,
|
||||||
@Nullable TypeParameterMappings typeParameterMappings
|
@Nullable TypeParameterMappings typeParameterMappings,
|
||||||
|
boolean isDefaultCompilation
|
||||||
) {
|
) {
|
||||||
assert InlineUtil.isInline(function) || InlineUtil.isArrayConstructorWithLambda(function) :
|
assert InlineUtil.isInline(function) || InlineUtil.isArrayConstructorWithLambda(function) :
|
||||||
"InlineCodegen can inline only inline functions and array constructors: " + function;
|
"InlineCodegen can inline only inline functions and array constructors: " + function;
|
||||||
|
this.isDefaultCompilation = isDefaultCompilation;
|
||||||
this.state = state;
|
this.state = state;
|
||||||
this.typeMapper = state.getTypeMapper();
|
this.typeMapper = state.getTypeMapper();
|
||||||
this.codegen = codegen;
|
this.codegen = codegen;
|
||||||
@@ -274,7 +276,7 @@ public class InlineCodegen extends CallGenerator {
|
|||||||
|
|
||||||
InliningContext info = new RootInliningContext(
|
InliningContext info = new RootInliningContext(
|
||||||
expressionMap, state, codegen.getInlineNameGenerator().subGenerator(jvmSignature.getAsmMethod().getName()),
|
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,
|
MethodInliner inliner = new MethodInliner(node, parameters, info, new FieldRemapper(null, null, parameters), isSameModule,
|
||||||
|
|||||||
@@ -370,7 +370,10 @@ public class MethodInliner {
|
|||||||
@NotNull String name, @NotNull String desc, String signature, @NotNull Label start, @NotNull Label end, int index
|
@NotNull String name, @NotNull String desc, String signature, @NotNull Label start, @NotNull Label end, int index
|
||||||
) {
|
) {
|
||||||
if (isInliningLambda || InlineCodegenUtil.GENERATE_SMAP) {
|
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;
|
String varName = !varSuffix.isEmpty() && name.equals("this") ? name + "_" : name;
|
||||||
super.visitLocalVariable(varName + varSuffix, desc, signature, start, end, getNewIndex(index));
|
super.visitLocalVariable(varName + varSuffix, desc, signature, start, end, getNewIndex(index));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ public class RootInliningContext extends InliningContext {
|
|||||||
public final CodegenContext startContext;
|
public final CodegenContext startContext;
|
||||||
private final InlineCallSiteInfo inlineCallSiteInfo;
|
private final InlineCallSiteInfo inlineCallSiteInfo;
|
||||||
public final TypeParameterMappings typeParameterMappings;
|
public final TypeParameterMappings typeParameterMappings;
|
||||||
|
public final boolean isDefaultCompilation;
|
||||||
public final KtElement callElement;
|
public final KtElement callElement;
|
||||||
|
|
||||||
public RootInliningContext(
|
public RootInliningContext(
|
||||||
@@ -38,13 +39,15 @@ public class RootInliningContext extends InliningContext {
|
|||||||
@NotNull KtElement callElement,
|
@NotNull KtElement callElement,
|
||||||
@NotNull InlineCallSiteInfo classNameToInline,
|
@NotNull InlineCallSiteInfo classNameToInline,
|
||||||
@NotNull ReifiedTypeInliner inliner,
|
@NotNull ReifiedTypeInliner inliner,
|
||||||
@Nullable TypeParameterMappings typeParameterMappings
|
@Nullable TypeParameterMappings typeParameterMappings,
|
||||||
|
boolean isDefaultCompilation
|
||||||
) {
|
) {
|
||||||
super(null, map, state, nameGenerator, TypeRemapper.createRoot(typeParameterMappings), inliner, false, false);
|
super(null, map, state, nameGenerator, TypeRemapper.createRoot(typeParameterMappings), inliner, false, false);
|
||||||
this.callElement = callElement;
|
this.callElement = callElement;
|
||||||
this.startContext = startContext;
|
this.startContext = startContext;
|
||||||
this.inlineCallSiteInfo = classNameToInline;
|
this.inlineCallSiteInfo = classNameToInline;
|
||||||
this.typeParameterMappings = typeParameterMappings;
|
this.typeParameterMappings = typeParameterMappings;
|
||||||
|
this.isDefaultCompilation = isDefaultCompilation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
LineBreakpoint created at remappedParameterInInline.kt:7
|
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
|
!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'
|
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||||
remappedParameterInInline.kt:7
|
remappedParameterInInline.kt:7
|
||||||
Compile bytecode for p
|
Compile bytecode for p
|
||||||
|
remappedParameterInInline.kt:14
|
||||||
|
Compile bytecode for p
|
||||||
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||||
|
|
||||||
Process finished with exit code 0
|
Process finished with exit code 0
|
||||||
|
|||||||
+9
-1
@@ -7,8 +7,16 @@ inline fun watch(p: String, f: (String) -> Int) {
|
|||||||
f(p)
|
f(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline fun inlineDefault(p: Int = 1, f: (Int) -> Unit) {
|
||||||
|
// EXPRESSION: p
|
||||||
|
// RESULT: 1: I
|
||||||
|
//Breakpoint!
|
||||||
|
f(p)
|
||||||
|
}
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
val local = "mno"
|
val local = "mno"
|
||||||
watch(local) { it.length }
|
watch(local) { it.length }
|
||||||
}
|
|
||||||
|
|
||||||
|
inlineDefault { it }
|
||||||
|
}
|
||||||
+6
@@ -772,6 +772,12 @@ public class KotlinEvaluateExpressionTestGenerated extends AbstractKotlinEvaluat
|
|||||||
doMultipleBreakpointsTest(fileName);
|
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")
|
@TestMetadata("whenEntry.kt")
|
||||||
public void testWhenEntry() throws Exception {
|
public void testWhenEntry() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/whenEntry.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/whenEntry.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user