Minor. Extract method for retreiving variable descriptor in codegen
This commit is contained in:
@@ -2002,8 +2002,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
final Label blockEnd,
|
final Label blockEnd,
|
||||||
@NotNull List<Function<StackValue, Void>> leaveTasks
|
@NotNull List<Function<StackValue, Void>> leaveTasks
|
||||||
) {
|
) {
|
||||||
final VariableDescriptor variableDescriptor = bindingContext.get(VARIABLE, statement);
|
final VariableDescriptor variableDescriptor = getVariableDescriptorNotNull(statement);
|
||||||
assert variableDescriptor != null;
|
|
||||||
|
|
||||||
final Type type = getVariableType(variableDescriptor);
|
final Type type = getVariableType(variableDescriptor);
|
||||||
|
|
||||||
@@ -3265,15 +3264,11 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
VariableDescriptor variableDescriptor = bindingContext.get(VARIABLE, expression);
|
VariableDescriptor variableDescriptor = getVariableDescriptorNotNull(expression);
|
||||||
if (variableDescriptor != null) {
|
return generatePropertyReference(
|
||||||
return generatePropertyReference(
|
expression, variableDescriptor, (VariableDescriptor) resolvedCall.getResultingDescriptor(),
|
||||||
expression, variableDescriptor, (VariableDescriptor) resolvedCall.getResultingDescriptor(),
|
receiverAsmType, receiverValue
|
||||||
receiverAsmType, receiverValue
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new UnsupportedOperationException("Unsupported callable reference expression: " + expression.getText());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -3931,7 +3926,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
@NotNull KtVariableDeclaration variableDeclaration,
|
@NotNull KtVariableDeclaration variableDeclaration,
|
||||||
@NotNull StackValue initializer
|
@NotNull StackValue initializer
|
||||||
) {
|
) {
|
||||||
LocalVariableDescriptor variableDescriptor = (LocalVariableDescriptor) bindingContext.get(VARIABLE, variableDeclaration);
|
LocalVariableDescriptor variableDescriptor = (LocalVariableDescriptor) getVariableDescriptorNotNull(variableDeclaration);
|
||||||
|
|
||||||
if (KtPsiUtil.isScriptDeclaration(variableDeclaration)) {
|
if (KtPsiUtil.isScriptDeclaration(variableDeclaration)) {
|
||||||
return;
|
return;
|
||||||
@@ -3943,7 +3938,6 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
Type sharedVarType = typeMapper.getSharedVarType(variableDescriptor);
|
Type sharedVarType = typeMapper.getSharedVarType(variableDescriptor);
|
||||||
assert variableDescriptor != null;
|
|
||||||
|
|
||||||
Type varType = getVariableTypeNoSharing(variableDescriptor);
|
Type varType = getVariableTypeNoSharing(variableDescriptor);
|
||||||
|
|
||||||
@@ -3963,6 +3957,13 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private VariableDescriptor getVariableDescriptorNotNull(@NotNull KtElement declaration) {
|
||||||
|
VariableDescriptor descriptor = bindingContext.get(VARIABLE, declaration);
|
||||||
|
assert descriptor != null : "Couldn't find variable declaration in binding context " + declaration.getText();
|
||||||
|
return descriptor;
|
||||||
|
}
|
||||||
|
|
||||||
private void invokePropertyDelegatedOnLocalVar(
|
private void invokePropertyDelegatedOnLocalVar(
|
||||||
@NotNull LocalVariableDescriptor variableDescriptor,
|
@NotNull LocalVariableDescriptor variableDescriptor,
|
||||||
@NotNull StackValue delegateValue,
|
@NotNull StackValue delegateValue,
|
||||||
|
|||||||
Reference in New Issue
Block a user