Old JVM: support init blocks in inline classes
#KT-28055 Fixed
This commit is contained in:
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.descriptors.*;
|
|||||||
import org.jetbrains.kotlin.psi.*;
|
import org.jetbrains.kotlin.psi.*;
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils;
|
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils;
|
||||||
|
import org.jetbrains.kotlin.resolve.InlineClassesUtilsKt;
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||||
import org.jetbrains.kotlin.resolve.jvm.InlineClassManglingRulesKt;
|
import org.jetbrains.kotlin.resolve.jvm.InlineClassManglingRulesKt;
|
||||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin;
|
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin;
|
||||||
@@ -192,6 +193,7 @@ public class ConstructorCodegen {
|
|||||||
markLineNumberForConstructor(constructorDescriptor, primaryConstructor, codegen);
|
markLineNumberForConstructor(constructorDescriptor, primaryConstructor, codegen);
|
||||||
|
|
||||||
if (OwnerKind.ERASED_INLINE_CLASS == kind) {
|
if (OwnerKind.ERASED_INLINE_CLASS == kind) {
|
||||||
|
memberCodegen.generateInitializers(() -> codegen);
|
||||||
Type t = typeMapper.mapType(constructorDescriptor.getContainingDeclaration());
|
Type t = typeMapper.mapType(constructorDescriptor.getContainingDeclaration());
|
||||||
iv.load(0, t);
|
iv.load(0, t);
|
||||||
iv.areturn(t);
|
iv.areturn(t);
|
||||||
@@ -226,7 +228,7 @@ public class ConstructorCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//object initialization was moved to initializeObjects()
|
//object initialization was moved to initializeObjects()
|
||||||
if (!isObject(descriptor)) {
|
if (!isObject(descriptor) && !InlineClassesUtilsKt.isInlineClass(descriptor)) {
|
||||||
memberCodegen.generateInitializers(() -> codegen);
|
memberCodegen.generateInitializers(() -> codegen);
|
||||||
}
|
}
|
||||||
iv.visitInsn(RETURN);
|
iv.visitInsn(RETURN);
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
// IGNORE_BACKEND: JVM
|
|
||||||
// IGNORE_BACKEND: JS_IR
|
// IGNORE_BACKEND: JS_IR
|
||||||
// IGNORE_LIGHT_ANALYSIS
|
|
||||||
|
|
||||||
inline class IC(val i: Int) {
|
inline class IC(val i: Int) {
|
||||||
init {
|
init {
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
// IGNORE_BACKEND: JVM
|
|
||||||
// IGNORE_BACKEND: JS_IR
|
// IGNORE_BACKEND: JS_IR
|
||||||
// IGNORE_LIGHT_ANALYSIS
|
|
||||||
|
|
||||||
inline class SingleInitBlock(val s: String) {
|
inline class SingleInitBlock(val s: String) {
|
||||||
init {
|
init {
|
||||||
|
|||||||
+13
-3
@@ -13,8 +13,18 @@ inline class UInt(val a: Int) {
|
|||||||
|
|
||||||
fun takeNullable(a: UInt?) {}
|
fun takeNullable(a: UInt?) {}
|
||||||
|
|
||||||
// 2 INVOKESTATIC UInt\.box
|
|
||||||
// 0 INVOKEVIRTUAL Foo.unbox
|
|
||||||
|
|
||||||
// 1 valueOf
|
// 1 valueOf
|
||||||
// 0 intValue
|
// 0 intValue
|
||||||
|
|
||||||
|
// JVM_TEMPLATES:
|
||||||
|
// 2 INVOKESTATIC UInt\.box
|
||||||
|
// -- equals-impl
|
||||||
|
// 1 INVOKEVIRTUAL UInt\.unbox
|
||||||
|
|
||||||
|
// JVM_IR_TEMPLATES:
|
||||||
|
// -- 1 before takeNullable
|
||||||
|
// -- 1 before takeAnyInside
|
||||||
|
// -- 1 before takeAnyInside's GETFIELD
|
||||||
|
// 3 INVOKESTATIC UInt\.box
|
||||||
|
// -- getA, toString, hashCode, equals-impl, equals
|
||||||
|
// 5 INVOKEVIRTUAL UInt\.unbox
|
||||||
Reference in New Issue
Block a user