KT-10670: Debugger: Evaluate Expression/Watches fail for inline function parameter initialized with default value

#KT-10670 Fixed
This commit is contained in:
Michael Bogdanov
2016-01-25 17:15:22 +03:00
parent d4df7aaabc
commit dc2cb401ad
7 changed files with 36 additions and 11 deletions
@@ -2425,7 +2425,8 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> 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<StackValue, StackValue> 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<StackValue, StackValue> impleme
}
}
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;
@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,
@@ -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));
}
@@ -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