KT-5699 VerifyError in inlines
#KT-5699 Fixed
This commit is contained in:
@@ -619,8 +619,8 @@ public class FunctionCodegen extends ParentCodegenAware {
|
|||||||
CallGenerator generator = codegen.getOrCreateCallGenerator(functionDescriptor, function);
|
CallGenerator generator = codegen.getOrCreateCallGenerator(functionDescriptor, function);
|
||||||
|
|
||||||
InstructionAdapter iv = new InstructionAdapter(mv);
|
InstructionAdapter iv = new InstructionAdapter(mv);
|
||||||
loadExplicitArgumentsOnStack(iv, OBJECT_TYPE, isStatic, signature);
|
|
||||||
generator.putHiddenParams();
|
loadExplicitArgumentsOnStack(iv, OBJECT_TYPE, isStatic, signature, generator);
|
||||||
|
|
||||||
List<JvmMethodParameterSignature> mappedParameters = signature.getValueParameters();
|
List<JvmMethodParameterSignature> mappedParameters = signature.getValueParameters();
|
||||||
int capturedArgumentsCount = 0;
|
int capturedArgumentsCount = 0;
|
||||||
@@ -698,18 +698,19 @@ public class FunctionCodegen extends ParentCodegenAware {
|
|||||||
@NotNull InstructionAdapter iv,
|
@NotNull InstructionAdapter iv,
|
||||||
@NotNull Type ownerType,
|
@NotNull Type ownerType,
|
||||||
boolean isStatic,
|
boolean isStatic,
|
||||||
@NotNull JvmMethodSignature signature
|
@NotNull JvmMethodSignature signature,
|
||||||
|
@NotNull CallGenerator callGenerator
|
||||||
) {
|
) {
|
||||||
int var = 0;
|
int var = 0;
|
||||||
if (!isStatic) {
|
if (!isStatic) {
|
||||||
iv.load(var, ownerType);
|
callGenerator.putValueIfNeeded(null, ownerType, StackValue.local(var, ownerType));
|
||||||
var += ownerType.getSize();
|
var += ownerType.getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (JvmMethodParameterSignature parameterSignature : signature.getValueParameters()) {
|
for (JvmMethodParameterSignature parameterSignature : signature.getValueParameters()) {
|
||||||
if (parameterSignature.getKind() != JvmMethodParameterKind.VALUE) {
|
if (parameterSignature.getKind() != JvmMethodParameterKind.VALUE) {
|
||||||
Type type = parameterSignature.getAsmType();
|
Type type = parameterSignature.getAsmType();
|
||||||
iv.load(var, type);
|
callGenerator.putValueIfNeeded(null, type, StackValue.local(var, type));
|
||||||
var += type.getSize();
|
var += type.getSize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ public class InlineCodegen implements CallGenerator {
|
|||||||
MethodContext methodContext = context.getParentContext().intoFunction(functionDescriptor);
|
MethodContext methodContext = context.getParentContext().intoFunction(functionDescriptor);
|
||||||
MemberCodegen<?> parentCodegen = codegen.getParentCodegen();
|
MemberCodegen<?> parentCodegen = codegen.getParentCodegen();
|
||||||
if (callDefault) {
|
if (callDefault) {
|
||||||
boolean isStatic = isStatic(codegen.getContext().getContextKind());
|
boolean isStatic = isStatic(context.getContextKind());
|
||||||
FunctionCodegen.generateDefaultImplBody(
|
FunctionCodegen.generateDefaultImplBody(
|
||||||
methodContext, jvmSignature, functionDescriptor, isStatic, maxCalcAdapter, DefaultParameterValueLoader.DEFAULT,
|
methodContext, jvmSignature, functionDescriptor, isStatic, maxCalcAdapter, DefaultParameterValueLoader.DEFAULT,
|
||||||
(JetNamedFunction) element, parentCodegen, state
|
(JetNamedFunction) element, parentCodegen, state
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
import test.*
|
||||||
|
|
||||||
|
fun testExtensionInClass() : String {
|
||||||
|
|
||||||
|
var res = with(Z(1)) { "1".run("OK") }
|
||||||
|
if (res != "1OK") return "failed in class 1: $res"
|
||||||
|
|
||||||
|
res = with(Z(1)) { "1".run() }
|
||||||
|
if (res != "1null") return "failed in class 2: $res"
|
||||||
|
|
||||||
|
res = with(Z(2)) { "3".run("OK", {(a, b) -> a + b + value }, 1) }
|
||||||
|
if (res != "OK123") return "failed in class 3: $res"
|
||||||
|
|
||||||
|
res = with(Z(3)) { "4".run(lambda = {(a, b) -> a + b + value }) }
|
||||||
|
if (res != "034") return "failed in class 4: $res"
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
|
||||||
|
var res = "1".run("OK")
|
||||||
|
if (res != "1OK") return "failed 1: $res"
|
||||||
|
|
||||||
|
res = "1".run()
|
||||||
|
if (res != "1null") return "failed 2: $res"
|
||||||
|
|
||||||
|
res = "3".run("OK", {(a, b) -> a + b}, 1)
|
||||||
|
if (res != "OK13") return "failed 3: $res"
|
||||||
|
|
||||||
|
res = "4".run(lambda = {(a, b) -> a + b})
|
||||||
|
if (res != "04") return "failed 4: $res"
|
||||||
|
|
||||||
|
return testExtensionInClass()
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
inline public fun String.run(p1: String? = null): String {
|
||||||
|
return this + p1
|
||||||
|
}
|
||||||
|
|
||||||
|
inline public fun String.run(p1: String = "", lambda: (a: String, b: Int) -> String, p2: Int = 0): String {
|
||||||
|
return lambda(p1, p2) + this
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Z(val value: Int = 0) {
|
||||||
|
|
||||||
|
inline public fun String.run(p1: String? = null): String? {
|
||||||
|
return this + p1
|
||||||
|
}
|
||||||
|
|
||||||
|
inline public fun String.run(p1: String = "", lambda: (a: String, b: Int) -> String, p2: Int = 0): String {
|
||||||
|
return lambda(p1, p2) + this
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import test.*
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
if (Z().run() != "null0") return "fail 1: ${Z().run()}"
|
||||||
|
|
||||||
|
if (Z().run("OK") != "OK0") return "fail 2"
|
||||||
|
|
||||||
|
if (Z().run("OK", {(a, b) -> a + b }, 1) != "OK1") return "fail 3"
|
||||||
|
|
||||||
|
if (Z().run(lambda = {(a: String, b: Int) -> a + b }) != "0") return "fail 4"
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
public class Z(public val value: Int = 0) {
|
||||||
|
|
||||||
|
inline public fun run(p1: String? = null): String? {
|
||||||
|
return p1 + value
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline public fun run(p1: String = "", lambda: (a: String, b: Int) -> String, p2: Int = 0): String {
|
||||||
|
return lambda(p1, p2)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,5 +18,8 @@ fun box(): String {
|
|||||||
result = simple()
|
result = simple()
|
||||||
if (result != "OK") return "fail2: ${result}"
|
if (result != "OK") return "fail2: ${result}"
|
||||||
|
|
||||||
|
var result2 = simpleDoubleFun(2.0)
|
||||||
|
if (result2 != 2.0 + 1.0) return "fail3: ${result2}"
|
||||||
|
|
||||||
return "OK"
|
return "OK"
|
||||||
}
|
}
|
||||||
@@ -9,3 +9,9 @@ inline fun simpleFun(arg: String = "O"): String {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline fun simpleDoubleFun(arg: Double = 1.0): Double {
|
||||||
|
val r = arg + 1;
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
+10
@@ -157,11 +157,21 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxCodegenT
|
|||||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/defaultValues"), Pattern.compile("^(.+)\\.1.kt$"), true);
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/defaultValues"), Pattern.compile("^(.+)\\.1.kt$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("defaultInExtension.1.kt")
|
||||||
|
public void testDefaultInExtension() throws Exception {
|
||||||
|
doTestMultiFileWithInlineCheck("compiler/testData/codegen/boxInline/defaultValues/defaultInExtension.1.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("defaultMethod.1.kt")
|
@TestMetadata("defaultMethod.1.kt")
|
||||||
public void testDefaultMethod() throws Exception {
|
public void testDefaultMethod() throws Exception {
|
||||||
doTestMultiFileWithInlineCheck("compiler/testData/codegen/boxInline/defaultValues/defaultMethod.1.kt");
|
doTestMultiFileWithInlineCheck("compiler/testData/codegen/boxInline/defaultValues/defaultMethod.1.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("defaultMethodInClass.1.kt")
|
||||||
|
public void testDefaultMethodInClass() throws Exception {
|
||||||
|
doTestMultiFileWithInlineCheck("compiler/testData/codegen/boxInline/defaultValues/defaultMethodInClass.1.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("inlineInDefaultParameter.1.kt")
|
@TestMetadata("inlineInDefaultParameter.1.kt")
|
||||||
public void testInlineInDefaultParameter() throws Exception {
|
public void testInlineInDefaultParameter() throws Exception {
|
||||||
doTestMultiFileWithInlineCheck("compiler/testData/codegen/boxInline/defaultValues/inlineInDefaultParameter.1.kt");
|
doTestMultiFileWithInlineCheck("compiler/testData/codegen/boxInline/defaultValues/inlineInDefaultParameter.1.kt");
|
||||||
|
|||||||
+10
@@ -157,11 +157,21 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
|
|||||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/defaultValues"), Pattern.compile("^(.+)\\.1.kt$"), true);
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/defaultValues"), Pattern.compile("^(.+)\\.1.kt$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("defaultInExtension.1.kt")
|
||||||
|
public void testDefaultInExtension() throws Exception {
|
||||||
|
doBoxTestWithInlineCheck("compiler/testData/codegen/boxInline/defaultValues/defaultInExtension.1.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("defaultMethod.1.kt")
|
@TestMetadata("defaultMethod.1.kt")
|
||||||
public void testDefaultMethod() throws Exception {
|
public void testDefaultMethod() throws Exception {
|
||||||
doBoxTestWithInlineCheck("compiler/testData/codegen/boxInline/defaultValues/defaultMethod.1.kt");
|
doBoxTestWithInlineCheck("compiler/testData/codegen/boxInline/defaultValues/defaultMethod.1.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("defaultMethodInClass.1.kt")
|
||||||
|
public void testDefaultMethodInClass() throws Exception {
|
||||||
|
doBoxTestWithInlineCheck("compiler/testData/codegen/boxInline/defaultValues/defaultMethodInClass.1.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("inlineInDefaultParameter.1.kt")
|
@TestMetadata("inlineInDefaultParameter.1.kt")
|
||||||
public void testInlineInDefaultParameter() throws Exception {
|
public void testInlineInDefaultParameter() throws Exception {
|
||||||
doBoxTestWithInlineCheck("compiler/testData/codegen/boxInline/defaultValues/inlineInDefaultParameter.1.kt");
|
doBoxTestWithInlineCheck("compiler/testData/codegen/boxInline/defaultValues/inlineInDefaultParameter.1.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user