diff --git a/plugins/atomicfu/atomicfu-compiler/src/org/jetbrains/kotlinx/atomicfu/compiler/backend/TransformerUtil.kt b/plugins/atomicfu/atomicfu-compiler/src/org/jetbrains/kotlinx/atomicfu/compiler/backend/TransformerUtil.kt index af6728aae86..a65b8a6743d 100644 --- a/plugins/atomicfu/atomicfu-compiler/src/org/jetbrains/kotlinx/atomicfu/compiler/backend/TransformerUtil.kt +++ b/plugins/atomicfu/atomicfu-compiler/src/org/jetbrains/kotlinx/atomicfu/compiler/backend/TransformerUtil.kt @@ -304,7 +304,7 @@ internal fun IrPluginContext.getArrayConstructorSymbol( } } -internal fun IrPluginContext.addProperty( +internal fun IrPluginContext.buildPropertyForBackingField( field: IrField, parent: IrDeclarationContainer, visibility: DescriptorVisibility, @@ -386,12 +386,27 @@ internal fun IrPluginContext.addStaticGetter(property: IrProperty) { } } -internal fun IrPluginContext.buildClassInstance(irClass: IrClass, parentClass: IrDeclarationContainer) = +internal fun IrPluginContext.buildClassInstance( + irClass: IrClass, + parent: IrDeclarationContainer, + visibility: DescriptorVisibility, + isStatic: Boolean +): IrProperty = + buildPropertyForBackingField( + field = buildClassInstanceField(irClass, parent), + parent = parent, + visibility = visibility, + isStatic = isStatic + ) + +private fun IrPluginContext.buildClassInstanceField(irClass: IrClass, parent: IrDeclarationContainer) = + // build a backing field for the wrapper class instance property irFactory.buildField { this.name = Name.identifier(irClass.name.asString().decapitalizeAsciiOnly()) type = irClass.defaultType isFinal = true isStatic = true + visibility = DescriptorVisibilities.PRIVATE }.apply { initializer = IrExpressionBodyImpl( IrConstructorCallImpl.fromSymbolOwner( @@ -399,7 +414,7 @@ internal fun IrPluginContext.buildClassInstance(irClass: IrClass, parentClass: I irClass.primaryConstructor!!.symbol ) ) - this.parent = parentClass + this.parent = parent } private fun IrSimpleType.getArrayClassFqName(): FqName = diff --git a/plugins/atomicfu/atomicfu-compiler/src/org/jetbrains/kotlinx/atomicfu/compiler/backend/jvm/AtomicSymbols.kt b/plugins/atomicfu/atomicfu-compiler/src/org/jetbrains/kotlinx/atomicfu/compiler/backend/jvm/AtomicSymbols.kt index 25a9059fbfb..a1791a83e23 100644 --- a/plugins/atomicfu/atomicfu-compiler/src/org/jetbrains/kotlinx/atomicfu/compiler/backend/jvm/AtomicSymbols.kt +++ b/plugins/atomicfu/atomicfu-compiler/src/org/jetbrains/kotlinx/atomicfu/compiler/backend/jvm/AtomicSymbols.kt @@ -9,7 +9,6 @@ import org.jetbrains.kotlin.backend.common.ir.* import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.ir.* import org.jetbrains.kotlin.ir.builders.declarations.* -import org.jetbrains.kotlin.ir.builders.* import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.declarations.impl.* import org.jetbrains.kotlin.ir.expressions.* @@ -30,7 +29,7 @@ class AtomicSymbols( private val javaLang: IrPackageFragment = createPackage("java.lang") private val javaUtilConcurrent: IrPackageFragment = createPackage("java.util.concurrent.atomic") private val kotlinJvm: IrPackageFragment = createPackage("kotlin.jvm") - val javaLangClass: IrClassSymbol = createClass(javaLang, "Class", ClassKind.CLASS, Modality.FINAL) + private val javaLangClass: IrClassSymbol = createClass(javaLang, "Class", ClassKind.CLASS, Modality.FINAL) // AtomicIntegerFieldUpdater val atomicIntFieldUpdaterClass: IrClassSymbol = @@ -536,25 +535,6 @@ class AtomicSymbols( val volatileAnnotationConstructorCall = IrConstructorCallImpl.fromSymbolOwner(volatileConstructor.returnType, volatileConstructor.symbol) - fun buildClassWithPrimaryConstructor( - name: String, - parent: IrDeclarationContainer - ) = buildClass( - FqName(name), - ClassKind.CLASS, - parent - ).apply { - val irClass = this - addConstructor { - isPrimary = true - }.apply { - body = createBuilder(symbol).irBlockBody(startOffset, endOffset) { - +irDelegatingConstructorCall(context.irBuiltIns.anyClass.owner.constructors.single()) - +IrInstanceInitializerCallImpl(startOffset, endOffset, irClass.symbol, context.irBuiltIns.unitType) - } - } - } - fun buildClass( fqName: FqName, classKind: ClassKind, diff --git a/plugins/atomicfu/atomicfu-compiler/src/org/jetbrains/kotlinx/atomicfu/compiler/backend/jvm/AtomicfuJvmIrTransformer.kt b/plugins/atomicfu/atomicfu-compiler/src/org/jetbrains/kotlinx/atomicfu/compiler/backend/jvm/AtomicfuJvmIrTransformer.kt index 7d50f7eccc3..caec0958df4 100644 --- a/plugins/atomicfu/atomicfu-compiler/src/org/jetbrains/kotlinx/atomicfu/compiler/backend/jvm/AtomicfuJvmIrTransformer.kt +++ b/plugins/atomicfu/atomicfu-compiler/src/org/jetbrains/kotlinx/atomicfu/compiler/backend/jvm/AtomicfuJvmIrTransformer.kt @@ -103,20 +103,24 @@ class AtomicfuJvmIrTransformer( } private fun IrProperty.transformAtomicfuProperty(parent: IrDeclarationContainer) { + val atomicfuProperty = this val isTopLevel = parent is IrFile || (parent is IrClass && parent.kind == ClassKind.OBJECT) when { isAtomic() -> { if (isTopLevel) { - val parentClass = generateWrapperClass(this, parent) - transformAtomicProperty(parentClass) - moveFromFileToClass(parent, parentClass) + val wrapperClass = buildWrapperClass(atomicfuProperty, parent).also { + // add a static instance of the generated wrapper class to the parent container + context.buildClassInstance(it, parent, atomicfuProperty.visibility, true) + } + transformAtomicProperty(wrapperClass) + moveFromFileToClass(parent, wrapperClass) } else { transformAtomicProperty(parent as IrClass) } } isDelegatedToAtomic() -> transformDelegatedProperty(parent) isAtomicArray() -> transformAtomicArrayProperty(parent) - isTrace() -> parent.declarations.remove(this) + isTrace() -> parent.declarations.remove(atomicfuProperty) else -> {} } } @@ -240,9 +244,9 @@ class AtomicfuJvmIrTransformer( } private fun buildVolatileRawField(property: IrProperty, parent: IrDeclarationContainer): IrField = - // Generate a new backing field for the given property: - // a volatile variable of the atomic value type - // val a = atomic(0) + // Generate a new backing field for the given property: + // a volatile variable of the atomic value type + // val a = atomic(0) // volatile var a: Int = 0 property.backingField?.let { backingField -> val init = backingField.initializer?.expression @@ -250,9 +254,9 @@ class AtomicfuJvmIrTransformer( context.irFactory.buildField { name = property.name type = if (valueType.isBoolean()) irBuiltIns.intType else valueType - visibility = backingField.visibility // private isFinal = false isStatic = parent is IrFile + visibility = DescriptorVisibilities.PRIVATE }.apply { if (init != null) { val value = (init as IrCall).getAtomicFactoryValueArgument() @@ -272,9 +276,9 @@ class AtomicfuJvmIrTransformer( } ?: error("Backing field of the atomic property ${property.render()} is null") private fun addJucaAFUProperty(atomicProperty: IrProperty, parentClass: IrClass): IrProperty = - // Generate an atomic field updater for the volatile backing field of the given property: - // val a = atomic(0) - // volatile var a: Int = 0 + // Generate an atomic field updater for the volatile backing field of the given property: + // val a = atomic(0) + // volatile var a: Int = 0 // val a$FU = AtomicIntegerFieldUpdater.newUpdater(parentClass, "a") atomicProperty.backingField?.let { volatileField -> val fuClass = atomicSymbols.getJucaAFUClass(volatileField.type) @@ -282,9 +286,9 @@ class AtomicfuJvmIrTransformer( val fuField = context.irFactory.buildField { name = Name.identifier(mangleFUName(fieldName)) type = fuClass.defaultType - visibility = volatileField.visibility // private isFinal = true isStatic = true + visibility = DescriptorVisibilities.PRIVATE }.apply { initializer = IrExpressionBodyImpl( with(atomicSymbols.createBuilder(symbol)) { @@ -293,7 +297,7 @@ class AtomicfuJvmIrTransformer( ) parent = parentClass } - return context.addProperty(fuField, parentClass, atomicProperty.visibility, true) + return context.buildPropertyForBackingField(fuField, parentClass, atomicProperty.visibility, true) } ?: error("Atomic property ${atomicProperty.render()} should have a non-null generated volatile backingField") private fun buildJucaArrayField(atomicfuArrayProperty: IrProperty, parent: IrDeclarationContainer) = @@ -303,9 +307,9 @@ class AtomicfuJvmIrTransformer( context.irFactory.buildField { name = atomicfuArray.name type = atomicArrayClass.defaultType - visibility = atomicfuArray.visibility // private isFinal = atomicfuArray.isFinal isStatic = atomicfuArray.isStatic + visibility = DescriptorVisibilities.PRIVATE }.apply { if (init != null) { this.initializer = IrExpressionBodyImpl( @@ -333,20 +337,24 @@ class AtomicfuJvmIrTransformer( } } ?: error("Atomic property does not have backingField") - private fun generateWrapperClass(atomicProperty: IrProperty, parentContainer: IrDeclarationContainer): IrClass { - val wrapperClassName = getVolatileWrapperClassName(atomicProperty) - val volatileWrapperClass = parentContainer.declarations.singleOrNull { it is IrClass && it.name.asString() == wrapperClassName } - ?: atomicSymbols.buildClassWithPrimaryConstructor(wrapperClassName, parentContainer) - // add a static instance of the generated wrapper class to the parent container - return (volatileWrapperClass as IrClass).also { - context.addProperty( - field = context.buildClassInstance(it, parentContainer), - parent = parentContainer, - visibility = atomicProperty.visibility, - isStatic = true - ) + private fun buildWrapperClass(atomicProperty: IrProperty, parentContainer: IrDeclarationContainer): IrClass = + atomicSymbols.buildClass( + FqName(getVolatileWrapperClassName(atomicProperty)), + ClassKind.CLASS, + parentContainer + ).apply { + val irClass = this + irClass.visibility = atomicProperty.visibility + addConstructor { + isPrimary = true + }.apply { + body = atomicSymbols.createBuilder(symbol).irBlockBody(startOffset, endOffset) { + +irDelegatingConstructorCall(context.irBuiltIns.anyClass.owner.constructors.single()) + +IrInstanceInitializerCallImpl(startOffset, endOffset, irClass.symbol, context.irBuiltIns.unitType) + } + this.visibility = DescriptorVisibilities.PRIVATE // constructor of the wrapper class should be private + } } - } private fun transformLateInitializer( field: IrField, diff --git a/plugins/atomicfu/atomicfu-compiler/testData/box/DelegatedPropertiesTest.txt b/plugins/atomicfu/atomicfu-compiler/testData/box/DelegatedPropertiesTest.txt index b05ef1330e1..5d68be41e56 100644 --- a/plugins/atomicfu/atomicfu-compiler/testData/box/DelegatedPropertiesTest.txt +++ b/plugins/atomicfu/atomicfu-compiler/testData/box/DelegatedPropertiesTest.txt @@ -82,7 +82,7 @@ public final class DelegatedProperties { @kotlin.Metadata public final class DelegatedPropertiesTestKt { // source: 'DelegatedPropertiesTest.kt' - public final static @org.jetbrains.annotations.NotNull field _topLevelInt$DelegatedPropertiesTest$VolatileWrapper: _topLevelInt$DelegatedPropertiesTest$VolatileWrapper + private final static @org.jetbrains.annotations.NotNull field _topLevelInt$DelegatedPropertiesTest$VolatileWrapper: _topLevelInt$DelegatedPropertiesTest$VolatileWrapper private volatile static @kotlin.jvm.Volatile field topLevelVolatile: int static method (): void public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String @@ -95,12 +95,13 @@ public final class DelegatedPropertiesTestKt { } @kotlin.Metadata -public final class _topLevelInt$DelegatedPropertiesTest$VolatileWrapper { +final class _topLevelInt$DelegatedPropertiesTest$VolatileWrapper { // source: 'DelegatedPropertiesTest.kt' private final static @org.jetbrains.annotations.NotNull field _topLevelInt$FU: java.util.concurrent.atomic.AtomicIntegerFieldUpdater private volatile @kotlin.jvm.Volatile field _topLevelInt: int static method (): void - public method (): void + private method (): void + public synthetic method (p0: kotlin.jvm.internal.DefaultConstructorMarker): void public synthetic final static method access$get_topLevelInt$FU$p(): java.util.concurrent.atomic.AtomicIntegerFieldUpdater public synthetic final static method access$get_topLevelInt$p(p0: _topLevelInt$DelegatedPropertiesTest$VolatileWrapper): int public synthetic final static method access$set_topLevelInt$p(p0: _topLevelInt$DelegatedPropertiesTest$VolatileWrapper, p1: int): void diff --git a/plugins/atomicfu/atomicfu-compiler/testData/box/ExtensionLoopTest.txt b/plugins/atomicfu/atomicfu-compiler/testData/box/ExtensionLoopTest.txt index c78355dfd31..fe4d735be87 100644 --- a/plugins/atomicfu/atomicfu-compiler/testData/box/ExtensionLoopTest.txt +++ b/plugins/atomicfu/atomicfu-compiler/testData/box/ExtensionLoopTest.txt @@ -1,7 +1,7 @@ @kotlin.Metadata public final class ExtensionLoopTestKt { // source: 'ExtensionLoopTest.kt' - public final static @org.jetbrains.annotations.NotNull field ref$ExtensionLoopTest$VolatileWrapper: Ref$ExtensionLoopTest$VolatileWrapper + private final static @org.jetbrains.annotations.NotNull field ref$ExtensionLoopTest$VolatileWrapper: Ref$ExtensionLoopTest$VolatileWrapper static method (): void public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String private final static method loop$atomicfu$array(p0: java.util.concurrent.atomic.AtomicReferenceArray, p1: int, p2: kotlin.jvm.functions.Function1): void @@ -70,11 +70,12 @@ public final class LoopTest { } @kotlin.Metadata -public final class Ref$ExtensionLoopTest$VolatileWrapper { +final class Ref$ExtensionLoopTest$VolatileWrapper { // source: 'ExtensionLoopTest.kt' private final static @org.jetbrains.annotations.NotNull field ref$FU: java.util.concurrent.atomic.AtomicReferenceFieldUpdater private volatile @kotlin.jvm.Volatile @org.jetbrains.annotations.Nullable field ref: java.lang.Object static method (): void - public method (): void + private method (): void + public synthetic method (p0: kotlin.jvm.internal.DefaultConstructorMarker): void public synthetic final static method access$getRef$FU$p(): java.util.concurrent.atomic.AtomicReferenceFieldUpdater } diff --git a/plugins/atomicfu/atomicfu-compiler/testData/box/FieldInObjectTest.kt b/plugins/atomicfu/atomicfu-compiler/testData/box/FieldInObjectTest.kt index 04b8c2991d0..1a2bb017ef6 100644 --- a/plugins/atomicfu/atomicfu-compiler/testData/box/FieldInObjectTest.kt +++ b/plugins/atomicfu/atomicfu-compiler/testData/box/FieldInObjectTest.kt @@ -3,7 +3,7 @@ import kotlin.test.* import kotlin.random.* object Provider { - val port = atomic(Random.nextInt(20, 90) * 100) + private val port = atomic(Random.nextInt(20, 90) * 100) fun next(): Int = port.incrementAndGet() private val _l = atomic(2424920024888888848) diff --git a/plugins/atomicfu/atomicfu-compiler/testData/box/FieldInObjectTest.txt b/plugins/atomicfu/atomicfu-compiler/testData/box/FieldInObjectTest.txt index a1753d96e24..5b4cfd3736b 100644 --- a/plugins/atomicfu/atomicfu-compiler/testData/box/FieldInObjectTest.txt +++ b/plugins/atomicfu/atomicfu-compiler/testData/box/FieldInObjectTest.txt @@ -4,7 +4,8 @@ public final class DelegatedProvider$_a$DelegatedProvider$VolatileWrapper { private final static @org.jetbrains.annotations.NotNull field _a$FU: java.util.concurrent.atomic.AtomicIntegerFieldUpdater private volatile @kotlin.jvm.Volatile field _a: int static method (): void - public method (): void + private method (): void + public synthetic method (p0: kotlin.jvm.internal.DefaultConstructorMarker): void public synthetic final static method access$get_a$p(p0: DelegatedProvider$_a$DelegatedProvider$VolatileWrapper): int public synthetic final static method access$set_a$p(p0: DelegatedProvider$_a$DelegatedProvider$VolatileWrapper, p1: int): void public final static @org.jetbrains.annotations.NotNull method get_a$FU(): java.util.concurrent.atomic.AtomicIntegerFieldUpdater @@ -16,7 +17,7 @@ public final class DelegatedProvider$_a$DelegatedProvider$VolatileWrapper { public final class DelegatedProvider { // source: 'FieldInObjectTest.kt' public final static @org.jetbrains.annotations.NotNull field INSTANCE: DelegatedProvider - public final static @org.jetbrains.annotations.NotNull field _a$DelegatedProvider$VolatileWrapper: DelegatedProvider$_a$DelegatedProvider$VolatileWrapper + private final static @org.jetbrains.annotations.NotNull field _a$DelegatedProvider$VolatileWrapper: DelegatedProvider$_a$DelegatedProvider$VolatileWrapper private volatile @kotlin.jvm.Volatile field vInt: int static method (): void private method (): void @@ -40,27 +41,28 @@ public final class FieldInObjectTestKt { } @kotlin.Metadata -public final class Provider$Port$Provider$VolatileWrapper { +final class Provider$Port$Provider$VolatileWrapper { // source: 'FieldInObjectTest.kt' private final static @org.jetbrains.annotations.NotNull field port$FU: java.util.concurrent.atomic.AtomicIntegerFieldUpdater private volatile @kotlin.jvm.Volatile field port: int static method (): void - public method (): void - public final static @org.jetbrains.annotations.NotNull method getPort$FU(): java.util.concurrent.atomic.AtomicIntegerFieldUpdater - public final method getPort(): int - public final inner class Provider$Port$Provider$VolatileWrapper + private method (): void + public synthetic method (p0: kotlin.jvm.internal.DefaultConstructorMarker): void + public synthetic final static method access$getPort$FU$p(): java.util.concurrent.atomic.AtomicIntegerFieldUpdater + private final inner class Provider$Port$Provider$VolatileWrapper public final inner class kotlin/random/Random$Default } @kotlin.Metadata -public final class Provider$_l$Provider$VolatileWrapper { +final class Provider$_l$Provider$VolatileWrapper { // source: 'FieldInObjectTest.kt' private final static @org.jetbrains.annotations.NotNull field _l$FU: java.util.concurrent.atomic.AtomicLongFieldUpdater private volatile @kotlin.jvm.Volatile field _l: long static method (): void - public method (): void + private method (): void + public synthetic method (p0: kotlin.jvm.internal.DefaultConstructorMarker): void public synthetic final static method access$get_l$FU$p(): java.util.concurrent.atomic.AtomicLongFieldUpdater - public final inner class Provider$_l$Provider$VolatileWrapper + private final inner class Provider$_l$Provider$VolatileWrapper } @kotlin.Metadata @@ -69,7 +71,8 @@ public final class Provider$_ref$Provider$VolatileWrapper { private final static @org.jetbrains.annotations.NotNull field _ref$FU: java.util.concurrent.atomic.AtomicReferenceFieldUpdater private volatile @kotlin.jvm.Volatile @org.jetbrains.annotations.Nullable field _ref: java.lang.Object static method (): void - public method (): void + private method (): void + public synthetic method (p0: kotlin.jvm.internal.DefaultConstructorMarker): void public final static @org.jetbrains.annotations.NotNull method get_ref$FU(): java.util.concurrent.atomic.AtomicReferenceFieldUpdater public final @org.jetbrains.annotations.Nullable method get_ref(): java.lang.Object public final inner class Provider$_ref$Provider$VolatileWrapper @@ -81,7 +84,8 @@ public final class Provider$_x$Provider$VolatileWrapper { private final static @org.jetbrains.annotations.NotNull field _x$FU: java.util.concurrent.atomic.AtomicIntegerFieldUpdater private volatile @kotlin.jvm.Volatile field _x: int static method (): void - public method (): void + private method (): void + public synthetic method (p0: kotlin.jvm.internal.DefaultConstructorMarker): void public final static @org.jetbrains.annotations.NotNull method get_x$FU(): java.util.concurrent.atomic.AtomicIntegerFieldUpdater public final method get_x(): int public final inner class Provider$_x$Provider$VolatileWrapper @@ -91,25 +95,24 @@ public final class Provider$_x$Provider$VolatileWrapper { public final class Provider { // source: 'FieldInObjectTest.kt' public final static @org.jetbrains.annotations.NotNull field INSTANCE: Provider - public final static @org.jetbrains.annotations.NotNull field _l$Provider$VolatileWrapper: Provider$_l$Provider$VolatileWrapper - public final static @org.jetbrains.annotations.NotNull field _ref$Provider$VolatileWrapper: Provider$_ref$Provider$VolatileWrapper - public final static @org.jetbrains.annotations.NotNull field _x$Provider$VolatileWrapper: Provider$_x$Provider$VolatileWrapper + private final static @org.jetbrains.annotations.NotNull field _l$Provider$VolatileWrapper: Provider$_l$Provider$VolatileWrapper + private final static @org.jetbrains.annotations.NotNull field _ref$Provider$VolatileWrapper: Provider$_ref$Provider$VolatileWrapper + private final static @org.jetbrains.annotations.NotNull field _x$Provider$VolatileWrapper: Provider$_x$Provider$VolatileWrapper private final static @org.jetbrains.annotations.NotNull field intArr: java.util.concurrent.atomic.AtomicIntegerArray private final static @org.jetbrains.annotations.NotNull field longArr: java.util.concurrent.atomic.AtomicLongArray - public final static @org.jetbrains.annotations.NotNull field port$Provider$VolatileWrapper: Provider$Port$Provider$VolatileWrapper + private final static @org.jetbrains.annotations.NotNull field port$Provider$VolatileWrapper: Provider$Port$Provider$VolatileWrapper private final static @org.jetbrains.annotations.NotNull field refArr: java.util.concurrent.atomic.AtomicReferenceArray static method (): void private method (): void public final static @org.jetbrains.annotations.NotNull method getIntArr(): java.util.concurrent.atomic.AtomicIntegerArray public final method getL(): long public final static @org.jetbrains.annotations.NotNull method getLongArr(): java.util.concurrent.atomic.AtomicLongArray - public final static @org.jetbrains.annotations.NotNull method getPort$Provider$VolatileWrapper(): Provider$Port$Provider$VolatileWrapper public final static @org.jetbrains.annotations.NotNull method getRefArr(): java.util.concurrent.atomic.AtomicReferenceArray public final static @org.jetbrains.annotations.NotNull method get_ref$Provider$VolatileWrapper(): Provider$_ref$Provider$VolatileWrapper public final static @org.jetbrains.annotations.NotNull method get_x$Provider$VolatileWrapper(): Provider$_x$Provider$VolatileWrapper public final method next(): int - public final inner class Provider$Port$Provider$VolatileWrapper - public final inner class Provider$_l$Provider$VolatileWrapper + private final inner class Provider$Port$Provider$VolatileWrapper + private final inner class Provider$_l$Provider$VolatileWrapper public final inner class Provider$_ref$Provider$VolatileWrapper public final inner class Provider$_x$Provider$VolatileWrapper } diff --git a/plugins/atomicfu/atomicfu-compiler/testData/box/TopLevelTest.kt b/plugins/atomicfu/atomicfu-compiler/testData/box/TopLevelTest.kt index 9c8df62dd70..c1dfcb7777f 100644 --- a/plugins/atomicfu/atomicfu-compiler/testData/box/TopLevelTest.kt +++ b/plugins/atomicfu/atomicfu-compiler/testData/box/TopLevelTest.kt @@ -153,7 +153,6 @@ class TopLevelArrayTest { val a = abcNode.value assertTrue(refArr[3].compareAndSet(a3, a)) } - } data class ANode(val b: T) @@ -174,4 +173,4 @@ fun box(): String { arrayTest.testBooleanArray() arrayTest.testRefArray() return "OK" -} \ No newline at end of file +} diff --git a/plugins/atomicfu/atomicfu-compiler/testData/box/TopLevelTest.txt b/plugins/atomicfu/atomicfu-compiler/testData/box/TopLevelTest.txt index 6b2bd30c0f7..9ecb4924289 100644 --- a/plugins/atomicfu/atomicfu-compiler/testData/box/TopLevelTest.txt +++ b/plugins/atomicfu/atomicfu-compiler/testData/box/TopLevelTest.txt @@ -1,10 +1,11 @@ @kotlin.Metadata -public final class A$TopLevelTest$VolatileWrapper { +final class A$TopLevelTest$VolatileWrapper { // source: 'TopLevelTest.kt' private final static @org.jetbrains.annotations.NotNull field a$FU: java.util.concurrent.atomic.AtomicIntegerFieldUpdater private volatile @kotlin.jvm.Volatile field a: int static method (): void - public method (): void + private method (): void + public synthetic method (p0: kotlin.jvm.internal.DefaultConstructorMarker): void public synthetic final static method access$getA$FU$p(): java.util.concurrent.atomic.AtomicIntegerFieldUpdater } @@ -23,32 +24,35 @@ public final class ANode { } @kotlin.Metadata -public final class AbcNode$TopLevelTest$VolatileWrapper { +final class AbcNode$TopLevelTest$VolatileWrapper { // source: 'TopLevelTest.kt' private final static @org.jetbrains.annotations.NotNull field abcNode$FU: java.util.concurrent.atomic.AtomicReferenceFieldUpdater private volatile @kotlin.jvm.Volatile @org.jetbrains.annotations.Nullable field abcNode: java.lang.Object static method (): void - public method (): void + private method (): void + public synthetic method (p0: kotlin.jvm.internal.DefaultConstructorMarker): void public synthetic final static method access$getAbcNode$FU$p(): java.util.concurrent.atomic.AtomicReferenceFieldUpdater } @kotlin.Metadata -public final class Any$TopLevelTest$VolatileWrapper { +final class Any$TopLevelTest$VolatileWrapper { // source: 'TopLevelTest.kt' private final static @org.jetbrains.annotations.NotNull field any$FU: java.util.concurrent.atomic.AtomicReferenceFieldUpdater private volatile @kotlin.jvm.Volatile @org.jetbrains.annotations.Nullable field any: java.lang.Object static method (): void - public method (): void + private method (): void + public synthetic method (p0: kotlin.jvm.internal.DefaultConstructorMarker): void public synthetic final static method access$getAny$FU$p(): java.util.concurrent.atomic.AtomicReferenceFieldUpdater } @kotlin.Metadata -public final class B$TopLevelTest$VolatileWrapper { +final class B$TopLevelTest$VolatileWrapper { // source: 'TopLevelTest.kt' private final static @org.jetbrains.annotations.NotNull field b$FU: java.util.concurrent.atomic.AtomicLongFieldUpdater private volatile @kotlin.jvm.Volatile field b: long static method (): void - public method (): void + private method (): void + public synthetic method (p0: kotlin.jvm.internal.DefaultConstructorMarker): void public synthetic final static method access$getB$FU$p(): java.util.concurrent.atomic.AtomicLongFieldUpdater } @@ -67,12 +71,13 @@ public final class BNode { } @kotlin.Metadata -public final class C$TopLevelTest$VolatileWrapper { +final class C$TopLevelTest$VolatileWrapper { // source: 'TopLevelTest.kt' private final static @org.jetbrains.annotations.NotNull field c$FU: java.util.concurrent.atomic.AtomicIntegerFieldUpdater private volatile @kotlin.jvm.Volatile field c: int static method (): void - public method (): void + private method (): void + public synthetic method (p0: kotlin.jvm.internal.DefaultConstructorMarker): void public synthetic final static method access$getC$FU$p(): java.util.concurrent.atomic.AtomicIntegerFieldUpdater } @@ -114,19 +119,24 @@ public final class TopLevelPrimitiveTest { @kotlin.Metadata public final class TopLevelTestKt { // source: 'TopLevelTest.kt' - public final static @org.jetbrains.annotations.NotNull field a$TopLevelTest$VolatileWrapper: A$TopLevelTest$VolatileWrapper - public final static @org.jetbrains.annotations.NotNull field abcNode$TopLevelTest$VolatileWrapper: AbcNode$TopLevelTest$VolatileWrapper - public final static @org.jetbrains.annotations.NotNull field any$TopLevelTest$VolatileWrapper: Any$TopLevelTest$VolatileWrapper + private final static @org.jetbrains.annotations.NotNull field a$TopLevelTest$VolatileWrapper: A$TopLevelTest$VolatileWrapper + private final static @org.jetbrains.annotations.NotNull field abcNode$TopLevelTest$VolatileWrapper: AbcNode$TopLevelTest$VolatileWrapper + private final static @org.jetbrains.annotations.NotNull field any$TopLevelTest$VolatileWrapper: Any$TopLevelTest$VolatileWrapper private final static @org.jetbrains.annotations.NotNull field anyRefArr: java.util.concurrent.atomic.AtomicReferenceArray - public final static @org.jetbrains.annotations.NotNull field b$TopLevelTest$VolatileWrapper: B$TopLevelTest$VolatileWrapper + private final static @org.jetbrains.annotations.NotNull field b$TopLevelTest$VolatileWrapper: B$TopLevelTest$VolatileWrapper private final static @org.jetbrains.annotations.NotNull field booleanArr: java.util.concurrent.atomic.AtomicIntegerArray - public final static @org.jetbrains.annotations.NotNull field c$TopLevelTest$VolatileWrapper: C$TopLevelTest$VolatileWrapper + private final static @org.jetbrains.annotations.NotNull field c$TopLevelTest$VolatileWrapper: C$TopLevelTest$VolatileWrapper private final static @org.jetbrains.annotations.NotNull field intArr: java.util.concurrent.atomic.AtomicIntegerArray private final static @org.jetbrains.annotations.NotNull field longArr: java.util.concurrent.atomic.AtomicLongArray private final static @org.jetbrains.annotations.NotNull field refArr: java.util.concurrent.atomic.AtomicReferenceArray private final static @org.jetbrains.annotations.NotNull field stringAtomicNullArr: java.util.concurrent.atomic.AtomicReferenceArray static method (): void + public synthetic final static method access$getA$TopLevelTest$VolatileWrapper$p(): A$TopLevelTest$VolatileWrapper + public synthetic final static method access$getAbcNode$TopLevelTest$VolatileWrapper$p(): AbcNode$TopLevelTest$VolatileWrapper + public synthetic final static method access$getAny$TopLevelTest$VolatileWrapper$p(): Any$TopLevelTest$VolatileWrapper + public synthetic final static method access$getB$TopLevelTest$VolatileWrapper$p(): B$TopLevelTest$VolatileWrapper public synthetic final static method access$getBooleanArr$p(): java.util.concurrent.atomic.AtomicIntegerArray + public synthetic final static method access$getC$TopLevelTest$VolatileWrapper$p(): C$TopLevelTest$VolatileWrapper public synthetic final static method access$getIntArr$p(): java.util.concurrent.atomic.AtomicIntegerArray public synthetic final static method access$getLongArr$p(): java.util.concurrent.atomic.AtomicLongArray public synthetic final static method access$getRefArr$p(): java.util.concurrent.atomic.AtomicReferenceArray diff --git a/plugins/atomicfu/atomicfu-compiler/testData/box/UncheckedCastTest.txt b/plugins/atomicfu/atomicfu-compiler/testData/box/UncheckedCastTest.txt index c1edaea84e1..d8cad8d3b50 100644 --- a/plugins/atomicfu/atomicfu-compiler/testData/box/UncheckedCastTest.txt +++ b/plugins/atomicfu/atomicfu-compiler/testData/box/UncheckedCastTest.txt @@ -1,10 +1,11 @@ @kotlin.Metadata -public final class TopLevelS$UncheckedCastTest$VolatileWrapper { +final class TopLevelS$UncheckedCastTest$VolatileWrapper { // source: 'UncheckedCastTest.kt' private final static @org.jetbrains.annotations.NotNull field topLevelS$FU: java.util.concurrent.atomic.AtomicReferenceFieldUpdater private volatile @kotlin.jvm.Volatile @org.jetbrains.annotations.Nullable field topLevelS: java.lang.Object static method (): void - public method (): void + private method (): void + public synthetic method (p0: kotlin.jvm.internal.DefaultConstructorMarker): void public synthetic final static method access$getTopLevelS$FU$p(): java.util.concurrent.atomic.AtomicReferenceFieldUpdater } @@ -46,7 +47,8 @@ public final class UncheckedCastTest { @kotlin.Metadata public final class UncheckedCastTestKt { // source: 'UncheckedCastTest.kt' - public final static @org.jetbrains.annotations.NotNull field topLevelS$UncheckedCastTest$VolatileWrapper: TopLevelS$UncheckedCastTest$VolatileWrapper + private final static @org.jetbrains.annotations.NotNull field topLevelS$UncheckedCastTest$VolatileWrapper: TopLevelS$UncheckedCastTest$VolatileWrapper static method (): void + public synthetic final static method access$getTopLevelS$UncheckedCastTest$VolatileWrapper$p(): TopLevelS$UncheckedCastTest$VolatileWrapper public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String }