Fix Android byte code generation inside complex expressions
This commit is contained in:
@@ -1914,8 +1914,9 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
ExpressionCodegenExtension.Context context = new ExpressionCodegenExtension.Context(typeMapper, v);
|
||||
JetType returnType = propertyDescriptor.getReturnType();
|
||||
for (ExpressionCodegenExtension extension : codegenExtensions) {
|
||||
if (returnType != null && extension.apply(receiver, resolvedCall, context)) {
|
||||
return StackValue.onStack(typeMapper.mapType(returnType));
|
||||
if (returnType != null) {
|
||||
StackValue value = extension.applyProperty(receiver, resolvedCall, context);
|
||||
if (value != null) return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2352,7 +2353,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
if (!codegenExtensions.isEmpty()) {
|
||||
ExpressionCodegenExtension.Context context = new ExpressionCodegenExtension.Context(typeMapper, v);
|
||||
for (ExpressionCodegenExtension extension : codegenExtensions) {
|
||||
if (extension.apply(receiver, resolvedCall, context)) return;
|
||||
if (extension.applyFunction(receiver, resolvedCall, context)) return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+11
-3
@@ -35,9 +35,17 @@ public trait ExpressionCodegenExtension {
|
||||
public val v: InstructionAdapter
|
||||
)
|
||||
|
||||
// Function is responsible to put the value on stack by itself.
|
||||
// Returns false if not applicable, and if stack was not modified.
|
||||
public fun apply(receiver: StackValue, resolvedCall: ResolvedCall<*>, c: Context): Boolean
|
||||
/**
|
||||
* Used for generating custom byte code for the property value obtain. This function has lazy semantics.
|
||||
* Returns new stack value.
|
||||
*/
|
||||
public fun applyProperty(receiver: StackValue, resolvedCall: ResolvedCall<*>, c: Context): StackValue? = null
|
||||
|
||||
/**
|
||||
* Used for generating custom byte code for the function call. This function has non-lazy semantics.
|
||||
* Returns true if the stack was modified.
|
||||
*/
|
||||
public fun applyFunction(receiver: StackValue, resolvedCall: ResolvedCall<*>, c: Context): Boolean = false
|
||||
|
||||
public fun generateClassSyntheticParts(
|
||||
classBuilder: ClassBuilder,
|
||||
|
||||
Reference in New Issue
Block a user