Properly capture extension receiver for array convention expressions in object constructor

#KT-19389 Fixed
This commit is contained in:
Mikhael Bogdanov
2019-02-05 11:37:23 +01:00
parent 3943bd1b15
commit 9ab6062295
12 changed files with 155 additions and 0 deletions
@@ -69,6 +69,8 @@ import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.*;
import static org.jetbrains.kotlin.codegen.binding.CodegenBinding.enumEntryNeedSubclass;
import static org.jetbrains.kotlin.codegen.inline.InlineCodegenUtils2Kt.initDefaultSourceMappingIfNeeded;
import static org.jetbrains.kotlin.load.java.JvmAbi.*;
import static org.jetbrains.kotlin.resolve.BindingContext.INDEXED_LVALUE_GET;
import static org.jetbrains.kotlin.resolve.BindingContext.INDEXED_LVALUE_SET;
import static org.jetbrains.kotlin.resolve.BindingContextUtils.getNotNull;
import static org.jetbrains.kotlin.resolve.DescriptorToSourceUtils.descriptorToDeclaration;
import static org.jetbrains.kotlin.resolve.DescriptorUtils.*;
@@ -1021,6 +1023,22 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
public void visitSuperExpression(@NotNull KtSuperExpression expression) {
lookupInContext(ExpressionCodegen.getSuperCallLabelTarget(context, expression));
}
@Override
public void visitArrayAccessExpression(@NotNull KtArrayAccessExpression expression) {
ResolvedCall<FunctionDescriptor> resolvedGetCall = bindingContext.get(INDEXED_LVALUE_GET, expression);
if (resolvedGetCall != null) {
ReceiverValue receiver = resolvedGetCall.getDispatchReceiver();
lookupReceiver(receiver);
}
ResolvedCall<FunctionDescriptor> resolvedSetCall = bindingContext.get(INDEXED_LVALUE_SET, expression);
if (resolvedSetCall != null) {
ReceiverValue receiver = resolvedSetCall.getDispatchReceiver();
lookupReceiver(receiver);
}
super.visitArrayAccessExpression(expression);
}
};
for (KtDeclaration declaration : myClass.getDeclarations()) {