[K2, MPP] Actualize value class representation
^KT-63638 fixed
This commit is contained in:
committed by
Space Cloud
parent
0bd6ea764e
commit
438b2dd164
+6
@@ -35638,6 +35638,12 @@ public class LLFirBlackBoxCodegenBasedTestGenerated extends AbstractLLFirBlackBo
|
||||
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/transitiveSuperclassActualization_java.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("valueClassOfExpectClass.kt")
|
||||
public void testValueClassOfExpectClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/valueClassOfExpectClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("valueClasses.kt")
|
||||
public void testValueClasses() throws Exception {
|
||||
|
||||
+6
@@ -35638,6 +35638,12 @@ public class LLFirReversedBlackBoxCodegenBasedTestGenerated extends AbstractLLFi
|
||||
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/transitiveSuperclassActualization_java.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("valueClassOfExpectClass.kt")
|
||||
public void testValueClassOfExpectClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/valueClassOfExpectClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("valueClasses.kt")
|
||||
public void testValueClasses() throws Exception {
|
||||
|
||||
+6
@@ -35229,6 +35229,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr
|
||||
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/transitiveSuperclassActualization_java.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("valueClassOfExpectClass.kt")
|
||||
public void testValueClassOfExpectClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/valueClassOfExpectClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("valueClasses.kt")
|
||||
public void testValueClasses() throws Exception {
|
||||
|
||||
+6
@@ -35229,6 +35229,12 @@ public class FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated
|
||||
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/transitiveSuperclassActualization_java.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("valueClassOfExpectClass.kt")
|
||||
public void testValueClassOfExpectClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/valueClassOfExpectClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("valueClasses.kt")
|
||||
public void testValueClasses() throws Exception {
|
||||
|
||||
+6
@@ -35229,6 +35229,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo
|
||||
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/transitiveSuperclassActualization_java.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("valueClassOfExpectClass.kt")
|
||||
public void testValueClassOfExpectClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multiplatform/k2/basic/valueClassOfExpectClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("valueClasses.kt")
|
||||
public void testValueClasses() throws Exception {
|
||||
|
||||
+5
-4
@@ -7,10 +7,8 @@ package org.jetbrains.kotlin.backend.common.actualizer
|
||||
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.symbols.*
|
||||
import org.jetbrains.kotlin.ir.util.DeepCopyIrTreeWithSymbols
|
||||
import org.jetbrains.kotlin.ir.util.SymbolRemapper
|
||||
import org.jetbrains.kotlin.ir.util.SymbolRenamer
|
||||
import org.jetbrains.kotlin.ir.util.TypeRemapper
|
||||
import org.jetbrains.kotlin.ir.types.IrSimpleType
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
import org.jetbrains.kotlin.utils.memoryOptimizedMap
|
||||
|
||||
internal class ActualizerSymbolRemapper(private val expectActualMap: Map<IrSymbol, IrSymbol>) : SymbolRemapper {
|
||||
@@ -100,6 +98,9 @@ internal open class ActualizerVisitor(private val symbolRemapper: SymbolRemapper
|
||||
it.superTypes = it.superTypes.map { superType -> superType.remapType() }
|
||||
it.transformChildren(this, null)
|
||||
it.transformAnnotations(declaration)
|
||||
it.valueClassRepresentation = it.valueClassRepresentation?.mapUnderlyingType { type ->
|
||||
type.remapType() as? IrSimpleType ?: error("Value class underlying type is not a simple type: ${it.render()}")
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitSimpleFunction(declaration: IrSimpleFunction) = (visitFunction(declaration) as IrSimpleFunction).also {
|
||||
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
// ISSUE: KT-63638
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// WITH_STDLIB
|
||||
|
||||
// MODULE: common
|
||||
// TARGET_PLATFORM: Common
|
||||
// FILE: expect.kt
|
||||
|
||||
import kotlin.jvm.JvmInline
|
||||
|
||||
class Session<T>(val value: T)
|
||||
|
||||
@JvmInline
|
||||
value class SessionMutex<T> private constructor(
|
||||
private val currentSessionHolder: AtomicReference<Session<T>?>
|
||||
) {
|
||||
constructor() : this(AtomicReference(null))
|
||||
|
||||
val currentSession: T?
|
||||
get() = currentSessionHolder.get()?.value
|
||||
}
|
||||
|
||||
expect class AtomicReference<V>(value: V) {
|
||||
fun get(): V
|
||||
fun set(value: V)
|
||||
fun getAndSet(value: V): V
|
||||
fun compareAndSet(expect: V, newValue: V): Boolean
|
||||
}
|
||||
|
||||
// MODULE: main()()(common)
|
||||
// FILE: actual.kt
|
||||
|
||||
internal actual typealias AtomicReference<V> = java.util.concurrent.atomic.AtomicReference<V>
|
||||
|
||||
fun box(): String {
|
||||
val mutex = SessionMutex<Int>()
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user