Fix for KT-10047: java.lang.VerifyError: Bad return type
#KT-10047 Fixed
This commit is contained in:
@@ -603,7 +603,8 @@ public abstract class MemberCodegen<T extends KtElement/* TODO: & JetDeclaration
|
|||||||
public void doGenerateBody(@NotNull ExpressionCodegen codegen, @NotNull JvmMethodSignature signature) {
|
public void doGenerateBody(@NotNull ExpressionCodegen codegen, @NotNull JvmMethodSignature signature) {
|
||||||
markLineNumberForElement(element, codegen.v);
|
markLineNumberForElement(element, codegen.v);
|
||||||
|
|
||||||
generateMethodCallTo(original, accessor, codegen.v);
|
generateMethodCallTo(original, accessor, codegen.v).coerceTo(signature.getReturnType(), codegen.v);
|
||||||
|
|
||||||
codegen.v.areturn(signature.getReturnType());
|
codegen.v.areturn(signature.getReturnType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -642,7 +643,7 @@ public abstract class MemberCodegen<T extends KtElement/* TODO: & JetDeclaration
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (callableDescriptor instanceof PropertyGetterDescriptor) {
|
if (callableDescriptor instanceof PropertyGetterDescriptor) {
|
||||||
property.put(property.type, iv);
|
property.put(signature.getReturnType(), iv);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
property.store(StackValue.onStack(property.type), iv, true);
|
property.store(StackValue.onStack(property.type), iv, true);
|
||||||
@@ -672,7 +673,7 @@ public abstract class MemberCodegen<T extends KtElement/* TODO: & JetDeclaration
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateMethodCallTo(
|
private StackValue generateMethodCallTo(
|
||||||
@NotNull FunctionDescriptor functionDescriptor,
|
@NotNull FunctionDescriptor functionDescriptor,
|
||||||
@Nullable FunctionDescriptor accessorDescriptor,
|
@Nullable FunctionDescriptor accessorDescriptor,
|
||||||
@NotNull InstructionAdapter iv
|
@NotNull InstructionAdapter iv
|
||||||
@@ -708,5 +709,7 @@ public abstract class MemberCodegen<T extends KtElement/* TODO: & JetDeclaration
|
|||||||
}
|
}
|
||||||
|
|
||||||
callableMethod.genInvokeInstruction(iv);
|
callableMethod.genInvokeInstruction(iv);
|
||||||
|
|
||||||
|
return StackValue.onStack(callableMethod.getReturnType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package test2
|
||||||
|
|
||||||
|
import test.Actor
|
||||||
|
import test.O2dScriptAction
|
||||||
|
|
||||||
|
class CompositeActor : Actor()
|
||||||
|
|
||||||
|
public open class O2dDialog : O2dScriptAction<CompositeActor>() {
|
||||||
|
|
||||||
|
fun test() = { owner }()
|
||||||
|
|
||||||
|
fun test2() = { calc() }()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
if (O2dDialog().test() != null) return "fail 1"
|
||||||
|
if (O2dDialog().test2() != null) return "fail 2"
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
open class Actor
|
||||||
|
|
||||||
|
abstract public class O2dScriptAction<T : Actor> {
|
||||||
|
protected var owner: T? = null
|
||||||
|
private set
|
||||||
|
|
||||||
|
protected fun calc(): T? = null
|
||||||
|
|
||||||
|
}
|
||||||
+6
@@ -65,6 +65,12 @@ public class BlackBoxMultiFileCodegenTestGenerated extends AbstractBlackBoxCodeg
|
|||||||
doTestMultiFile(fileName);
|
doTestMultiFile(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt10047")
|
||||||
|
public void testKt10047() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/kt10047/");
|
||||||
|
doTestMultiFile(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt1515")
|
@TestMetadata("kt1515")
|
||||||
public void testKt1515() throws Exception {
|
public void testKt1515() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/kt1515/");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/kt1515/");
|
||||||
|
|||||||
Reference in New Issue
Block a user