Handle inline class operations in inline class secondary constructors
#KT-27225 Fixed
This commit is contained in:
committed by
SvyatoslavScherbina
parent
4045bf48c8
commit
d6475cb2ad
+3
-1
@@ -271,6 +271,8 @@ private class InlineClassTransformer(private val context: Context) : IrBuildingT
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun visitConstructor(declaration: IrConstructor): IrStatement {
|
override fun visitConstructor(declaration: IrConstructor): IrStatement {
|
||||||
|
super.visitConstructor(declaration)
|
||||||
|
|
||||||
val classIsInlined = declaration.constructedClass.isInlined()
|
val classIsInlined = declaration.constructedClass.isInlined()
|
||||||
|
|
||||||
if (classIsInlined && !declaration.isPrimary) {
|
if (classIsInlined && !declaration.isPrimary) {
|
||||||
@@ -282,7 +284,7 @@ private class InlineClassTransformer(private val context: Context) : IrBuildingT
|
|||||||
(declaration.body as IrBlockBody).statements.clear()
|
(declaration.body as IrBlockBody).statements.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.visitConstructor(declaration)
|
return declaration
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun IrBuilderWithScope.irIsNull(expression: IrExpression): IrExpression {
|
private fun IrBuilderWithScope.irIsNull(expression: IrExpression): IrExpression {
|
||||||
|
|||||||
@@ -2580,6 +2580,10 @@ task classDeclarationInsideInline(type: RunKonanTest) {
|
|||||||
goldValue = "test1: 1.0\n1\ntest2\n"
|
goldValue = "test1: 1.0\n1\ntest2\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task inlineClass0(type: RunKonanTest) {
|
||||||
|
source = "codegen/inlineClass/inlineClass0.kt"
|
||||||
|
}
|
||||||
|
|
||||||
task deserialized_inline0(type: RunKonanTest) {
|
task deserialized_inline0(type: RunKonanTest) {
|
||||||
source = "serialization/deserialized_inline0.kt"
|
source = "serialization/deserialized_inline0.kt"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package codegen.inlineClass.inlineClass0
|
||||||
|
|
||||||
|
import kotlin.test.*
|
||||||
|
|
||||||
|
// Based on KT-27225.
|
||||||
|
|
||||||
|
inline class First(val value: Int)
|
||||||
|
|
||||||
|
inline class Second(val value: First) {
|
||||||
|
constructor(c: Int) : this(First(c))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun runTest() {
|
||||||
|
assertEquals(Second(42).value.value, 42)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user