KT-27706: Dispatch receiver type for constructor accessor is Object

This commit is contained in:
Dmitry Petrov
2018-10-19 17:08:49 +03:00
parent ea4afdaebe
commit ac7cc0c08e
7 changed files with 45 additions and 1 deletions
@@ -884,7 +884,9 @@ public abstract class MemberCodegen<T extends KtPureElement/* TODO: & KtDeclarat
boolean accessorIsConstructor = accessorDescriptor instanceof AccessorForConstructorDescriptor;
ReceiverParameterDescriptor dispatchReceiver = functionDescriptor.getDispatchReceiverParameter();
Type dispatchReceiverType = dispatchReceiver != null ? typeMapper.mapType(dispatchReceiver.getType()) : AsmTypes.OBJECT_TYPE;
Type dispatchReceiverType = dispatchReceiver != null && !accessorIsConstructor
? typeMapper.mapType(dispatchReceiver.getType())
: AsmTypes.OBJECT_TYPE;
int accessorParam = (hasDispatchReceiver && !accessorIsConstructor) ? 1 : 0;
int reg = hasDispatchReceiver ? dispatchReceiverType.getSize() : 0;
+17
View File
@@ -0,0 +1,17 @@
// !LANGUAGE: +InlineClasses
// WITH_RUNTIME
// IGNORE_BACKEND: JVM_IR
inline class Z(val x: Int) {
inner class Inner(val z: Z) {
val xx = x
}
}
fun box(): String {
val zi = Z(42).Inner(Z(100))
if (zi.xx != 42) throw AssertionError()
if (zi.z.x != 100) throw AssertionError()
return "OK"
}
@@ -12060,6 +12060,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/inlineClasses/kt27705.kt");
}
@TestMetadata("kt27706.kt")
public void testKt27706() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/kt27706.kt");
}
@TestMetadata("noAssertionsOnInlineClassBasedOnNullableType.kt")
public void testNoAssertionsOnInlineClassBasedOnNullableType() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/noAssertionsOnInlineClassBasedOnNullableType.kt");
@@ -12060,6 +12060,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/inlineClasses/kt27705.kt");
}
@TestMetadata("kt27706.kt")
public void testKt27706() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/kt27706.kt");
}
@TestMetadata("noAssertionsOnInlineClassBasedOnNullableType.kt")
public void testNoAssertionsOnInlineClassBasedOnNullableType() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/noAssertionsOnInlineClassBasedOnNullableType.kt");
@@ -12065,6 +12065,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/inlineClasses/kt27705.kt");
}
@TestMetadata("kt27706.kt")
public void testKt27706() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/kt27706.kt");
}
@TestMetadata("noAssertionsOnInlineClassBasedOnNullableType.kt")
public void testNoAssertionsOnInlineClassBasedOnNullableType() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/noAssertionsOnInlineClassBasedOnNullableType.kt");
@@ -10460,6 +10460,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/inlineClasses/kt27705.kt");
}
@TestMetadata("kt27706.kt")
public void testKt27706() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/kt27706.kt");
}
@TestMetadata("noAssertionsOnInlineClassBasedOnNullableType.kt")
public void testNoAssertionsOnInlineClassBasedOnNullableType() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/noAssertionsOnInlineClassBasedOnNullableType.kt");
@@ -11505,6 +11505,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/inlineClasses/kt27705.kt");
}
@TestMetadata("kt27706.kt")
public void testKt27706() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/kt27706.kt");
}
@TestMetadata("noAssertionsOnInlineClassBasedOnNullableType.kt")
public void testNoAssertionsOnInlineClassBasedOnNullableType() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/noAssertionsOnInlineClassBasedOnNullableType.kt");