Add KotlinType info about this inside inline class
This commit is contained in:
@@ -2678,8 +2678,8 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
|
|
||||||
private StackValue generateThisOrOuterFromContext(@NotNull ClassDescriptor thisOrOuterClass, boolean isSuper, boolean forceOuter) {
|
private StackValue generateThisOrOuterFromContext(@NotNull ClassDescriptor thisOrOuterClass, boolean isSuper, boolean forceOuter) {
|
||||||
CodegenContext cur = context;
|
CodegenContext cur = context;
|
||||||
Type type = asmType(thisOrOuterClass.getDefaultType());
|
SimpleType thisType = thisOrOuterClass.getDefaultType();
|
||||||
StackValue result = StackValue.local(0, type);
|
StackValue result = StackValue.local(0, asmType(thisType), thisType);
|
||||||
boolean inStartConstructorContext = cur instanceof ConstructorContext;
|
boolean inStartConstructorContext = cur instanceof ConstructorContext;
|
||||||
while (cur != null) {
|
while (cur != null) {
|
||||||
ClassDescriptor thisDescriptor = cur.getThisDescriptor();
|
ClassDescriptor thisDescriptor = cur.getThisDescriptor();
|
||||||
|
|||||||
@@ -151,6 +151,10 @@ public abstract class StackValue {
|
|||||||
return new Local(index, type);
|
return new Local(index, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Local local(int index, @NotNull Type type, @Nullable KotlinType kotlinType) {
|
||||||
|
return new Local(index, type, kotlinType);
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static Local local(int index, @NotNull Type type, @NotNull VariableDescriptor descriptor) {
|
public static Local local(int index, @NotNull Type type, @NotNull VariableDescriptor descriptor) {
|
||||||
return new Local(index, type, descriptor.getType(), descriptor.isLateInit(), descriptor.getName());
|
return new Local(index, type, descriptor.getType(), descriptor.isLateInit(), descriptor.getName());
|
||||||
@@ -802,6 +806,10 @@ public abstract class StackValue {
|
|||||||
this(index, type, null, false, null);
|
this(index, type, null, false, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Local(int index, Type type, KotlinType kotlinType) {
|
||||||
|
this(index, type, kotlinType, false, null);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void putSelector(@NotNull Type type, @Nullable KotlinType kotlinType, @NotNull InstructionAdapter v) {
|
public void putSelector(@NotNull Type type, @Nullable KotlinType kotlinType, @NotNull InstructionAdapter v) {
|
||||||
v.load(index, this.type);
|
v.load(index, this.type);
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
// !LANGUAGE: +InlineClasses
|
||||||
|
|
||||||
|
inline class UInt(val a: Int) {
|
||||||
|
fun test() {
|
||||||
|
takeNullable(this)
|
||||||
|
takeAnyInside(this)
|
||||||
|
|
||||||
|
takeAnyInside(this.a)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun takeAnyInside(a: Any) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun takeNullable(a: UInt?) {}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val a = UInt(0)
|
||||||
|
a.test()
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
// !LANGUAGE: +InlineClasses
|
||||||
|
|
||||||
|
inline class UInt(val a: Int) {
|
||||||
|
fun test() {
|
||||||
|
takeNullable(this) // box
|
||||||
|
takeAnyInside(this) // box
|
||||||
|
|
||||||
|
takeAnyInside(this.a) // box int
|
||||||
|
}
|
||||||
|
|
||||||
|
fun takeAnyInside(a: Any) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun takeNullable(a: UInt?) {}
|
||||||
|
|
||||||
|
// 2 INVOKESTATIC UInt\$Erased.box
|
||||||
|
// 0 INVOKEVIRTUAL Foo.unbox
|
||||||
|
|
||||||
|
// 1 valueOf
|
||||||
|
// 0 intValue
|
||||||
Generated
+6
@@ -10496,6 +10496,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/inlineClasses/useInlineFunctionInsideInlineClass.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/inlineClasses/useInlineFunctionInsideInlineClass.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("useThisInsideInlineClass.kt")
|
||||||
|
public void testUseThisInsideInlineClass() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/inlineClasses/useThisInsideInlineClass.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/innerNested")
|
@TestMetadata("compiler/testData/codegen/box/innerNested")
|
||||||
|
|||||||
+6
@@ -10496,6 +10496,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/inlineClasses/useInlineFunctionInsideInlineClass.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/inlineClasses/useInlineFunctionInsideInlineClass.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("useThisInsideInlineClass.kt")
|
||||||
|
public void testUseThisInsideInlineClass() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/inlineClasses/useThisInsideInlineClass.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/innerNested")
|
@TestMetadata("compiler/testData/codegen/box/innerNested")
|
||||||
|
|||||||
@@ -1920,6 +1920,12 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("boxThisOfInlineClass.kt")
|
||||||
|
public void testBoxThisOfInlineClass() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/inlineClasses/boxThisOfInlineClass.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("boxUnboxInlineClassFromMethodReturnType.kt")
|
@TestMetadata("boxUnboxInlineClassFromMethodReturnType.kt")
|
||||||
public void testBoxUnboxInlineClassFromMethodReturnType() throws Exception {
|
public void testBoxUnboxInlineClassFromMethodReturnType() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/inlineClasses/boxUnboxInlineClassFromMethodReturnType.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/inlineClasses/boxUnboxInlineClassFromMethodReturnType.kt");
|
||||||
|
|||||||
+6
@@ -10496,6 +10496,12 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/inlineClasses/useInlineFunctionInsideInlineClass.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/inlineClasses/useInlineFunctionInsideInlineClass.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("useThisInsideInlineClass.kt")
|
||||||
|
public void testUseThisInsideInlineClass() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/inlineClasses/useThisInsideInlineClass.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/innerNested")
|
@TestMetadata("compiler/testData/codegen/box/innerNested")
|
||||||
|
|||||||
+6
@@ -11480,6 +11480,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/inlineClasses/useInlineFunctionInsideInlineClass.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/inlineClasses/useInlineFunctionInsideInlineClass.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("useThisInsideInlineClass.kt")
|
||||||
|
public void testUseThisInsideInlineClass() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/inlineClasses/useThisInsideInlineClass.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/innerNested")
|
@TestMetadata("compiler/testData/codegen/box/innerNested")
|
||||||
|
|||||||
Reference in New Issue
Block a user