[IR] Supported value classes
This commit is contained in:
committed by
Stanislav Erokhin
parent
3cd335c1c5
commit
e2cbe53776
+3
-2
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.name.FqNameUnsafe
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.getAllSuperClassifiers
|
||||
import org.jetbrains.kotlin.resolve.isInlineClass
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.isNullable
|
||||
import org.jetbrains.kotlin.types.typeUtil.makeNullable
|
||||
@@ -254,7 +255,7 @@ internal object KotlinTypeInlineClassesSupport : InlineClassesSupport<ClassDescr
|
||||
else type.constructor.supertypes.asSequence().flatMap { computeFullErasure(it) }
|
||||
}
|
||||
|
||||
override fun hasInlineModifier(clazz: ClassDescriptor): Boolean = clazz.isInline
|
||||
override fun hasInlineModifier(clazz: ClassDescriptor): Boolean = clazz.isInlineClass()
|
||||
|
||||
override fun getNativePointedSuperclass(clazz: ClassDescriptor): ClassDescriptor? = clazz.getAllSuperClassifiers()
|
||||
.firstOrNull { it.fqNameUnsafe == InteropFqNames.nativePointed } as ClassDescriptor?
|
||||
@@ -295,7 +296,7 @@ private object IrTypeInlineClassesSupport : InlineClassesSupport<IrClass, IrType
|
||||
}
|
||||
}
|
||||
|
||||
override fun hasInlineModifier(clazz: IrClass): Boolean = clazz.descriptor.isInline
|
||||
override fun hasInlineModifier(clazz: IrClass): Boolean = clazz.isInline
|
||||
|
||||
override fun getNativePointedSuperclass(clazz: IrClass): IrClass? {
|
||||
var superClass: IrClass? = clazz
|
||||
|
||||
+1
-1
@@ -129,7 +129,7 @@ internal class BuiltinOperatorLowering(val context: Context) : FileLoweringPass,
|
||||
}
|
||||
|
||||
private fun inlinedClassHasDefaultEquals(irClass: IrClass): Boolean {
|
||||
if (!irClass.descriptor.isInline) {
|
||||
if (!irClass.isInline) {
|
||||
// Implicitly-inlined class, e.g. primitive one.
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -3275,6 +3275,10 @@ task inlineClass_secondaryConstructorWithGenerics(type: KonanLocalTest) {
|
||||
source = "codegen/inlineClass/secondaryConstructorWithGenerics.kt"
|
||||
}
|
||||
|
||||
task valueClass0(type: KonanLocalTest) {
|
||||
source = "codegen/inlineClass/valueClass0.kt"
|
||||
}
|
||||
|
||||
task deserialized_inline0(type: KonanLocalTest) {
|
||||
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.valueClass0
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
// Based on KT-27225.
|
||||
|
||||
value class First(val value: Int)
|
||||
|
||||
value 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