Minor, simplify method
This commit is contained in:
@@ -199,19 +199,12 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
StackValue castToRequiredTypeOfInterfaceIfNeeded(StackValue inner, DeclarationDescriptor provided, @Nullable ClassDescriptor required) {
|
@NotNull
|
||||||
if (required == null) {
|
private StackValue castToRequiredTypeOfInterfaceIfNeeded(
|
||||||
return inner;
|
StackValue inner,
|
||||||
}
|
@NotNull ClassDescriptor provided,
|
||||||
|
@NotNull ClassDescriptor required
|
||||||
if (provided instanceof CallableDescriptor) {
|
) {
|
||||||
ReceiverParameterDescriptor receiverParameter = ((CallableDescriptor) provided).getReceiverParameter();
|
|
||||||
assert receiverParameter != null : receiverParameter;
|
|
||||||
provided = receiverParameter.getType().getConstructor().getDeclarationDescriptor();
|
|
||||||
}
|
|
||||||
|
|
||||||
assert provided instanceof ClassDescriptor;
|
|
||||||
|
|
||||||
if (!isInterface(provided) && isInterface(required)) {
|
if (!isInterface(provided) && isInterface(required)) {
|
||||||
inner.put(OBJECT_TYPE, v);
|
inner.put(OBJECT_TYPE, v);
|
||||||
Type type = asmType(required.getDefaultType());
|
Type type = asmType(required.getDefaultType());
|
||||||
@@ -2217,12 +2210,10 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
|||||||
|
|
||||||
private StackValue generateReceiver(DeclarationDescriptor provided) {
|
private StackValue generateReceiver(DeclarationDescriptor provided) {
|
||||||
if (context.getCallableDescriptorWithReceiver() == provided) {
|
if (context.getCallableDescriptorWithReceiver() == provided) {
|
||||||
StackValue result = context.getReceiverExpression(typeMapper);
|
return context.getReceiverExpression(typeMapper);
|
||||||
return castToRequiredTypeOfInterfaceIfNeeded(result, provided, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StackValue result = context.lookupInContext(provided, StackValue.local(0, OBJECT_TYPE), state, false);
|
return context.lookupInContext(provided, StackValue.local(0, OBJECT_TYPE), state, false);
|
||||||
return castToRequiredTypeOfInterfaceIfNeeded(result, provided, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateScript(@NotNull ScriptReceiver receiver) {
|
private void generateScript(@NotNull ScriptReceiver receiver) {
|
||||||
|
|||||||
Reference in New Issue
Block a user