From b1bd138afb416344571bc70a15b5f6f03156dae6 Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Tue, 6 Oct 2020 15:06:20 +0300 Subject: [PATCH] JVM_IR fix inline class <-> collection stubs issues Move collectionStubMethodLowering before jvmInlineClassPhase, and make them interact properly. Note that some issues still remain in inline class <-> special bridges interaction. KT-40187 KT-42469 --- .../kotlin/fir/Fir2IrTextTestGenerated.java | 5 + .../jetbrains/kotlin/backend/jvm/JvmLower.kt | 2 +- .../jvm/lower/JvmInlineClassLowering.kt | 13 +- .../jvm/lower/inlineclasses/InlineClassAbi.kt | 7 +- .../MemoizedInlineClassReplacements.kt | 19 +- .../declarations/impl/IrValueParameterImpl.kt | 2 +- .../collection.kt | 11 + .../collection.txt | 53 ++++ .../collection_ir.txt | 53 ++++ .../inlineCollectionOfInlineClass/iterable.kt | 7 + .../iterable.txt | 34 +++ .../inlineCollectionOfInlineClass/iterator.kt | 8 + .../iterator.txt | 38 +++ .../inlineCollectionOfInlineClass/list.kt | 19 ++ .../inlineCollectionOfInlineClass/list.txt | 75 ++++++ .../inlineCollectionOfInlineClass/map.kt | 16 ++ .../inlineCollectionOfInlineClass/map.txt | 77 ++++++ .../inlineCollectionOfInlineClass/mapEntry.kt | 9 + .../mapEntry.txt | 57 ++++ .../mapEntry_ir.txt | 57 ++++ .../inlineCollectionOfInlineClass/map_ir.txt | 78 ++++++ .../mutableCollection.kt | 20 ++ .../mutableCollection.txt | 60 +++++ .../mutableIterable.kt | 8 + .../mutableIterable.txt | 34 +++ .../mutableIterator.kt | 9 + .../mutableIterator.txt | 39 +++ .../mutableList.kt | 29 ++ .../mutableList.txt | 87 ++++++ .../mutableMap.kt | 20 ++ .../mutableMap.txt | 82 ++++++ .../mutableMapEntry.kt | 10 + .../mutableMapEntry.txt | 58 ++++ .../mutableMap_ir.txt | 82 ++++++ .../mutableSet.kt | 19 ++ .../mutableSet.txt | 60 +++++ .../inlineCollectionOfInlineClass/set.kt | 11 + .../inlineCollectionOfInlineClass/set.txt | 53 ++++ .../inlineCollectionOfInlineClass/set_ir.txt | 53 ++++ ...nericMethodWithInlineClassParameterType.kt | 11 + ...ericMethodWithInlineClassParameterType.txt | 44 ++++ ...gGenericMethodWithInlineClassReturnType.kt | 9 + ...GenericMethodWithInlineClassReturnType.txt | 26 ++ .../inlineCollectionOfInlineClass.kt | 15 ++ .../inlineCollectionOfInlineClass.txt | 247 ++++++++++++++++++ .../codegen/AbstractBytecodeListingTest.kt | 50 +++- .../codegen/BytecodeListingTestGenerated.java | 93 +++++++ .../ir/IrBytecodeListingTestGenerated.java | 93 +++++++ .../kotlin/ir/IrTextTestCaseGenerated.java | 5 + 49 files changed, 1941 insertions(+), 26 deletions(-) create mode 100644 compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/collection.kt create mode 100644 compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/collection.txt create mode 100644 compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/collection_ir.txt create mode 100644 compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/iterable.kt create mode 100644 compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/iterable.txt create mode 100644 compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/iterator.kt create mode 100644 compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/iterator.txt create mode 100644 compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/list.kt create mode 100644 compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/list.txt create mode 100644 compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/map.kt create mode 100644 compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/map.txt create mode 100644 compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mapEntry.kt create mode 100644 compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mapEntry.txt create mode 100644 compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mapEntry_ir.txt create mode 100644 compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/map_ir.txt create mode 100644 compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableCollection.kt create mode 100644 compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableCollection.txt create mode 100644 compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableIterable.kt create mode 100644 compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableIterable.txt create mode 100644 compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableIterator.kt create mode 100644 compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableIterator.txt create mode 100644 compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableList.kt create mode 100644 compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableList.txt create mode 100644 compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableMap.kt create mode 100644 compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableMap.txt create mode 100644 compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableMapEntry.kt create mode 100644 compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableMapEntry.txt create mode 100644 compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableMap_ir.txt create mode 100644 compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableSet.kt create mode 100644 compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableSet.txt create mode 100644 compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/set.kt create mode 100644 compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/set.txt create mode 100644 compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/set_ir.txt create mode 100644 compiler/testData/codegen/bytecodeListing/inlineClasses/overridingGenericMethodWithInlineClassParameterType.kt create mode 100644 compiler/testData/codegen/bytecodeListing/inlineClasses/overridingGenericMethodWithInlineClassParameterType.txt create mode 100644 compiler/testData/codegen/bytecodeListing/inlineClasses/overridingGenericMethodWithInlineClassReturnType.kt create mode 100644 compiler/testData/codegen/bytecodeListing/inlineClasses/overridingGenericMethodWithInlineClassReturnType.txt create mode 100644 compiler/testData/ir/irText/declarations/inlineCollectionOfInlineClass.kt create mode 100644 compiler/testData/ir/irText/declarations/inlineCollectionOfInlineClass.txt diff --git a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java index 26c2417dd2b..f2216ebac8a 100644 --- a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java @@ -324,6 +324,11 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { runTest("compiler/testData/ir/irText/declarations/genericDelegatedProperty.kt"); } + @TestMetadata("inlineCollectionOfInlineClass.kt") + public void testInlineCollectionOfInlineClass() throws Exception { + runTest("compiler/testData/ir/irText/declarations/inlineCollectionOfInlineClass.kt"); + } + @TestMetadata("interfaceProperties.kt") public void testInterfaceProperties() throws Exception { runTest("compiler/testData/ir/irText/declarations/interfaceProperties.kt"); diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmLower.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmLower.kt index 00fc7ac5e7d..4d6ca5f70c9 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmLower.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmLower.kt @@ -300,6 +300,7 @@ private val jvmFilePhases = listOf( rangeContainsLoweringPhase, forLoopsPhase, + collectionStubMethodLowering, jvmInlineClassPhase, sharedVariablesPhase, @@ -348,7 +349,6 @@ private val jvmFilePhases = listOf( staticInitializersPhase, initializersPhase, initializersCleanupPhase, - collectionStubMethodLowering, functionNVarargBridgePhase, jvmStaticAnnotationPhase, staticDefaultFunctionPhase, diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmInlineClassLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmInlineClassLowering.kt index afbfc1709d9..ad39449d8ed 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmInlineClassLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmInlineClassLowering.kt @@ -48,8 +48,9 @@ val jvmInlineClassPhase = makeIrFilePhase( name = "Inline Classes", description = "Lower inline classes", // forLoopsPhase may produce UInt and ULong which are inline classes. - // standard library replacements are done on the unmangled names for UInt and ULong classes. - prerequisite = setOf(forLoopsPhase, jvmStandardLibraryBuiltInsPhase) + // Standard library replacements are done on the unmangled names for UInt and ULong classes. + // Collection stubs may require mangling by inline class rules. + prerequisite = setOf(forLoopsPhase, jvmStandardLibraryBuiltInsPhase, collectionStubMethodLowering) ) /** @@ -131,9 +132,9 @@ private class JvmInlineClassLowering(private val context: JvmBackendContext) : F val bridgeFunction = createBridgeDeclaration( function, when { - // If the original function has value parameters which need mangling we still need to replace + // If the original function has signature which need mangling we still need to replace // it with a mangled version. - !function.isFakeOverride && function.fullValueParameterList.any { it.type.requiresMangling } -> + !function.isFakeOverride && function.signatureRequiresMangling() -> replacement.name // Since we remove the corresponding property symbol from the bridge we need to resolve getter/setter // names at this point. @@ -160,6 +161,10 @@ private class JvmInlineClassLowering(private val context: JvmBackendContext) : F return listOf(replacement, bridgeFunction) } + private fun IrSimpleFunction.signatureRequiresMangling() = + fullValueParameterList.any { it.type.requiresMangling } || + context.state.functionsWithInlineClassReturnTypesMangled && returnType.requiresMangling + // We may need to add a bridge method for inline class methods with static replacements. Ideally, we'd do this in BridgeLowering, // but unfortunately this is a special case in the old backend. The bridge method is not marked as such and does not follow the normal // visibility rules for bridge methods. diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/InlineClassAbi.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/InlineClassAbi.kt index b4006b03595..204849bdb18 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/InlineClassAbi.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/InlineClassAbi.kt @@ -76,8 +76,11 @@ object InlineClassAbi { hashSuffix(irFunction) mangleReturnTypes && irFunction.hasMangledReturnType -> returnHashSuffix(irFunction) - (irFunction.parent as? IrClass)?.isInline == true -> "impl" - else -> return irFunction.name + (irFunction.parent as? IrClass)?.isInline == true && + irFunction.origin != IrDeclarationOrigin.IR_BUILTINS_STUB -> + "impl" + else -> + return irFunction.name } val base = when { diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/MemoizedInlineClassReplacements.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/MemoizedInlineClassReplacements.kt index 5c65f1859f8..c82b72640a6 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/MemoizedInlineClassReplacements.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/MemoizedInlineClassReplacements.kt @@ -13,8 +13,8 @@ import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin import org.jetbrains.kotlin.backend.jvm.ir.isStaticInlineClassReplacement import org.jetbrains.kotlin.backend.jvm.lower.inlineclasses.InlineClassAbi.mangledNameFor import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper -import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.DescriptorVisibilities +import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.ir.builders.declarations.addValueParameter import org.jetbrains.kotlin.ir.builders.declarations.buildFun import org.jetbrains.kotlin.ir.builders.declarations.buildProperty @@ -46,7 +46,8 @@ class MemoizedInlineClassReplacements(private val mangleReturnTypes: Boolean, pr it.origin == IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA || (it.origin == IrDeclarationOrigin.DELEGATED_PROPERTY_ACCESSOR && it.visibility == DescriptorVisibilities.LOCAL) || it.isStaticInlineClassReplacement || - it.origin.isSynthetic -> null + it.origin.isSynthetic -> + null it.isInlineClassFieldGetter -> if (it.hasMangledReturnType) @@ -56,11 +57,21 @@ class MemoizedInlineClassReplacements(private val mangleReturnTypes: Boolean, pr // Mangle all functions in the body of an inline class it.parent.safeAs()?.isInline == true -> - createStaticReplacement(it) + when (it.origin) { + IrDeclarationOrigin.IR_BUILTINS_STUB -> + createMethodReplacement(it) + IrDeclarationOrigin.BRIDGE_SPECIAL -> + null + else -> + createStaticReplacement(it) + } // Otherwise, mangle functions with mangled parameters, ignoring constructors it is IrSimpleFunction && (it.hasMangledParameters || mangleReturnTypes && it.hasMangledReturnType) -> - if (it.dispatchReceiverParameter != null) createMethodReplacement(it) else createStaticReplacement(it) + if (it.dispatchReceiverParameter != null) + createMethodReplacement(it) + else + createStaticReplacement(it) else -> null diff --git a/compiler/ir/ir.tree.impl/src/org/jetbrains/kotlin/ir/declarations/impl/IrValueParameterImpl.kt b/compiler/ir/ir.tree.impl/src/org/jetbrains/kotlin/ir/declarations/impl/IrValueParameterImpl.kt index 8a8dd52fbf9..ae8a326a129 100644 --- a/compiler/ir/ir.tree.impl/src/org/jetbrains/kotlin/ir/declarations/impl/IrValueParameterImpl.kt +++ b/compiler/ir/ir.tree.impl/src/org/jetbrains/kotlin/ir/declarations/impl/IrValueParameterImpl.kt @@ -18,9 +18,9 @@ package org.jetbrains.kotlin.ir.declarations.impl import org.jetbrains.kotlin.descriptors.ParameterDescriptor import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI -import org.jetbrains.kotlin.ir.declarations.IrFactory import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent +import org.jetbrains.kotlin.ir.declarations.IrFactory import org.jetbrains.kotlin.ir.declarations.IrValueParameter import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.expressions.IrExpressionBody diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/collection.kt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/collection.kt new file mode 100644 index 00000000000..51607a95409 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/collection.kt @@ -0,0 +1,11 @@ +// IGNORE_ANNOTATIONS + +inline class IT(val x: Int) + +inline class InlineCollection(private val c: Collection) : Collection { + override val size: Int get() = c.size + override fun contains(element: IT): Boolean = c.contains(element) + override fun containsAll(elements: Collection): Boolean = c.containsAll(elements) + override fun isEmpty(): Boolean = c.isEmpty() + override fun iterator(): Iterator = c.iterator() +} diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/collection.txt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/collection.txt new file mode 100644 index 00000000000..fbfb88e8c87 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/collection.txt @@ -0,0 +1,53 @@ +public final class IT { + // source: 'collection.kt' + private final field x: int + private synthetic method (p0: int): void + public synthetic final static method box-impl(p0: int): IT + public static method constructor-impl(p0: int): int + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: int, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: int, p1: int): boolean + public final method getX(): int + public method hashCode(): int + public static method hashCode-impl(p0: int): int + public method toString(): java.lang.String + public static method toString-impl(p0: int): java.lang.String + public synthetic final method unbox-impl(): int +} + +public final class InlineCollection { + // source: 'collection.kt' + private final field c: java.util.Collection + private synthetic method (p0: java.util.Collection): void + public synthetic method add(p0: java.lang.Object): boolean + public method add-jHY5zpA(p0: int): boolean + public method addAll(p0: java.util.Collection): boolean + public synthetic final static method box-impl(p0: java.util.Collection): InlineCollection + public method clear(): void + public static method constructor-impl(p0: java.util.Collection): java.util.Collection + public bridge final method contains(p0: java.lang.Object): boolean + public method contains-jHY5zpA(p0: int): boolean + public static method contains-jHY5zpA(p0: java.util.Collection, p1: int): boolean + public method containsAll(p0: java.util.Collection): boolean + public static method containsAll-impl(p0: java.util.Collection, p1: java.util.Collection): boolean + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: java.util.Collection, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: java.util.Collection, p1: java.util.Collection): boolean + public method getSize(): int + public static method getSize-impl(p0: java.util.Collection): int + public method hashCode(): int + public static method hashCode-impl(p0: java.util.Collection): int + public method isEmpty(): boolean + public static method isEmpty-impl(p0: java.util.Collection): boolean + public method iterator(): java.util.Iterator + public static method iterator-impl(p0: java.util.Collection): java.util.Iterator + public method remove(p0: java.lang.Object): boolean + public method removeAll(p0: java.util.Collection): boolean + public method retainAll(p0: java.util.Collection): boolean + public bridge final method size(): int + public method toArray(): java.lang.Object[] + public method toArray(p0: java.lang.Object[]): java.lang.Object[] + public method toString(): java.lang.String + public static method toString-impl(p0: java.util.Collection): java.lang.String + public synthetic final method unbox-impl(): java.util.Collection +} diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/collection_ir.txt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/collection_ir.txt new file mode 100644 index 00000000000..120be8748b7 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/collection_ir.txt @@ -0,0 +1,53 @@ +public final class IT { + // source: 'collection.kt' + private final field x: int + private synthetic method (p0: int): void + public synthetic final static method box-impl(p0: int): IT + public static method constructor-impl(p0: int): int + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: int, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: int, p1: int): boolean + public final method getX(): int + public method hashCode(): int + public static method hashCode-impl(p0: int): int + public method toString(): java.lang.String + public static method toString-impl(p0: int): java.lang.String + public synthetic final method unbox-impl(): int +} + +public final class InlineCollection { + // source: 'collection.kt' + private final field c: java.util.Collection + private synthetic method (p0: java.util.Collection): void + public synthetic bridge method add(p0: java.lang.Object): boolean + public method add-jHY5zpA(p0: int): boolean + public method addAll(p0: java.util.Collection): boolean + public synthetic final static method box-impl(p0: java.util.Collection): InlineCollection + public method clear(): void + public static method constructor-impl(p0: java.util.Collection): java.util.Collection + public synthetic bridge method contains(p0: java.lang.Object): boolean + public method contains-jHY5zpA(p0: int): boolean + public static method contains-jHY5zpA(p0: java.util.Collection, p1: int): boolean + public method containsAll(p0: java.util.Collection): boolean + public static method containsAll-impl(p0: java.util.Collection, p1: java.util.Collection): boolean + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: java.util.Collection, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: java.util.Collection, p1: java.util.Collection): boolean + public method getSize(): int + public static method getSize-impl(p0: java.util.Collection): int + public method hashCode(): int + public static method hashCode-impl(p0: java.util.Collection): int + public method isEmpty(): boolean + public static method isEmpty-impl(p0: java.util.Collection): boolean + public method iterator(): java.util.Iterator + public static method iterator-impl(p0: java.util.Collection): java.util.Iterator + public method remove(p0: java.lang.Object): boolean + public method removeAll(p0: java.util.Collection): boolean + public method retainAll(p0: java.util.Collection): boolean + public synthetic bridge method size(): int + public method toArray(): java.lang.Object[] + public method toArray(p0: java.lang.Object[]): java.lang.Object[] + public method toString(): java.lang.String + public static method toString-impl(p0: java.util.Collection): java.lang.String + public synthetic final method unbox-impl(): java.util.Collection +} diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/iterable.kt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/iterable.kt new file mode 100644 index 00000000000..63696803152 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/iterable.kt @@ -0,0 +1,7 @@ +// IGNORE_ANNOTATIONS + +inline class IT(val x: Int) + +inline class InlineIterable(private val it: Iterable) : Iterable { + override fun iterator(): Iterator = it.iterator() +} diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/iterable.txt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/iterable.txt new file mode 100644 index 00000000000..47c2863668c --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/iterable.txt @@ -0,0 +1,34 @@ +public final class IT { + // source: 'iterable.kt' + private final field x: int + private synthetic method (p0: int): void + public synthetic final static method box-impl(p0: int): IT + public static method constructor-impl(p0: int): int + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: int, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: int, p1: int): boolean + public final method getX(): int + public method hashCode(): int + public static method hashCode-impl(p0: int): int + public method toString(): java.lang.String + public static method toString-impl(p0: int): java.lang.String + public synthetic final method unbox-impl(): int +} + +public final class InlineIterable { + // source: 'iterable.kt' + private final field it: java.lang.Iterable + private synthetic method (p0: java.lang.Iterable): void + public synthetic final static method box-impl(p0: java.lang.Iterable): InlineIterable + public static method constructor-impl(p0: java.lang.Iterable): java.lang.Iterable + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: java.lang.Iterable, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: java.lang.Iterable, p1: java.lang.Iterable): boolean + public method hashCode(): int + public static method hashCode-impl(p0: java.lang.Iterable): int + public method iterator(): java.util.Iterator + public static method iterator-impl(p0: java.lang.Iterable): java.util.Iterator + public method toString(): java.lang.String + public static method toString-impl(p0: java.lang.Iterable): java.lang.String + public synthetic final method unbox-impl(): java.lang.Iterable +} diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/iterator.kt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/iterator.kt new file mode 100644 index 00000000000..7e8e26d015a --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/iterator.kt @@ -0,0 +1,8 @@ +// IGNORE_ANNOTATIONS + +inline class IT(val x: Int) + +inline class InlineIterator(private val it: Iterator) : Iterator { + override fun hasNext(): Boolean = it.hasNext() + override fun next(): IT = it.next() +} diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/iterator.txt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/iterator.txt new file mode 100644 index 00000000000..2bf8bbb0474 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/iterator.txt @@ -0,0 +1,38 @@ +public final class IT { + // source: 'iterator.kt' + private final field x: int + private synthetic method (p0: int): void + public synthetic final static method box-impl(p0: int): IT + public static method constructor-impl(p0: int): int + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: int, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: int, p1: int): boolean + public final method getX(): int + public method hashCode(): int + public static method hashCode-impl(p0: int): int + public method toString(): java.lang.String + public static method toString-impl(p0: int): java.lang.String + public synthetic final method unbox-impl(): int +} + +public final class InlineIterator { + // source: 'iterator.kt' + private final field it: java.util.Iterator + private synthetic method (p0: java.util.Iterator): void + public synthetic final static method box-impl(p0: java.util.Iterator): InlineIterator + public static method constructor-impl(p0: java.util.Iterator): java.util.Iterator + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: java.util.Iterator, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: java.util.Iterator, p1: java.util.Iterator): boolean + public method hasNext(): boolean + public static method hasNext-impl(p0: java.util.Iterator): boolean + public method hashCode(): int + public static method hashCode-impl(p0: java.util.Iterator): int + public synthetic bridge method next(): java.lang.Object + public method next-XAcLw3A(): int + public static method next-XAcLw3A(p0: java.util.Iterator): int + public method remove(): void + public method toString(): java.lang.String + public static method toString-impl(p0: java.util.Iterator): java.lang.String + public synthetic final method unbox-impl(): java.util.Iterator +} diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/list.kt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/list.kt new file mode 100644 index 00000000000..799130ec4b9 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/list.kt @@ -0,0 +1,19 @@ +// IGNORE_ANNOTATIONS +// IGNORE_BACKEND: JVM_IR +// ^ TODO: special bridges <-> inline classes interaction + +inline class IT(val x: Int) + +inline class InlineList(private val list: List) : List { + override val size: Int get() = list.size + override fun contains(element: IT): Boolean = list.contains(element) + override fun containsAll(elements: Collection): Boolean = list.containsAll(elements) + override fun get(index: Int): IT = list[index] + override fun indexOf(element: IT): Int = list.indexOf(element) + override fun isEmpty(): Boolean = list.isEmpty() + override fun iterator(): Iterator = list.iterator() + override fun lastIndexOf(element: IT): Int = list.lastIndexOf(element) + override fun listIterator(): ListIterator = list.listIterator() + override fun listIterator(index: Int): ListIterator = list.listIterator(index) + override fun subList(fromIndex: Int, toIndex: Int): List = list.subList(fromIndex, toIndex) +} diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/list.txt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/list.txt new file mode 100644 index 00000000000..749284caf33 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/list.txt @@ -0,0 +1,75 @@ +public final class IT { + // source: 'list.kt' + private final field x: int + private synthetic method (p0: int): void + public synthetic final static method box-impl(p0: int): IT + public static method constructor-impl(p0: int): int + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: int, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: int, p1: int): boolean + public final method getX(): int + public method hashCode(): int + public static method hashCode-impl(p0: int): int + public method toString(): java.lang.String + public static method toString-impl(p0: int): java.lang.String + public synthetic final method unbox-impl(): int +} + +public final class InlineList { + // source: 'list.kt' + private final field list: java.util.List + private synthetic method (p0: java.util.List): void + public synthetic method add(p0: int, p1: java.lang.Object): void + public synthetic method add(p0: java.lang.Object): boolean + public method add-_bimVNw(p0: int, p1: int): void + public method add-jHY5zpA(p0: int): boolean + public method addAll(p0: int, p1: java.util.Collection): boolean + public method addAll(p0: java.util.Collection): boolean + public synthetic final static method box-impl(p0: java.util.List): InlineList + public method clear(): void + public static method constructor-impl(p0: java.util.List): java.util.List + public bridge final method contains(p0: java.lang.Object): boolean + public method contains-jHY5zpA(p0: int): boolean + public static method contains-jHY5zpA(p0: java.util.List, p1: int): boolean + public method containsAll(p0: java.util.Collection): boolean + public static method containsAll-impl(p0: java.util.List, p1: java.util.Collection): boolean + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: java.util.List, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: java.util.List, p1: java.util.List): boolean + public synthetic bridge method get(p0: int): java.lang.Object + public method get-XAcLw3A(p0: int): int + public static method get-XAcLw3A(p0: java.util.List, p1: int): int + public method getSize(): int + public static method getSize-impl(p0: java.util.List): int + public method hashCode(): int + public static method hashCode-impl(p0: java.util.List): int + public bridge final method indexOf(p0: java.lang.Object): int + public method indexOf-jHY5zpA(p0: int): int + public static method indexOf-jHY5zpA(p0: java.util.List, p1: int): int + public method isEmpty(): boolean + public static method isEmpty-impl(p0: java.util.List): boolean + public method iterator(): java.util.Iterator + public static method iterator-impl(p0: java.util.List): java.util.Iterator + public bridge final method lastIndexOf(p0: java.lang.Object): int + public method lastIndexOf-jHY5zpA(p0: int): int + public static method lastIndexOf-jHY5zpA(p0: java.util.List, p1: int): int + public method listIterator(): java.util.ListIterator + public method listIterator(p0: int): java.util.ListIterator + public static method listIterator-impl(p0: java.util.List): java.util.ListIterator + public static method listIterator-impl(p0: java.util.List, p1: int): java.util.ListIterator + public method remove(p0: int): int + public synthetic method remove(p0: int): java.lang.Object + public method remove(p0: java.lang.Object): boolean + public method removeAll(p0: java.util.Collection): boolean + public method retainAll(p0: java.util.Collection): boolean + public synthetic method set(p0: int, p1: java.lang.Object): java.lang.Object + public method set-_bimVNw(p0: int, p1: int): int + public bridge final method size(): int + public method subList(p0: int, p1: int): java.util.List + public static method subList-impl(p0: java.util.List, p1: int, p2: int): java.util.List + public method toArray(): java.lang.Object[] + public method toArray(p0: java.lang.Object[]): java.lang.Object[] + public method toString(): java.lang.String + public static method toString-impl(p0: java.util.List): java.lang.String + public synthetic final method unbox-impl(): java.util.List +} diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/map.kt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/map.kt new file mode 100644 index 00000000000..c02a46530f3 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/map.kt @@ -0,0 +1,16 @@ +// IGNORE_ANNOTATIONS + +inline class IK(val x: Int) +inline class IV(val x: Double) + +inline class InlineMap(private val map: Map) : Map { + override val entries: Set> get() = map.entries + override val keys: Set get() = map.keys + override val size: Int get() = map.size + override val values: Collection get() = map.values + override fun containsKey(key: IK): Boolean = map.containsKey(key) + override fun containsValue(value: IV): Boolean = map.containsValue(value) + override fun get(key: IK): IV? = map[key] + override fun isEmpty(): Boolean = map.isEmpty() +} + diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/map.txt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/map.txt new file mode 100644 index 00000000000..f49fe34f3c4 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/map.txt @@ -0,0 +1,77 @@ +public final class IK { + // source: 'map.kt' + private final field x: int + private synthetic method (p0: int): void + public synthetic final static method box-impl(p0: int): IK + public static method constructor-impl(p0: int): int + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: int, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: int, p1: int): boolean + public final method getX(): int + public method hashCode(): int + public static method hashCode-impl(p0: int): int + public method toString(): java.lang.String + public static method toString-impl(p0: int): java.lang.String + public synthetic final method unbox-impl(): int +} + +public final class IV { + // source: 'map.kt' + private final field x: double + private synthetic method (p0: double): void + public synthetic final static method box-impl(p0: double): IV + public static method constructor-impl(p0: double): double + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: double, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: double, p1: double): boolean + public final method getX(): double + public method hashCode(): int + public static method hashCode-impl(p0: double): int + public method toString(): java.lang.String + public static method toString-impl(p0: double): java.lang.String + public synthetic final method unbox-impl(): double +} + +public final class InlineMap { + // source: 'map.kt' + private final field map: java.util.Map + private synthetic method (p0: java.util.Map): void + public synthetic final static method box-impl(p0: java.util.Map): InlineMap + public method clear(): void + public static method constructor-impl(p0: java.util.Map): java.util.Map + public bridge final method containsKey(p0: java.lang.Object): boolean + public method containsKey-FSIWiWE(p0: int): boolean + public static method containsKey-FSIWiWE(p0: java.util.Map, p1: int): boolean + public bridge final method containsValue(p0: java.lang.Object): boolean + public method containsValue-jbX5DO8(p0: double): boolean + public static method containsValue-jbX5DO8(p0: java.util.Map, p1: double): boolean + public bridge final method entrySet(): java.util.Set + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: java.util.Map, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: java.util.Map, p1: java.util.Map): boolean + public bridge final method get(p0: java.lang.Object): java.lang.Object + public method get-FSIWiWE(p0: int): IV + public static method get-FSIWiWE(p0: java.util.Map, p1: int): IV + public method getEntries(): java.util.Set + public static method getEntries-impl(p0: java.util.Map): java.util.Set + public method getKeys(): java.util.Set + public static method getKeys-impl(p0: java.util.Map): java.util.Set + public method getSize(): int + public static method getSize-impl(p0: java.util.Map): int + public method getValues(): java.util.Collection + public static method getValues-impl(p0: java.util.Map): java.util.Collection + public method hashCode(): int + public static method hashCode-impl(p0: java.util.Map): int + public method isEmpty(): boolean + public static method isEmpty-impl(p0: java.util.Map): boolean + public bridge final method keySet(): java.util.Set + public synthetic method put(p0: java.lang.Object, p1: java.lang.Object): java.lang.Object + public method put-pjrbk2k(p0: int, p1: double): IV + public method putAll(p0: java.util.Map): void + public method remove(p0: java.lang.Object): java.lang.Object + public bridge final method size(): int + public method toString(): java.lang.String + public static method toString-impl(p0: java.util.Map): java.lang.String + public synthetic final method unbox-impl(): java.util.Map + public bridge final method values(): java.util.Collection +} diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mapEntry.kt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mapEntry.kt new file mode 100644 index 00000000000..84fd448bf8a --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mapEntry.kt @@ -0,0 +1,9 @@ +// IGNORE_ANNOTATIONS + +inline class IK(val x: Int) +inline class IV(val x: Double) + +inline class InlineMapEntry(private val e: Map.Entry) : Map.Entry { + override val key: IK get() = e.key + override val value: IV get() = e.value +} diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mapEntry.txt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mapEntry.txt new file mode 100644 index 00000000000..1e92d29064c --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mapEntry.txt @@ -0,0 +1,57 @@ +public final class IK { + // source: 'mapEntry.kt' + private final field x: int + private synthetic method (p0: int): void + public synthetic final static method box-impl(p0: int): IK + public static method constructor-impl(p0: int): int + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: int, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: int, p1: int): boolean + public final method getX(): int + public method hashCode(): int + public static method hashCode-impl(p0: int): int + public method toString(): java.lang.String + public static method toString-impl(p0: int): java.lang.String + public synthetic final method unbox-impl(): int +} + +public final class IV { + // source: 'mapEntry.kt' + private final field x: double + private synthetic method (p0: double): void + public synthetic final static method box-impl(p0: double): IV + public static method constructor-impl(p0: double): double + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: double, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: double, p1: double): boolean + public final method getX(): double + public method hashCode(): int + public static method hashCode-impl(p0: double): int + public method toString(): java.lang.String + public static method toString-impl(p0: double): java.lang.String + public synthetic final method unbox-impl(): double +} + +public final class InlineMapEntry { + // source: 'mapEntry.kt' + private final field e: java.util.Map$Entry + private synthetic method (p0: java.util.Map$Entry): void + public synthetic final static method box-impl(p0: java.util.Map$Entry): InlineMapEntry + public static method constructor-impl(p0: java.util.Map$Entry): java.util.Map$Entry + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: java.util.Map$Entry, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: java.util.Map$Entry, p1: java.util.Map$Entry): boolean + public synthetic bridge method getKey(): java.lang.Object + public method getKey-I5j8jlQ(): int + public static method getKey-I5j8jlQ(p0: java.util.Map$Entry): int + public synthetic bridge method getValue(): java.lang.Object + public method getValue-zSeR6Gk(): double + public static method getValue-zSeR6Gk(p0: java.util.Map$Entry): double + public method hashCode(): int + public static method hashCode-impl(p0: java.util.Map$Entry): int + public synthetic method setValue(p0: java.lang.Object): java.lang.Object + public method setValue-jbX5DO8(p0: double): double + public method toString(): java.lang.String + public static method toString-impl(p0: java.util.Map$Entry): java.lang.String + public synthetic final method unbox-impl(): java.util.Map$Entry +} diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mapEntry_ir.txt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mapEntry_ir.txt new file mode 100644 index 00000000000..6564cf86e94 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mapEntry_ir.txt @@ -0,0 +1,57 @@ +public final class IK { + // source: 'mapEntry.kt' + private final field x: int + private synthetic method (p0: int): void + public synthetic final static method box-impl(p0: int): IK + public static method constructor-impl(p0: int): int + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: int, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: int, p1: int): boolean + public final method getX(): int + public method hashCode(): int + public static method hashCode-impl(p0: int): int + public method toString(): java.lang.String + public static method toString-impl(p0: int): java.lang.String + public synthetic final method unbox-impl(): int +} + +public final class IV { + // source: 'mapEntry.kt' + private final field x: double + private synthetic method (p0: double): void + public synthetic final static method box-impl(p0: double): IV + public static method constructor-impl(p0: double): double + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: double, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: double, p1: double): boolean + public final method getX(): double + public method hashCode(): int + public static method hashCode-impl(p0: double): int + public method toString(): java.lang.String + public static method toString-impl(p0: double): java.lang.String + public synthetic final method unbox-impl(): double +} + +public final class InlineMapEntry { + // source: 'mapEntry.kt' + private final field e: java.util.Map$Entry + private synthetic method (p0: java.util.Map$Entry): void + public synthetic final static method box-impl(p0: java.util.Map$Entry): InlineMapEntry + public static method constructor-impl(p0: java.util.Map$Entry): java.util.Map$Entry + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: java.util.Map$Entry, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: java.util.Map$Entry, p1: java.util.Map$Entry): boolean + public synthetic bridge method getKey(): java.lang.Object + public method getKey-I5j8jlQ(): int + public static method getKey-I5j8jlQ(p0: java.util.Map$Entry): int + public synthetic bridge method getValue(): java.lang.Object + public method getValue-zSeR6Gk(): double + public static method getValue-zSeR6Gk(p0: java.util.Map$Entry): double + public method hashCode(): int + public static method hashCode-impl(p0: java.util.Map$Entry): int + public synthetic bridge method setValue(p0: java.lang.Object): java.lang.Object + public method setValue-jbX5DO8(p0: double): double + public method toString(): java.lang.String + public static method toString-impl(p0: java.util.Map$Entry): java.lang.String + public synthetic final method unbox-impl(): java.util.Map$Entry +} diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/map_ir.txt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/map_ir.txt new file mode 100644 index 00000000000..3f15ccd5455 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/map_ir.txt @@ -0,0 +1,78 @@ +public final class IK { + // source: 'map.kt' + private final field x: int + private synthetic method (p0: int): void + public synthetic final static method box-impl(p0: int): IK + public static method constructor-impl(p0: int): int + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: int, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: int, p1: int): boolean + public final method getX(): int + public method hashCode(): int + public static method hashCode-impl(p0: int): int + public method toString(): java.lang.String + public static method toString-impl(p0: int): java.lang.String + public synthetic final method unbox-impl(): int +} + +public final class IV { + // source: 'map.kt' + private final field x: double + private synthetic method (p0: double): void + public synthetic final static method box-impl(p0: double): IV + public static method constructor-impl(p0: double): double + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: double, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: double, p1: double): boolean + public final method getX(): double + public method hashCode(): int + public static method hashCode-impl(p0: double): int + public method toString(): java.lang.String + public static method toString-impl(p0: double): java.lang.String + public synthetic final method unbox-impl(): double +} + +public final class InlineMap { + // source: 'map.kt' + private final field map: java.util.Map + private synthetic method (p0: java.util.Map): void + public synthetic final static method box-impl(p0: java.util.Map): InlineMap + public method clear(): void + public static method constructor-impl(p0: java.util.Map): java.util.Map + public synthetic bridge method containsKey(p0: java.lang.Object): boolean + public method containsKey-FSIWiWE(p0: int): boolean + public static method containsKey-FSIWiWE(p0: java.util.Map, p1: int): boolean + public synthetic bridge method containsValue(p0: java.lang.Object): boolean + public method containsValue-jbX5DO8(p0: double): boolean + public static method containsValue-jbX5DO8(p0: java.util.Map, p1: double): boolean + public synthetic bridge method entrySet(): java.util.Set + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: java.util.Map, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: java.util.Map, p1: java.util.Map): boolean + public synthetic bridge method get(p0: java.lang.Object): java.lang.Object + public method get-FSIWiWE(p0: int): IV + public static method get-FSIWiWE(p0: java.util.Map, p1: int): IV + public method getEntries(): java.util.Set + public static method getEntries-impl(p0: java.util.Map): java.util.Set + public method getKeys(): java.util.Set + public static method getKeys-impl(p0: java.util.Map): java.util.Set + public method getSize(): int + public static method getSize-impl(p0: java.util.Map): int + public method getValues(): java.util.Collection + public static method getValues-impl(p0: java.util.Map): java.util.Collection + public method hashCode(): int + public static method hashCode-impl(p0: java.util.Map): int + public method isEmpty(): boolean + public static method isEmpty-impl(p0: java.util.Map): boolean + public synthetic bridge method keySet(): java.util.Set + public synthetic bridge method put(p0: java.lang.Object, p1: java.lang.Object): java.lang.Object + public method put-pjrbk2k(p0: int, p1: double): IV + public method putAll(p0: java.util.Map): void + public synthetic bridge method remove(p0: java.lang.Object): java.lang.Object + public method remove-i7hxwoc(p0: java.lang.Object): IV + public synthetic bridge method size(): int + public method toString(): java.lang.String + public static method toString-impl(p0: java.util.Map): java.lang.String + public synthetic final method unbox-impl(): java.util.Map + public synthetic bridge method values(): java.util.Collection +} diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableCollection.kt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableCollection.kt new file mode 100644 index 00000000000..44ae93542dd --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableCollection.kt @@ -0,0 +1,20 @@ +// IGNORE_ANNOTATIONS +// IGNORE_BACKEND: JVM_IR +// ^ TODO: special bridges <-> inline classes interaction + +inline class IT(val x: Int) + +inline class InlineMutableCollection(private val mc: MutableCollection) : MutableCollection { + override val size: Int get() = mc.size + override fun contains(element: IT): Boolean = mc.contains(element) + override fun containsAll(elements: Collection): Boolean = mc.containsAll(elements) + override fun isEmpty(): Boolean = mc.isEmpty() + override fun add(element: IT): Boolean = mc.add(element) + override fun addAll(elements: Collection): Boolean = mc.addAll(elements) + override fun clear() { mc.clear() } + override fun iterator(): MutableIterator = mc.iterator() + override fun remove(element: IT): Boolean = mc.remove(element) + override fun removeAll(elements: Collection): Boolean = mc.removeAll(elements) + override fun retainAll(elements: Collection): Boolean = mc.retainAll(elements) +} + diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableCollection.txt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableCollection.txt new file mode 100644 index 00000000000..019d63972f1 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableCollection.txt @@ -0,0 +1,60 @@ +public final class IT { + // source: 'mutableCollection.kt' + private final field x: int + private synthetic method (p0: int): void + public synthetic final static method box-impl(p0: int): IT + public static method constructor-impl(p0: int): int + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: int, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: int, p1: int): boolean + public final method getX(): int + public method hashCode(): int + public static method hashCode-impl(p0: int): int + public method toString(): java.lang.String + public static method toString-impl(p0: int): java.lang.String + public synthetic final method unbox-impl(): int +} + +public final class InlineMutableCollection { + // source: 'mutableCollection.kt' + private final field mc: java.util.Collection + private synthetic method (p0: java.util.Collection): void + public synthetic bridge method add(p0: java.lang.Object): boolean + public method add-jHY5zpA(p0: int): boolean + public static method add-jHY5zpA(p0: java.util.Collection, p1: int): boolean + public method addAll(p0: java.util.Collection): boolean + public static method addAll-impl(p0: java.util.Collection, p1: java.util.Collection): boolean + public synthetic final static method box-impl(p0: java.util.Collection): InlineMutableCollection + public method clear(): void + public static method clear-impl(p0: java.util.Collection): void + public static method constructor-impl(p0: java.util.Collection): java.util.Collection + public bridge final method contains(p0: java.lang.Object): boolean + public method contains-jHY5zpA(p0: int): boolean + public static method contains-jHY5zpA(p0: java.util.Collection, p1: int): boolean + public method containsAll(p0: java.util.Collection): boolean + public static method containsAll-impl(p0: java.util.Collection, p1: java.util.Collection): boolean + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: java.util.Collection, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: java.util.Collection, p1: java.util.Collection): boolean + public method getSize(): int + public static method getSize-impl(p0: java.util.Collection): int + public method hashCode(): int + public static method hashCode-impl(p0: java.util.Collection): int + public method isEmpty(): boolean + public static method isEmpty-impl(p0: java.util.Collection): boolean + public method iterator(): java.util.Iterator + public static method iterator-impl(p0: java.util.Collection): java.util.Iterator + public bridge final method remove(p0: java.lang.Object): boolean + public method remove-jHY5zpA(p0: IT): boolean + public static method remove-jHY5zpA(p0: java.util.Collection, p1: IT): boolean + public method removeAll(p0: java.util.Collection): boolean + public static method removeAll-impl(p0: java.util.Collection, p1: java.util.Collection): boolean + public method retainAll(p0: java.util.Collection): boolean + public static method retainAll-impl(p0: java.util.Collection, p1: java.util.Collection): boolean + public bridge final method size(): int + public method toArray(): java.lang.Object[] + public method toArray(p0: java.lang.Object[]): java.lang.Object[] + public method toString(): java.lang.String + public static method toString-impl(p0: java.util.Collection): java.lang.String + public synthetic final method unbox-impl(): java.util.Collection +} diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableIterable.kt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableIterable.kt new file mode 100644 index 00000000000..6de8ff9d8ea --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableIterable.kt @@ -0,0 +1,8 @@ +// IGNORE_ANNOTATIONS + +inline class IT(val x: Int) + +inline class InlineMutableIterable(private val it: MutableIterable) : MutableIterable { + override fun iterator(): MutableIterator = it.iterator() +} + diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableIterable.txt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableIterable.txt new file mode 100644 index 00000000000..fae22835bb4 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableIterable.txt @@ -0,0 +1,34 @@ +public final class IT { + // source: 'mutableIterable.kt' + private final field x: int + private synthetic method (p0: int): void + public synthetic final static method box-impl(p0: int): IT + public static method constructor-impl(p0: int): int + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: int, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: int, p1: int): boolean + public final method getX(): int + public method hashCode(): int + public static method hashCode-impl(p0: int): int + public method toString(): java.lang.String + public static method toString-impl(p0: int): java.lang.String + public synthetic final method unbox-impl(): int +} + +public final class InlineMutableIterable { + // source: 'mutableIterable.kt' + private final field it: java.lang.Iterable + private synthetic method (p0: java.lang.Iterable): void + public synthetic final static method box-impl(p0: java.lang.Iterable): InlineMutableIterable + public static method constructor-impl(p0: java.lang.Iterable): java.lang.Iterable + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: java.lang.Iterable, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: java.lang.Iterable, p1: java.lang.Iterable): boolean + public method hashCode(): int + public static method hashCode-impl(p0: java.lang.Iterable): int + public method iterator(): java.util.Iterator + public static method iterator-impl(p0: java.lang.Iterable): java.util.Iterator + public method toString(): java.lang.String + public static method toString-impl(p0: java.lang.Iterable): java.lang.String + public synthetic final method unbox-impl(): java.lang.Iterable +} diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableIterator.kt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableIterator.kt new file mode 100644 index 00000000000..95ec5a112b1 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableIterator.kt @@ -0,0 +1,9 @@ +// IGNORE_ANNOTATIONS + +inline class IT(val x: Int) + +inline class InlineMutableIterator(private val it: MutableIterator) : MutableIterator { + override fun hasNext(): Boolean = it.hasNext() + override fun next(): IT = it.next() + override fun remove() { it.remove() } +} diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableIterator.txt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableIterator.txt new file mode 100644 index 00000000000..74280d02bef --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableIterator.txt @@ -0,0 +1,39 @@ +public final class IT { + // source: 'mutableIterator.kt' + private final field x: int + private synthetic method (p0: int): void + public synthetic final static method box-impl(p0: int): IT + public static method constructor-impl(p0: int): int + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: int, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: int, p1: int): boolean + public final method getX(): int + public method hashCode(): int + public static method hashCode-impl(p0: int): int + public method toString(): java.lang.String + public static method toString-impl(p0: int): java.lang.String + public synthetic final method unbox-impl(): int +} + +public final class InlineMutableIterator { + // source: 'mutableIterator.kt' + private final field it: java.util.Iterator + private synthetic method (p0: java.util.Iterator): void + public synthetic final static method box-impl(p0: java.util.Iterator): InlineMutableIterator + public static method constructor-impl(p0: java.util.Iterator): java.util.Iterator + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: java.util.Iterator, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: java.util.Iterator, p1: java.util.Iterator): boolean + public method hasNext(): boolean + public static method hasNext-impl(p0: java.util.Iterator): boolean + public method hashCode(): int + public static method hashCode-impl(p0: java.util.Iterator): int + public synthetic bridge method next(): java.lang.Object + public method next-XAcLw3A(): int + public static method next-XAcLw3A(p0: java.util.Iterator): int + public method remove(): void + public static method remove-impl(p0: java.util.Iterator): void + public method toString(): java.lang.String + public static method toString-impl(p0: java.util.Iterator): java.lang.String + public synthetic final method unbox-impl(): java.util.Iterator +} diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableList.kt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableList.kt new file mode 100644 index 00000000000..fdcdcc42b62 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableList.kt @@ -0,0 +1,29 @@ +// IGNORE_ANNOTATIONS +// IGNORE_BACKEND: JVM_IR +// ^ TODO: special bridges <-> inline classes interaction + +inline class IT(val x: Int) + +inline class InlineMutableList(private val mlist: MutableList) : MutableList { + override val size: Int get() = mlist.size + override fun contains(element: IT): Boolean = mlist.contains(element) + override fun containsAll(elements: Collection): Boolean = mlist.containsAll(elements) + override fun get(index: Int): IT = mlist[index] + override fun indexOf(element: IT): Int = mlist.indexOf(element) + override fun isEmpty(): Boolean = mlist.isEmpty() + override fun iterator(): MutableIterator = mlist.iterator() + override fun lastIndexOf(element: IT): Int = mlist.lastIndexOf(element) + override fun add(element: IT): Boolean = mlist.add(element) + override fun add(index: Int, element: IT) { mlist.add(index, element) } + override fun addAll(index: Int, elements: Collection): Boolean = mlist.addAll(index, elements) + override fun addAll(elements: Collection): Boolean = mlist.addAll(elements) + override fun clear() { mlist.clear() } + override fun listIterator(): MutableListIterator = mlist.listIterator() + override fun listIterator(index: Int): MutableListIterator = mlist.listIterator(index) + override fun remove(element: IT): Boolean = mlist.remove(element) + override fun removeAll(elements: Collection): Boolean = mlist.removeAll(elements) + override fun removeAt(index: Int): IT = mlist.removeAt(index) + override fun retainAll(elements: Collection): Boolean = mlist.retainAll(elements) + override fun set(index: Int, element: IT): IT = mlist.set(index, element) + override fun subList(fromIndex: Int, toIndex: Int): MutableList = mlist.subList(fromIndex, toIndex) +} diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableList.txt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableList.txt new file mode 100644 index 00000000000..85101afa481 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableList.txt @@ -0,0 +1,87 @@ +public final class IT { + // source: 'mutableList.kt' + private final field x: int + private synthetic method (p0: int): void + public synthetic final static method box-impl(p0: int): IT + public static method constructor-impl(p0: int): int + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: int, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: int, p1: int): boolean + public final method getX(): int + public method hashCode(): int + public static method hashCode-impl(p0: int): int + public method toString(): java.lang.String + public static method toString-impl(p0: int): java.lang.String + public synthetic final method unbox-impl(): int +} + +public final class InlineMutableList { + // source: 'mutableList.kt' + private final field mlist: java.util.List + private synthetic method (p0: java.util.List): void + public synthetic bridge method add(p0: int, p1: java.lang.Object): void + public synthetic bridge method add(p0: java.lang.Object): boolean + public method add-_bimVNw(p0: int, p1: int): void + public static method add-_bimVNw(p0: java.util.List, p1: int, p2: int): void + public method add-jHY5zpA(p0: int): boolean + public static method add-jHY5zpA(p0: java.util.List, p1: int): boolean + public method addAll(p0: int, p1: java.util.Collection): boolean + public method addAll(p0: java.util.Collection): boolean + public static method addAll-impl(p0: java.util.List, p1: int, p2: java.util.Collection): boolean + public static method addAll-impl(p0: java.util.List, p1: java.util.Collection): boolean + public synthetic final static method box-impl(p0: java.util.List): InlineMutableList + public method clear(): void + public static method clear-impl(p0: java.util.List): void + public static method constructor-impl(p0: java.util.List): java.util.List + public bridge final method contains(p0: java.lang.Object): boolean + public method contains-jHY5zpA(p0: int): boolean + public static method contains-jHY5zpA(p0: java.util.List, p1: int): boolean + public method containsAll(p0: java.util.Collection): boolean + public static method containsAll-impl(p0: java.util.List, p1: java.util.Collection): boolean + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: java.util.List, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: java.util.List, p1: java.util.List): boolean + public synthetic bridge method get(p0: int): java.lang.Object + public method get-XAcLw3A(p0: int): int + public static method get-XAcLw3A(p0: java.util.List, p1: int): int + public method getSize(): int + public static method getSize-impl(p0: java.util.List): int + public method hashCode(): int + public static method hashCode-impl(p0: java.util.List): int + public bridge final method indexOf(p0: java.lang.Object): int + public method indexOf-jHY5zpA(p0: int): int + public static method indexOf-jHY5zpA(p0: java.util.List, p1: int): int + public method isEmpty(): boolean + public static method isEmpty-impl(p0: java.util.List): boolean + public method iterator(): java.util.Iterator + public static method iterator-impl(p0: java.util.List): java.util.Iterator + public bridge final method lastIndexOf(p0: java.lang.Object): int + public method lastIndexOf-jHY5zpA(p0: int): int + public static method lastIndexOf-jHY5zpA(p0: java.util.List, p1: int): int + public method listIterator(): java.util.ListIterator + public method listIterator(p0: int): java.util.ListIterator + public static method listIterator-impl(p0: java.util.List): java.util.ListIterator + public static method listIterator-impl(p0: java.util.List, p1: int): java.util.ListIterator + public bridge final method remove(p0: int): int + public synthetic bridge method remove(p0: int): java.lang.Object + public bridge final method remove(p0: java.lang.Object): boolean + public method remove-jHY5zpA(p0: IT): boolean + public static method remove-jHY5zpA(p0: java.util.List, p1: IT): boolean + public method removeAll(p0: java.util.Collection): boolean + public static method removeAll-impl(p0: java.util.List, p1: java.util.Collection): boolean + public method removeAt-XAcLw3A(p0: int): int + public static method removeAt-XAcLw3A(p0: java.util.List, p1: int): int + public method retainAll(p0: java.util.Collection): boolean + public static method retainAll-impl(p0: java.util.List, p1: java.util.Collection): boolean + public synthetic bridge method set(p0: int, p1: java.lang.Object): java.lang.Object + public method set-_bimVNw(p0: int, p1: int): int + public static method set-_bimVNw(p0: java.util.List, p1: int, p2: int): int + public bridge final method size(): int + public method subList(p0: int, p1: int): java.util.List + public static method subList-impl(p0: java.util.List, p1: int, p2: int): java.util.List + public method toArray(): java.lang.Object[] + public method toArray(p0: java.lang.Object[]): java.lang.Object[] + public method toString(): java.lang.String + public static method toString-impl(p0: java.util.List): java.lang.String + public synthetic final method unbox-impl(): java.util.List +} diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableMap.kt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableMap.kt new file mode 100644 index 00000000000..92e4ec046bc --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableMap.kt @@ -0,0 +1,20 @@ +// IGNORE_ANNOTATIONS + +inline class IK(val x: Int) +inline class IV(val x: Double) + +inline class InlineMutableMap(private val mmap: MutableMap) : MutableMap { + override val size: Int get() = mmap.size + override fun containsKey(key: IK): Boolean = mmap.containsKey(key) + override fun containsValue(value: IV): Boolean = mmap.containsValue(value) + override fun get(key: IK): IV? = mmap[key] + override fun isEmpty(): Boolean = mmap.isEmpty() + override val entries: MutableSet> get() = mmap.entries + override val keys: MutableSet get() = mmap.keys + override val values: MutableCollection get() = mmap.values + override fun clear() { mmap.clear() } + override fun put(key: IK, value: IV): IV? = mmap.put(key, value) + override fun putAll(from: Map) { mmap.putAll(from) } + override fun remove(key: IK): IV? = mmap.remove(key) +} + diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableMap.txt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableMap.txt new file mode 100644 index 00000000000..7239d03d579 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableMap.txt @@ -0,0 +1,82 @@ +public final class IK { + // source: 'mutableMap.kt' + private final field x: int + private synthetic method (p0: int): void + public synthetic final static method box-impl(p0: int): IK + public static method constructor-impl(p0: int): int + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: int, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: int, p1: int): boolean + public final method getX(): int + public method hashCode(): int + public static method hashCode-impl(p0: int): int + public method toString(): java.lang.String + public static method toString-impl(p0: int): java.lang.String + public synthetic final method unbox-impl(): int +} + +public final class IV { + // source: 'mutableMap.kt' + private final field x: double + private synthetic method (p0: double): void + public synthetic final static method box-impl(p0: double): IV + public static method constructor-impl(p0: double): double + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: double, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: double, p1: double): boolean + public final method getX(): double + public method hashCode(): int + public static method hashCode-impl(p0: double): int + public method toString(): java.lang.String + public static method toString-impl(p0: double): java.lang.String + public synthetic final method unbox-impl(): double +} + +public final class InlineMutableMap { + // source: 'mutableMap.kt' + private final field mmap: java.util.Map + private synthetic method (p0: java.util.Map): void + public synthetic final static method box-impl(p0: java.util.Map): InlineMutableMap + public method clear(): void + public static method clear-impl(p0: java.util.Map): void + public static method constructor-impl(p0: java.util.Map): java.util.Map + public bridge final method containsKey(p0: java.lang.Object): boolean + public method containsKey-FSIWiWE(p0: int): boolean + public static method containsKey-FSIWiWE(p0: java.util.Map, p1: int): boolean + public bridge final method containsValue(p0: java.lang.Object): boolean + public method containsValue-jbX5DO8(p0: double): boolean + public static method containsValue-jbX5DO8(p0: java.util.Map, p1: double): boolean + public bridge final method entrySet(): java.util.Set + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: java.util.Map, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: java.util.Map, p1: java.util.Map): boolean + public bridge final method get(p0: java.lang.Object): java.lang.Object + public method get-FSIWiWE(p0: int): IV + public static method get-FSIWiWE(p0: java.util.Map, p1: int): IV + public method getEntries(): java.util.Set + public static method getEntries-impl(p0: java.util.Map): java.util.Set + public method getKeys(): java.util.Set + public static method getKeys-impl(p0: java.util.Map): java.util.Set + public method getSize(): int + public static method getSize-impl(p0: java.util.Map): int + public method getValues(): java.util.Collection + public static method getValues-impl(p0: java.util.Map): java.util.Collection + public method hashCode(): int + public static method hashCode-impl(p0: java.util.Map): int + public method isEmpty(): boolean + public static method isEmpty-impl(p0: java.util.Map): boolean + public bridge final method keySet(): java.util.Set + public synthetic bridge method put(p0: java.lang.Object, p1: java.lang.Object): java.lang.Object + public method put-pjrbk2k(p0: int, p1: double): IV + public static method put-pjrbk2k(p0: java.util.Map, p1: int, p2: double): IV + public method putAll(p0: java.util.Map): void + public static method putAll-impl(p0: java.util.Map, p1: java.util.Map): void + public bridge final method remove(p0: java.lang.Object): java.lang.Object + public method remove-FSIWiWE(p0: int): IV + public static method remove-FSIWiWE(p0: java.util.Map, p1: int): IV + public bridge final method size(): int + public method toString(): java.lang.String + public static method toString-impl(p0: java.util.Map): java.lang.String + public synthetic final method unbox-impl(): java.util.Map + public bridge final method values(): java.util.Collection +} diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableMapEntry.kt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableMapEntry.kt new file mode 100644 index 00000000000..7a146230692 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableMapEntry.kt @@ -0,0 +1,10 @@ +// IGNORE_ANNOTATIONS + +inline class IK(val x: Int) +inline class IV(val x: Double) + +inline class InlineMutableMapEntry(private val e: MutableMap.MutableEntry) : MutableMap.MutableEntry { + override val key: IK get() = e.key + override val value: IV get() = e.value + override fun setValue(newValue: IV): IV = e.setValue(newValue) +} diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableMapEntry.txt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableMapEntry.txt new file mode 100644 index 00000000000..a0e0083055f --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableMapEntry.txt @@ -0,0 +1,58 @@ +public final class IK { + // source: 'mutableMapEntry.kt' + private final field x: int + private synthetic method (p0: int): void + public synthetic final static method box-impl(p0: int): IK + public static method constructor-impl(p0: int): int + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: int, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: int, p1: int): boolean + public final method getX(): int + public method hashCode(): int + public static method hashCode-impl(p0: int): int + public method toString(): java.lang.String + public static method toString-impl(p0: int): java.lang.String + public synthetic final method unbox-impl(): int +} + +public final class IV { + // source: 'mutableMapEntry.kt' + private final field x: double + private synthetic method (p0: double): void + public synthetic final static method box-impl(p0: double): IV + public static method constructor-impl(p0: double): double + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: double, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: double, p1: double): boolean + public final method getX(): double + public method hashCode(): int + public static method hashCode-impl(p0: double): int + public method toString(): java.lang.String + public static method toString-impl(p0: double): java.lang.String + public synthetic final method unbox-impl(): double +} + +public final class InlineMutableMapEntry { + // source: 'mutableMapEntry.kt' + private final field e: java.util.Map$Entry + private synthetic method (p0: java.util.Map$Entry): void + public synthetic final static method box-impl(p0: java.util.Map$Entry): InlineMutableMapEntry + public static method constructor-impl(p0: java.util.Map$Entry): java.util.Map$Entry + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: java.util.Map$Entry, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: java.util.Map$Entry, p1: java.util.Map$Entry): boolean + public synthetic bridge method getKey(): java.lang.Object + public method getKey-I5j8jlQ(): int + public static method getKey-I5j8jlQ(p0: java.util.Map$Entry): int + public synthetic bridge method getValue(): java.lang.Object + public method getValue-zSeR6Gk(): double + public static method getValue-zSeR6Gk(p0: java.util.Map$Entry): double + public method hashCode(): int + public static method hashCode-impl(p0: java.util.Map$Entry): int + public synthetic bridge method setValue(p0: java.lang.Object): java.lang.Object + public method setValue-jbX5DO8(p0: double): double + public static method setValue-jbX5DO8(p0: java.util.Map$Entry, p1: double): double + public method toString(): java.lang.String + public static method toString-impl(p0: java.util.Map$Entry): java.lang.String + public synthetic final method unbox-impl(): java.util.Map$Entry +} diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableMap_ir.txt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableMap_ir.txt new file mode 100644 index 00000000000..d3e56f34382 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableMap_ir.txt @@ -0,0 +1,82 @@ +public final class IK { + // source: 'mutableMap.kt' + private final field x: int + private synthetic method (p0: int): void + public synthetic final static method box-impl(p0: int): IK + public static method constructor-impl(p0: int): int + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: int, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: int, p1: int): boolean + public final method getX(): int + public method hashCode(): int + public static method hashCode-impl(p0: int): int + public method toString(): java.lang.String + public static method toString-impl(p0: int): java.lang.String + public synthetic final method unbox-impl(): int +} + +public final class IV { + // source: 'mutableMap.kt' + private final field x: double + private synthetic method (p0: double): void + public synthetic final static method box-impl(p0: double): IV + public static method constructor-impl(p0: double): double + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: double, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: double, p1: double): boolean + public final method getX(): double + public method hashCode(): int + public static method hashCode-impl(p0: double): int + public method toString(): java.lang.String + public static method toString-impl(p0: double): java.lang.String + public synthetic final method unbox-impl(): double +} + +public final class InlineMutableMap { + // source: 'mutableMap.kt' + private final field mmap: java.util.Map + private synthetic method (p0: java.util.Map): void + public synthetic final static method box-impl(p0: java.util.Map): InlineMutableMap + public method clear(): void + public static method clear-impl(p0: java.util.Map): void + public static method constructor-impl(p0: java.util.Map): java.util.Map + public synthetic bridge method containsKey(p0: java.lang.Object): boolean + public method containsKey-FSIWiWE(p0: int): boolean + public static method containsKey-FSIWiWE(p0: java.util.Map, p1: int): boolean + public synthetic bridge method containsValue(p0: java.lang.Object): boolean + public method containsValue-jbX5DO8(p0: double): boolean + public static method containsValue-jbX5DO8(p0: java.util.Map, p1: double): boolean + public synthetic bridge method entrySet(): java.util.Set + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: java.util.Map, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: java.util.Map, p1: java.util.Map): boolean + public synthetic bridge method get(p0: java.lang.Object): java.lang.Object + public method get-FSIWiWE(p0: int): IV + public static method get-FSIWiWE(p0: java.util.Map, p1: int): IV + public method getEntries(): java.util.Set + public static method getEntries-impl(p0: java.util.Map): java.util.Set + public method getKeys(): java.util.Set + public static method getKeys-impl(p0: java.util.Map): java.util.Set + public method getSize(): int + public static method getSize-impl(p0: java.util.Map): int + public method getValues(): java.util.Collection + public static method getValues-impl(p0: java.util.Map): java.util.Collection + public method hashCode(): int + public static method hashCode-impl(p0: java.util.Map): int + public method isEmpty(): boolean + public static method isEmpty-impl(p0: java.util.Map): boolean + public synthetic bridge method keySet(): java.util.Set + public synthetic bridge method put(p0: java.lang.Object, p1: java.lang.Object): java.lang.Object + public method put-pjrbk2k(p0: int, p1: double): IV + public static method put-pjrbk2k(p0: java.util.Map, p1: int, p2: double): IV + public method putAll(p0: java.util.Map): void + public static method putAll-impl(p0: java.util.Map, p1: java.util.Map): void + public synthetic bridge method remove(p0: java.lang.Object): java.lang.Object + public method remove-FSIWiWE(p0: int): IV + public static method remove-FSIWiWE(p0: java.util.Map, p1: int): IV + public synthetic bridge method size(): int + public method toString(): java.lang.String + public static method toString-impl(p0: java.util.Map): java.lang.String + public synthetic final method unbox-impl(): java.util.Map + public synthetic bridge method values(): java.util.Collection +} diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableSet.kt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableSet.kt new file mode 100644 index 00000000000..41cd80ca3a2 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableSet.kt @@ -0,0 +1,19 @@ +// IGNORE_ANNOTATIONS +// IGNORE_BACKEND: JVM_IR +// ^ TODO: special bridges <-> inline classes interaction + +inline class IT(val x: Int) + +inline class InlineMutableSet(private val ms: MutableSet) : MutableSet { + override val size: Int get() = ms.size + override fun contains(element: IT): Boolean = ms.contains(element) + override fun containsAll(elements: Collection): Boolean = ms.containsAll(elements) + override fun isEmpty(): Boolean = ms.isEmpty() + override fun add(element: IT): Boolean = ms.add(element) + override fun addAll(elements: Collection): Boolean = ms.addAll(elements) + override fun clear() { ms.clear() } + override fun iterator(): MutableIterator = ms.iterator() + override fun remove(element: IT): Boolean = ms.remove(element) + override fun removeAll(elements: Collection): Boolean = ms.removeAll(elements) + override fun retainAll(elements: Collection): Boolean = ms.retainAll(elements) +} diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableSet.txt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableSet.txt new file mode 100644 index 00000000000..645d3c404aa --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableSet.txt @@ -0,0 +1,60 @@ +public final class IT { + // source: 'mutableSet.kt' + private final field x: int + private synthetic method (p0: int): void + public synthetic final static method box-impl(p0: int): IT + public static method constructor-impl(p0: int): int + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: int, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: int, p1: int): boolean + public final method getX(): int + public method hashCode(): int + public static method hashCode-impl(p0: int): int + public method toString(): java.lang.String + public static method toString-impl(p0: int): java.lang.String + public synthetic final method unbox-impl(): int +} + +public final class InlineMutableSet { + // source: 'mutableSet.kt' + private final field ms: java.util.Set + private synthetic method (p0: java.util.Set): void + public synthetic bridge method add(p0: java.lang.Object): boolean + public method add-jHY5zpA(p0: int): boolean + public static method add-jHY5zpA(p0: java.util.Set, p1: int): boolean + public method addAll(p0: java.util.Collection): boolean + public static method addAll-impl(p0: java.util.Set, p1: java.util.Collection): boolean + public synthetic final static method box-impl(p0: java.util.Set): InlineMutableSet + public method clear(): void + public static method clear-impl(p0: java.util.Set): void + public static method constructor-impl(p0: java.util.Set): java.util.Set + public bridge final method contains(p0: java.lang.Object): boolean + public method contains-jHY5zpA(p0: int): boolean + public static method contains-jHY5zpA(p0: java.util.Set, p1: int): boolean + public method containsAll(p0: java.util.Collection): boolean + public static method containsAll-impl(p0: java.util.Set, p1: java.util.Collection): boolean + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: java.util.Set, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: java.util.Set, p1: java.util.Set): boolean + public method getSize(): int + public static method getSize-impl(p0: java.util.Set): int + public method hashCode(): int + public static method hashCode-impl(p0: java.util.Set): int + public method isEmpty(): boolean + public static method isEmpty-impl(p0: java.util.Set): boolean + public method iterator(): java.util.Iterator + public static method iterator-impl(p0: java.util.Set): java.util.Iterator + public bridge final method remove(p0: java.lang.Object): boolean + public method remove-jHY5zpA(p0: IT): boolean + public static method remove-jHY5zpA(p0: java.util.Set, p1: IT): boolean + public method removeAll(p0: java.util.Collection): boolean + public static method removeAll-impl(p0: java.util.Set, p1: java.util.Collection): boolean + public method retainAll(p0: java.util.Collection): boolean + public static method retainAll-impl(p0: java.util.Set, p1: java.util.Collection): boolean + public bridge final method size(): int + public method toArray(): java.lang.Object[] + public method toArray(p0: java.lang.Object[]): java.lang.Object[] + public method toString(): java.lang.String + public static method toString-impl(p0: java.util.Set): java.lang.String + public synthetic final method unbox-impl(): java.util.Set +} diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/set.kt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/set.kt new file mode 100644 index 00000000000..c69ae2297e4 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/set.kt @@ -0,0 +1,11 @@ +// IGNORE_ANNOTATIONS + +inline class IT(val x: Int) + +inline class InlineSet(private val s: Set) : Set { + override val size: Int get() = s.size + override fun contains(element: IT): Boolean = s.contains(element) + override fun containsAll(elements: Collection): Boolean = s.containsAll(elements) + override fun isEmpty(): Boolean = s.isEmpty() + override fun iterator(): Iterator = s.iterator() +} diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/set.txt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/set.txt new file mode 100644 index 00000000000..0bdaddc32bb --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/set.txt @@ -0,0 +1,53 @@ +public final class IT { + // source: 'set.kt' + private final field x: int + private synthetic method (p0: int): void + public synthetic final static method box-impl(p0: int): IT + public static method constructor-impl(p0: int): int + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: int, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: int, p1: int): boolean + public final method getX(): int + public method hashCode(): int + public static method hashCode-impl(p0: int): int + public method toString(): java.lang.String + public static method toString-impl(p0: int): java.lang.String + public synthetic final method unbox-impl(): int +} + +public final class InlineSet { + // source: 'set.kt' + private final field s: java.util.Set + private synthetic method (p0: java.util.Set): void + public synthetic method add(p0: java.lang.Object): boolean + public method add-jHY5zpA(p0: int): boolean + public method addAll(p0: java.util.Collection): boolean + public synthetic final static method box-impl(p0: java.util.Set): InlineSet + public method clear(): void + public static method constructor-impl(p0: java.util.Set): java.util.Set + public bridge final method contains(p0: java.lang.Object): boolean + public method contains-jHY5zpA(p0: int): boolean + public static method contains-jHY5zpA(p0: java.util.Set, p1: int): boolean + public method containsAll(p0: java.util.Collection): boolean + public static method containsAll-impl(p0: java.util.Set, p1: java.util.Collection): boolean + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: java.util.Set, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: java.util.Set, p1: java.util.Set): boolean + public method getSize(): int + public static method getSize-impl(p0: java.util.Set): int + public method hashCode(): int + public static method hashCode-impl(p0: java.util.Set): int + public method isEmpty(): boolean + public static method isEmpty-impl(p0: java.util.Set): boolean + public method iterator(): java.util.Iterator + public static method iterator-impl(p0: java.util.Set): java.util.Iterator + public method remove(p0: java.lang.Object): boolean + public method removeAll(p0: java.util.Collection): boolean + public method retainAll(p0: java.util.Collection): boolean + public bridge final method size(): int + public method toArray(): java.lang.Object[] + public method toArray(p0: java.lang.Object[]): java.lang.Object[] + public method toString(): java.lang.String + public static method toString-impl(p0: java.util.Set): java.lang.String + public synthetic final method unbox-impl(): java.util.Set +} diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/set_ir.txt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/set_ir.txt new file mode 100644 index 00000000000..598f2a92f7c --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/set_ir.txt @@ -0,0 +1,53 @@ +public final class IT { + // source: 'set.kt' + private final field x: int + private synthetic method (p0: int): void + public synthetic final static method box-impl(p0: int): IT + public static method constructor-impl(p0: int): int + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: int, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: int, p1: int): boolean + public final method getX(): int + public method hashCode(): int + public static method hashCode-impl(p0: int): int + public method toString(): java.lang.String + public static method toString-impl(p0: int): java.lang.String + public synthetic final method unbox-impl(): int +} + +public final class InlineSet { + // source: 'set.kt' + private final field s: java.util.Set + private synthetic method (p0: java.util.Set): void + public synthetic bridge method add(p0: java.lang.Object): boolean + public method add-jHY5zpA(p0: int): boolean + public method addAll(p0: java.util.Collection): boolean + public synthetic final static method box-impl(p0: java.util.Set): InlineSet + public method clear(): void + public static method constructor-impl(p0: java.util.Set): java.util.Set + public synthetic bridge method contains(p0: java.lang.Object): boolean + public method contains-jHY5zpA(p0: int): boolean + public static method contains-jHY5zpA(p0: java.util.Set, p1: int): boolean + public method containsAll(p0: java.util.Collection): boolean + public static method containsAll-impl(p0: java.util.Set, p1: java.util.Collection): boolean + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: java.util.Set, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: java.util.Set, p1: java.util.Set): boolean + public method getSize(): int + public static method getSize-impl(p0: java.util.Set): int + public method hashCode(): int + public static method hashCode-impl(p0: java.util.Set): int + public method isEmpty(): boolean + public static method isEmpty-impl(p0: java.util.Set): boolean + public method iterator(): java.util.Iterator + public static method iterator-impl(p0: java.util.Set): java.util.Iterator + public method remove(p0: java.lang.Object): boolean + public method removeAll(p0: java.util.Collection): boolean + public method retainAll(p0: java.util.Collection): boolean + public synthetic bridge method size(): int + public method toArray(): java.lang.Object[] + public method toArray(p0: java.lang.Object[]): java.lang.Object[] + public method toString(): java.lang.String + public static method toString-impl(p0: java.util.Set): java.lang.String + public synthetic final method unbox-impl(): java.util.Set +} diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/overridingGenericMethodWithInlineClassParameterType.kt b/compiler/testData/codegen/bytecodeListing/inlineClasses/overridingGenericMethodWithInlineClassParameterType.kt new file mode 100644 index 00000000000..8222494f1c7 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/overridingGenericMethodWithInlineClassParameterType.kt @@ -0,0 +1,11 @@ +// !LANGUAGE: +InlineClasses + +interface IFoo { + fun foo(a: T) +} + +inline class Z(val x: Int) + +inline class CFoo(val x: Long) : IFoo { + override fun foo(a: Z) {} +} \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/overridingGenericMethodWithInlineClassParameterType.txt b/compiler/testData/codegen/bytecodeListing/inlineClasses/overridingGenericMethodWithInlineClassParameterType.txt new file mode 100644 index 00000000000..2070532a182 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/overridingGenericMethodWithInlineClassParameterType.txt @@ -0,0 +1,44 @@ +@kotlin.Metadata +public final class CFoo { + // source: 'overridingGenericMethodWithInlineClassParameterType.kt' + private final field x: long + private synthetic method (p0: long): void + public synthetic final static method box-impl(p0: long): CFoo + public static method constructor-impl(p0: long): long + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: long, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: long, p1: long): boolean + public synthetic bridge method foo(p0: java.lang.Object): void + public method foo-IQRRRT4(p0: int): void + public static method foo-IQRRRT4(p0: long, p1: int): void + public final method getX(): long + public method hashCode(): int + public static method hashCode-impl(p0: long): int + public method toString(): java.lang.String + public static method toString-impl(p0: long): java.lang.String + public synthetic final method unbox-impl(): long +} + +@kotlin.Metadata +public interface IFoo { + // source: 'overridingGenericMethodWithInlineClassParameterType.kt' + public abstract method foo(p0: java.lang.Object): void +} + +@kotlin.Metadata +public final class Z { + // source: 'overridingGenericMethodWithInlineClassParameterType.kt' + private final field x: int + private synthetic method (p0: int): void + public synthetic final static method box-impl(p0: int): Z + public static method constructor-impl(p0: int): int + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: int, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: int, p1: int): boolean + public final method getX(): int + public method hashCode(): int + public static method hashCode-impl(p0: int): int + public method toString(): java.lang.String + public static method toString-impl(p0: int): java.lang.String + public synthetic final method unbox-impl(): int +} diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/overridingGenericMethodWithInlineClassReturnType.kt b/compiler/testData/codegen/bytecodeListing/inlineClasses/overridingGenericMethodWithInlineClassReturnType.kt new file mode 100644 index 00000000000..46ffe5bd170 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/overridingGenericMethodWithInlineClassReturnType.kt @@ -0,0 +1,9 @@ +// !LANGUAGE: +InlineClasses + +interface A { + fun foo(): T +} + +inline class Foo(val x: Long) : A { + override fun foo() = this +} \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/overridingGenericMethodWithInlineClassReturnType.txt b/compiler/testData/codegen/bytecodeListing/inlineClasses/overridingGenericMethodWithInlineClassReturnType.txt new file mode 100644 index 00000000000..1b67705af80 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/overridingGenericMethodWithInlineClassReturnType.txt @@ -0,0 +1,26 @@ +@kotlin.Metadata +public interface A { + // source: 'overridingGenericMethodWithInlineClassReturnType.kt' + public abstract method foo(): java.lang.Object +} + +@kotlin.Metadata +public final class Foo { + // source: 'overridingGenericMethodWithInlineClassReturnType.kt' + private final field x: long + private synthetic method (p0: long): void + public synthetic final static method box-impl(p0: long): Foo + public static method constructor-impl(p0: long): long + public method equals(p0: java.lang.Object): boolean + public static method equals-impl(p0: long, p1: java.lang.Object): boolean + public final static method equals-impl0(p0: long, p1: long): boolean + public synthetic bridge method foo(): java.lang.Object + public method foo-qUNOhfQ(): long + public static method foo-qUNOhfQ(p0: long): long + public final method getX(): long + public method hashCode(): int + public static method hashCode-impl(p0: long): int + public method toString(): java.lang.String + public static method toString-impl(p0: long): java.lang.String + public synthetic final method unbox-impl(): long +} diff --git a/compiler/testData/ir/irText/declarations/inlineCollectionOfInlineClass.kt b/compiler/testData/ir/irText/declarations/inlineCollectionOfInlineClass.kt new file mode 100644 index 00000000000..cea1ea376af --- /dev/null +++ b/compiler/testData/ir/irText/declarations/inlineCollectionOfInlineClass.kt @@ -0,0 +1,15 @@ +inline class IT(val x: Int) + +inline class InlineMutableSet(private val ms: MutableSet) : MutableSet { + override val size: Int get() = ms.size + override fun contains(element: IT): Boolean = ms.contains(element) + override fun containsAll(elements: Collection): Boolean = ms.containsAll(elements) + override fun isEmpty(): Boolean = ms.isEmpty() + override fun add(element: IT): Boolean = ms.add(element) + override fun addAll(elements: Collection): Boolean = ms.addAll(elements) + override fun clear() { ms.clear() } + override fun iterator(): MutableIterator = ms.iterator() + override fun remove(element: IT): Boolean = ms.remove(element) + override fun removeAll(elements: Collection): Boolean = ms.removeAll(elements) + override fun retainAll(elements: Collection): Boolean = ms.retainAll(elements) +} diff --git a/compiler/testData/ir/irText/declarations/inlineCollectionOfInlineClass.txt b/compiler/testData/ir/irText/declarations/inlineCollectionOfInlineClass.txt new file mode 100644 index 00000000000..d70e112e60b --- /dev/null +++ b/compiler/testData/ir/irText/declarations/inlineCollectionOfInlineClass.txt @@ -0,0 +1,247 @@ +FILE fqName: fileName:/inlineCollectionOfInlineClass.kt + CLASS CLASS name:IT modality:FINAL visibility:public [inline] superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IT + CONSTRUCTOR visibility:public <> (x:kotlin.Int) returnType:.IT [primary] + VALUE_PARAMETER name:x index:0 type:kotlin.Int + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:IT modality:FINAL visibility:public [inline] superTypes:[kotlin.Any]' + PROPERTY name:x visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final] + EXPRESSION_BODY + GET_VAR 'x: kotlin.Int declared in .IT.' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.IT) returnType:kotlin.Int + correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.IT + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .IT' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': .IT declared in .IT.' type=.IT origin=null + FUN GENERATED_INLINE_CLASS_MEMBER name:toString visibility:public modality:OPEN <> ($this:.IT) returnType:kotlin.String + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:.IT + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun toString (): kotlin.String declared in .IT' + STRING_CONCATENATION type=kotlin.String + CONST String type=kotlin.String value="IT(" + CONST String type=kotlin.String value="x=" + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': .IT declared in .IT.toString' type=.IT origin=null + CONST String type=kotlin.String value=")" + FUN GENERATED_INLINE_CLASS_MEMBER name:hashCode visibility:public modality:OPEN <> ($this:.IT) returnType:kotlin.Int + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:.IT + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun hashCode (): kotlin.Int declared in .IT' + CALL 'public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': .IT declared in .IT.hashCode' type=.IT origin=null + FUN GENERATED_INLINE_CLASS_MEMBER name:equals visibility:public modality:OPEN <> ($this:.IT, other:kotlin.Any?) returnType:kotlin.Boolean [operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:.IT + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + BLOCK_BODY + WHEN type=kotlin.Unit origin=null + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=NOT_INSTANCEOF typeOperand=.IT + GET_VAR 'other: kotlin.Any? declared in .IT.equals' type=kotlin.Any? origin=null + then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in .IT' + CONST Boolean type=kotlin.Boolean value=false + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.IT [val] + TYPE_OP type=.IT origin=CAST typeOperand=.IT + GET_VAR 'other: kotlin.Any? declared in .IT.equals' type=kotlin.Any? origin=null + WHEN type=kotlin.Unit origin=null + BRANCH + if: CALL 'public final fun not (): kotlin.Boolean [operator] declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ + $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': .IT declared in .IT.equals' type=.IT origin=null + arg1: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR 'val tmp_0: .IT [val] declared in .IT.equals' type=.IT origin=null + then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in .IT' + CONST Boolean type=kotlin.Boolean value=false + RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in .IT' + CONST Boolean type=kotlin.Boolean value=true + CLASS CLASS name:InlineMutableSet modality:FINAL visibility:public [inline] superTypes:[kotlin.collections.MutableSet<.IT>] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.InlineMutableSet + CONSTRUCTOR visibility:public <> (ms:kotlin.collections.MutableSet<.IT>) returnType:.InlineMutableSet [primary] + VALUE_PARAMETER name:ms index:0 type:kotlin.collections.MutableSet<.IT> + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:InlineMutableSet modality:FINAL visibility:public [inline] superTypes:[kotlin.collections.MutableSet<.IT>]' + PROPERTY name:ms visibility:private modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:ms type:kotlin.collections.MutableSet<.IT> visibility:private [final] + EXPRESSION_BODY + GET_VAR 'ms: kotlin.collections.MutableSet<.IT> declared in .InlineMutableSet.' type=kotlin.collections.MutableSet<.IT> origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:private modality:FINAL <> ($this:.InlineMutableSet) returnType:kotlin.collections.MutableSet<.IT> + correspondingProperty: PROPERTY name:ms visibility:private modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.InlineMutableSet + BLOCK_BODY + RETURN type=kotlin.Nothing from='private final fun (): kotlin.collections.MutableSet<.IT> declared in .InlineMutableSet' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:ms type:kotlin.collections.MutableSet<.IT> visibility:private [final]' type=kotlin.collections.MutableSet<.IT> origin=null + receiver: GET_VAR ': .InlineMutableSet declared in .InlineMutableSet.' type=.InlineMutableSet origin=null + PROPERTY name:size visibility:public modality:OPEN [val] + FUN name: visibility:public modality:OPEN <> ($this:.InlineMutableSet) returnType:kotlin.Int + correspondingProperty: PROPERTY name:size visibility:public modality:OPEN [val] + overridden: + public abstract fun (): kotlin.Int [fake_override] declared in kotlin.collections.MutableSet + $this: VALUE_PARAMETER name: type:.InlineMutableSet + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun (): kotlin.Int declared in .InlineMutableSet' + CALL 'public abstract fun (): kotlin.Int [fake_override] declared in kotlin.collections.MutableSet' type=kotlin.Int origin=GET_PROPERTY + $this: CALL 'private final fun (): kotlin.collections.MutableSet<.IT> declared in .InlineMutableSet' type=kotlin.collections.MutableSet<.IT> origin=GET_PROPERTY + $this: GET_VAR ': .InlineMutableSet declared in .InlineMutableSet.' type=.InlineMutableSet origin=null + FUN name:contains visibility:public modality:OPEN <> ($this:.InlineMutableSet, element:.IT) returnType:kotlin.Boolean [operator] + overridden: + public abstract fun contains (element: E of kotlin.collections.MutableSet): kotlin.Boolean [fake_override,operator] declared in kotlin.collections.MutableSet + $this: VALUE_PARAMETER name: type:.InlineMutableSet + VALUE_PARAMETER name:element index:0 type:.IT + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun contains (element: .IT): kotlin.Boolean [operator] declared in .InlineMutableSet' + CALL 'public abstract fun contains (element: E of kotlin.collections.MutableSet): kotlin.Boolean [fake_override,operator] declared in kotlin.collections.MutableSet' type=kotlin.Boolean origin=null + $this: CALL 'private final fun (): kotlin.collections.MutableSet<.IT> declared in .InlineMutableSet' type=kotlin.collections.MutableSet<.IT> origin=GET_PROPERTY + $this: GET_VAR ': .InlineMutableSet declared in .InlineMutableSet.contains' type=.InlineMutableSet origin=null + element: GET_VAR 'element: .IT declared in .InlineMutableSet.contains' type=.IT origin=null + FUN name:containsAll visibility:public modality:OPEN <> ($this:.InlineMutableSet, elements:kotlin.collections.Collection<.IT>) returnType:kotlin.Boolean + overridden: + public abstract fun containsAll (elements: kotlin.collections.Collection): kotlin.Boolean [fake_override] declared in kotlin.collections.MutableSet + $this: VALUE_PARAMETER name: type:.InlineMutableSet + VALUE_PARAMETER name:elements index:0 type:kotlin.collections.Collection<.IT> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun containsAll (elements: kotlin.collections.Collection<.IT>): kotlin.Boolean declared in .InlineMutableSet' + CALL 'public abstract fun containsAll (elements: kotlin.collections.Collection): kotlin.Boolean [fake_override] declared in kotlin.collections.MutableSet' type=kotlin.Boolean origin=null + $this: CALL 'private final fun (): kotlin.collections.MutableSet<.IT> declared in .InlineMutableSet' type=kotlin.collections.MutableSet<.IT> origin=GET_PROPERTY + $this: GET_VAR ': .InlineMutableSet declared in .InlineMutableSet.containsAll' type=.InlineMutableSet origin=null + elements: GET_VAR 'elements: kotlin.collections.Collection<.IT> declared in .InlineMutableSet.containsAll' type=kotlin.collections.Collection<.IT> origin=null + FUN name:isEmpty visibility:public modality:OPEN <> ($this:.InlineMutableSet) returnType:kotlin.Boolean + overridden: + public abstract fun isEmpty (): kotlin.Boolean [fake_override] declared in kotlin.collections.MutableSet + $this: VALUE_PARAMETER name: type:.InlineMutableSet + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun isEmpty (): kotlin.Boolean declared in .InlineMutableSet' + CALL 'public abstract fun isEmpty (): kotlin.Boolean [fake_override] declared in kotlin.collections.MutableSet' type=kotlin.Boolean origin=null + $this: CALL 'private final fun (): kotlin.collections.MutableSet<.IT> declared in .InlineMutableSet' type=kotlin.collections.MutableSet<.IT> origin=GET_PROPERTY + $this: GET_VAR ': .InlineMutableSet declared in .InlineMutableSet.isEmpty' type=.InlineMutableSet origin=null + FUN name:add visibility:public modality:OPEN <> ($this:.InlineMutableSet, element:.IT) returnType:kotlin.Boolean + overridden: + public abstract fun add (element: E of kotlin.collections.MutableSet): kotlin.Boolean declared in kotlin.collections.MutableSet + $this: VALUE_PARAMETER name: type:.InlineMutableSet + VALUE_PARAMETER name:element index:0 type:.IT + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun add (element: .IT): kotlin.Boolean declared in .InlineMutableSet' + CALL 'public abstract fun add (element: E of kotlin.collections.MutableSet): kotlin.Boolean declared in kotlin.collections.MutableSet' type=kotlin.Boolean origin=null + $this: CALL 'private final fun (): kotlin.collections.MutableSet<.IT> declared in .InlineMutableSet' type=kotlin.collections.MutableSet<.IT> origin=GET_PROPERTY + $this: GET_VAR ': .InlineMutableSet declared in .InlineMutableSet.add' type=.InlineMutableSet origin=null + element: GET_VAR 'element: .IT declared in .InlineMutableSet.add' type=.IT origin=null + FUN name:addAll visibility:public modality:OPEN <> ($this:.InlineMutableSet, elements:kotlin.collections.Collection<.IT>) returnType:kotlin.Boolean + overridden: + public abstract fun addAll (elements: kotlin.collections.Collection): kotlin.Boolean declared in kotlin.collections.MutableSet + $this: VALUE_PARAMETER name: type:.InlineMutableSet + VALUE_PARAMETER name:elements index:0 type:kotlin.collections.Collection<.IT> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun addAll (elements: kotlin.collections.Collection<.IT>): kotlin.Boolean declared in .InlineMutableSet' + CALL 'public abstract fun addAll (elements: kotlin.collections.Collection): kotlin.Boolean declared in kotlin.collections.MutableSet' type=kotlin.Boolean origin=null + $this: CALL 'private final fun (): kotlin.collections.MutableSet<.IT> declared in .InlineMutableSet' type=kotlin.collections.MutableSet<.IT> origin=GET_PROPERTY + $this: GET_VAR ': .InlineMutableSet declared in .InlineMutableSet.addAll' type=.InlineMutableSet origin=null + elements: GET_VAR 'elements: kotlin.collections.Collection<.IT> declared in .InlineMutableSet.addAll' type=kotlin.collections.Collection<.IT> origin=null + FUN name:clear visibility:public modality:OPEN <> ($this:.InlineMutableSet) returnType:kotlin.Unit + overridden: + public abstract fun clear (): kotlin.Unit declared in kotlin.collections.MutableSet + $this: VALUE_PARAMETER name: type:.InlineMutableSet + BLOCK_BODY + CALL 'public abstract fun clear (): kotlin.Unit declared in kotlin.collections.MutableSet' type=kotlin.Unit origin=null + $this: CALL 'private final fun (): kotlin.collections.MutableSet<.IT> declared in .InlineMutableSet' type=kotlin.collections.MutableSet<.IT> origin=GET_PROPERTY + $this: GET_VAR ': .InlineMutableSet declared in .InlineMutableSet.clear' type=.InlineMutableSet origin=null + FUN name:iterator visibility:public modality:OPEN <> ($this:.InlineMutableSet) returnType:kotlin.collections.MutableIterator<.IT> [operator] + overridden: + public abstract fun iterator (): kotlin.collections.MutableIterator [operator] declared in kotlin.collections.MutableSet + $this: VALUE_PARAMETER name: type:.InlineMutableSet + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun iterator (): kotlin.collections.MutableIterator<.IT> [operator] declared in .InlineMutableSet' + CALL 'public abstract fun iterator (): kotlin.collections.MutableIterator [operator] declared in kotlin.collections.MutableSet' type=kotlin.collections.MutableIterator<.IT> origin=null + $this: CALL 'private final fun (): kotlin.collections.MutableSet<.IT> declared in .InlineMutableSet' type=kotlin.collections.MutableSet<.IT> origin=GET_PROPERTY + $this: GET_VAR ': .InlineMutableSet declared in .InlineMutableSet.iterator' type=.InlineMutableSet origin=null + FUN name:remove visibility:public modality:OPEN <> ($this:.InlineMutableSet, element:.IT) returnType:kotlin.Boolean + overridden: + public abstract fun remove (element: E of kotlin.collections.MutableSet): kotlin.Boolean declared in kotlin.collections.MutableSet + $this: VALUE_PARAMETER name: type:.InlineMutableSet + VALUE_PARAMETER name:element index:0 type:.IT + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun remove (element: .IT): kotlin.Boolean declared in .InlineMutableSet' + CALL 'public abstract fun remove (element: E of kotlin.collections.MutableSet): kotlin.Boolean declared in kotlin.collections.MutableSet' type=kotlin.Boolean origin=null + $this: CALL 'private final fun (): kotlin.collections.MutableSet<.IT> declared in .InlineMutableSet' type=kotlin.collections.MutableSet<.IT> origin=GET_PROPERTY + $this: GET_VAR ': .InlineMutableSet declared in .InlineMutableSet.remove' type=.InlineMutableSet origin=null + element: GET_VAR 'element: .IT declared in .InlineMutableSet.remove' type=.IT origin=null + FUN name:removeAll visibility:public modality:OPEN <> ($this:.InlineMutableSet, elements:kotlin.collections.Collection<.IT>) returnType:kotlin.Boolean + overridden: + public abstract fun removeAll (elements: kotlin.collections.Collection): kotlin.Boolean declared in kotlin.collections.MutableSet + $this: VALUE_PARAMETER name: type:.InlineMutableSet + VALUE_PARAMETER name:elements index:0 type:kotlin.collections.Collection<.IT> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun removeAll (elements: kotlin.collections.Collection<.IT>): kotlin.Boolean declared in .InlineMutableSet' + CALL 'public abstract fun removeAll (elements: kotlin.collections.Collection): kotlin.Boolean declared in kotlin.collections.MutableSet' type=kotlin.Boolean origin=null + $this: CALL 'private final fun (): kotlin.collections.MutableSet<.IT> declared in .InlineMutableSet' type=kotlin.collections.MutableSet<.IT> origin=GET_PROPERTY + $this: GET_VAR ': .InlineMutableSet declared in .InlineMutableSet.removeAll' type=.InlineMutableSet origin=null + elements: GET_VAR 'elements: kotlin.collections.Collection<.IT> declared in .InlineMutableSet.removeAll' type=kotlin.collections.Collection<.IT> origin=null + FUN name:retainAll visibility:public modality:OPEN <> ($this:.InlineMutableSet, elements:kotlin.collections.Collection<.IT>) returnType:kotlin.Boolean + overridden: + public abstract fun retainAll (elements: kotlin.collections.Collection): kotlin.Boolean declared in kotlin.collections.MutableSet + $this: VALUE_PARAMETER name: type:.InlineMutableSet + VALUE_PARAMETER name:elements index:0 type:kotlin.collections.Collection<.IT> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun retainAll (elements: kotlin.collections.Collection<.IT>): kotlin.Boolean declared in .InlineMutableSet' + CALL 'public abstract fun retainAll (elements: kotlin.collections.Collection): kotlin.Boolean declared in kotlin.collections.MutableSet' type=kotlin.Boolean origin=null + $this: CALL 'private final fun (): kotlin.collections.MutableSet<.IT> declared in .InlineMutableSet' type=kotlin.collections.MutableSet<.IT> origin=GET_PROPERTY + $this: GET_VAR ': .InlineMutableSet declared in .InlineMutableSet.retainAll' type=.InlineMutableSet origin=null + elements: GET_VAR 'elements: kotlin.collections.Collection<.IT> declared in .InlineMutableSet.retainAll' type=kotlin.collections.Collection<.IT> origin=null + FUN GENERATED_INLINE_CLASS_MEMBER name:toString visibility:public modality:OPEN <> ($this:.InlineMutableSet) returnType:kotlin.String + overridden: + public open fun toString (): kotlin.String [fake_override] declared in kotlin.collections.MutableSet + $this: VALUE_PARAMETER name: type:.InlineMutableSet + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun toString (): kotlin.String declared in .InlineMutableSet' + STRING_CONCATENATION type=kotlin.String + CONST String type=kotlin.String value="InlineMutableSet(" + CONST String type=kotlin.String value="ms=" + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:ms type:kotlin.collections.MutableSet<.IT> visibility:private [final]' type=kotlin.collections.MutableSet<.IT> origin=null + receiver: GET_VAR ': .InlineMutableSet declared in .InlineMutableSet.toString' type=.InlineMutableSet origin=null + CONST String type=kotlin.String value=")" + FUN GENERATED_INLINE_CLASS_MEMBER name:hashCode visibility:public modality:OPEN <> ($this:.InlineMutableSet) returnType:kotlin.Int + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.collections.MutableSet + $this: VALUE_PARAMETER name: type:.InlineMutableSet + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun hashCode (): kotlin.Int declared in .InlineMutableSet' + CALL 'public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.collections.MutableSet' type=kotlin.Int origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:ms type:kotlin.collections.MutableSet<.IT> visibility:private [final]' type=kotlin.collections.MutableSet<.IT> origin=null + receiver: GET_VAR ': .InlineMutableSet declared in .InlineMutableSet.hashCode' type=.InlineMutableSet origin=null + FUN GENERATED_INLINE_CLASS_MEMBER name:equals visibility:public modality:OPEN <> ($this:.InlineMutableSet, other:kotlin.Any?) returnType:kotlin.Boolean [operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.collections.MutableSet + $this: VALUE_PARAMETER name: type:.InlineMutableSet + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + BLOCK_BODY + WHEN type=kotlin.Unit origin=null + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=NOT_INSTANCEOF typeOperand=.InlineMutableSet + GET_VAR 'other: kotlin.Any? declared in .InlineMutableSet.equals' type=kotlin.Any? origin=null + then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in .InlineMutableSet' + CONST Boolean type=kotlin.Boolean value=false + VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:.InlineMutableSet [val] + TYPE_OP type=.InlineMutableSet origin=CAST typeOperand=.InlineMutableSet + GET_VAR 'other: kotlin.Any? declared in .InlineMutableSet.equals' type=kotlin.Any? origin=null + WHEN type=kotlin.Unit origin=null + BRANCH + if: CALL 'public final fun not (): kotlin.Boolean [operator] declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ + $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:ms type:kotlin.collections.MutableSet<.IT> visibility:private [final]' type=kotlin.collections.MutableSet<.IT> origin=null + receiver: GET_VAR ': .InlineMutableSet declared in .InlineMutableSet.equals' type=.InlineMutableSet origin=null + arg1: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:ms type:kotlin.collections.MutableSet<.IT> visibility:private [final]' type=kotlin.collections.MutableSet<.IT> origin=null + receiver: GET_VAR 'val tmp_1: .InlineMutableSet [val] declared in .InlineMutableSet.equals' type=.InlineMutableSet origin=null + then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in .InlineMutableSet' + CONST Boolean type=kotlin.Boolean value=false + RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in .InlineMutableSet' + CONST Boolean type=kotlin.Boolean value=true diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractBytecodeListingTest.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractBytecodeListingTest.kt index 9a81c9d5478..18fa355ca35 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractBytecodeListingTest.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractBytecodeListingTest.kt @@ -18,7 +18,11 @@ import kotlin.test.assertNull abstract class AbstractBytecodeListingTest : CodegenTestCase() { override fun doMultiFileTest(wholeFile: File, files: List) { compile(files) - val actualTxt = BytecodeListingTextCollectingVisitor.getText(classFileFactory, withSignatures = isWithSignatures(wholeFile)) + val actualTxt = BytecodeListingTextCollectingVisitor.getText( + classFileFactory, + withSignatures = isWithSignatures(wholeFile), + withAnnotations = isWithAnnotations(wholeFile) + ) val prefixes = when { backend.isIR -> listOf("_ir", "_1_3", "") @@ -36,23 +40,33 @@ abstract class AbstractBytecodeListingTest : CodegenTestCase() { private fun isWithSignatures(wholeFile: File): Boolean = WITH_SIGNATURES.containsMatchIn(wholeFile.readText()) + private fun isWithAnnotations(wholeFile: File): Boolean = + !IGNORE_ANNOTATIONS.containsMatchIn(wholeFile.readText()) + companion object { private val WITH_SIGNATURES = Regex.fromLiteral("// WITH_SIGNATURES") + private val IGNORE_ANNOTATIONS = Regex.fromLiteral("// IGNORE_ANNOTATIONS") } } -class BytecodeListingTextCollectingVisitor(val filter: Filter, val withSignatures: Boolean, api: Int = API_VERSION) : ClassVisitor(api) { +class BytecodeListingTextCollectingVisitor( + val filter: Filter, + val withSignatures: Boolean, + api: Int = API_VERSION, + val withAnnotations: Boolean = true +) : ClassVisitor(api) { companion object { @JvmOverloads fun getText( factory: ClassFileFactory, filter: Filter = Filter.EMPTY, - withSignatures: Boolean = false + withSignatures: Boolean = false, + withAnnotations: Boolean = true ) = factory.getClassFiles() .sortedBy { it.relativePath } .mapNotNull { val cr = ClassReader(it.asByteArray()) - val visitor = BytecodeListingTextCollectingVisitor(filter, withSignatures) + val visitor = BytecodeListingTextCollectingVisitor(filter, withSignatures, withAnnotations = withAnnotations) cr.accept(visitor, ClassReader.SKIP_CODE) if (!filter.shouldWriteClass(cr.access, cr.className)) null else visitor.text @@ -204,22 +218,26 @@ class BytecodeListingTextCollectingVisitor(val filter: Filter, val withSignature private var invisibleAnnotableParameterCount = methodParamCount override fun visitAnnotation(desc: String, visible: Boolean): AnnotationVisitor? { - val type = Type.getType(desc).className - methodAnnotations += "@$type " + if (withAnnotations) { + val type = Type.getType(desc).className + methodAnnotations += "@$type " + } return super.visitAnnotation(desc, visible) } override fun visitParameterAnnotation(parameter: Int, desc: String, visible: Boolean): AnnotationVisitor? { - val type = Type.getType(desc).className - parameterAnnotations.getOrPut( - parameter + methodParamCount - (if (visible) visibleAnnotableParameterCount else invisibleAnnotableParameterCount), - { arrayListOf() }).add("@$type ") + if (withAnnotations) { + val type = Type.getType(desc).className + parameterAnnotations.getOrPut( + parameter + methodParamCount - (if (visible) visibleAnnotableParameterCount else invisibleAnnotableParameterCount), + { arrayListOf() }).add("@$type ") + } return super.visitParameterAnnotation(parameter, desc, visible) } override fun visitEnd() { val parameterWithAnnotations = parameterTypes.mapIndexed { index, parameter -> - val annotations = parameterAnnotations.getOrElse(index, { emptyList() }).joinToString("") + val annotations = parameterAnnotations.getOrElse(index, { emptyList() }).joinToString("") "${annotations}p$index: $parameter" }.joinToString() val signatureIfRequired = if (withSignatures) "<$signature> " else "" @@ -254,15 +272,19 @@ class BytecodeListingTextCollectingVisitor(val filter: Filter, val withSignature return object : FieldVisitor(API_VERSION) { override fun visitAnnotation(desc: String, visible: Boolean): AnnotationVisitor? { - addAnnotation(desc) + if (withAnnotations) { + addAnnotation(desc) + } return super.visitAnnotation(desc, visible) } } } override fun visitAnnotation(desc: String, visible: Boolean): AnnotationVisitor? { - val name = Type.getType(desc).className - classAnnotations.add("@$name") + if (withAnnotations) { + val name = Type.getType(desc).className + classAnnotations.add("@$name") + } return super.visitAnnotation(desc, visible) } diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java index ab912509261..efb773c1651 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java @@ -714,6 +714,16 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest { runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/nullabilityInExpansion.kt"); } + @TestMetadata("overridingGenericMethodWithInlineClassParameterType.kt") + public void testOverridingGenericMethodWithInlineClassParameterType() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/overridingGenericMethodWithInlineClassParameterType.kt"); + } + + @TestMetadata("overridingGenericMethodWithInlineClassReturnType.kt") + public void testOverridingGenericMethodWithInlineClassReturnType() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/overridingGenericMethodWithInlineClassReturnType.kt"); + } + @TestMetadata("primaryValsWithDifferentVisibilities.kt") public void testPrimaryValsWithDifferentVisibilities() throws Exception { runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/primaryValsWithDifferentVisibilities.kt"); @@ -728,6 +738,89 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest { public void testShapeOfInlineClassWithPrimitive() throws Exception { runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/shapeOfInlineClassWithPrimitive.kt"); } + + @TestMetadata("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class InlineCollectionOfInlineClass extends AbstractBytecodeListingTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInInlineCollectionOfInlineClass() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + + @TestMetadata("collection.kt") + public void testCollection() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/collection.kt"); + } + + @TestMetadata("iterable.kt") + public void testIterable() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/iterable.kt"); + } + + @TestMetadata("iterator.kt") + public void testIterator() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/iterator.kt"); + } + + @TestMetadata("list.kt") + public void testList() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/list.kt"); + } + + @TestMetadata("map.kt") + public void testMap() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/map.kt"); + } + + @TestMetadata("mapEntry.kt") + public void testMapEntry() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mapEntry.kt"); + } + + @TestMetadata("mutableCollection.kt") + public void testMutableCollection() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableCollection.kt"); + } + + @TestMetadata("mutableIterable.kt") + public void testMutableIterable() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableIterable.kt"); + } + + @TestMetadata("mutableIterator.kt") + public void testMutableIterator() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableIterator.kt"); + } + + @TestMetadata("mutableList.kt") + public void testMutableList() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableList.kt"); + } + + @TestMetadata("mutableMap.kt") + public void testMutableMap() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableMap.kt"); + } + + @TestMetadata("mutableMapEntry.kt") + public void testMutableMapEntry() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableMapEntry.kt"); + } + + @TestMetadata("mutableSet.kt") + public void testMutableSet() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableSet.kt"); + } + + @TestMetadata("set.kt") + public void testSet() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/set.kt"); + } + } } @TestMetadata("compiler/testData/codegen/bytecodeListing/jvm8") diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java index 57946003395..9ee293b5e50 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java @@ -684,6 +684,16 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/nullabilityInExpansion.kt"); } + @TestMetadata("overridingGenericMethodWithInlineClassParameterType.kt") + public void testOverridingGenericMethodWithInlineClassParameterType() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/overridingGenericMethodWithInlineClassParameterType.kt"); + } + + @TestMetadata("overridingGenericMethodWithInlineClassReturnType.kt") + public void testOverridingGenericMethodWithInlineClassReturnType() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/overridingGenericMethodWithInlineClassReturnType.kt"); + } + @TestMetadata("primaryValsWithDifferentVisibilities.kt") public void testPrimaryValsWithDifferentVisibilities() throws Exception { runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/primaryValsWithDifferentVisibilities.kt"); @@ -698,6 +708,89 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes public void testShapeOfInlineClassWithPrimitive() throws Exception { runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/shapeOfInlineClassWithPrimitive.kt"); } + + @TestMetadata("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class InlineCollectionOfInlineClass extends AbstractIrBytecodeListingTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInInlineCollectionOfInlineClass() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @TestMetadata("collection.kt") + public void testCollection() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/collection.kt"); + } + + @TestMetadata("iterable.kt") + public void testIterable() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/iterable.kt"); + } + + @TestMetadata("iterator.kt") + public void testIterator() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/iterator.kt"); + } + + @TestMetadata("list.kt") + public void testList() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/list.kt"); + } + + @TestMetadata("map.kt") + public void testMap() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/map.kt"); + } + + @TestMetadata("mapEntry.kt") + public void testMapEntry() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mapEntry.kt"); + } + + @TestMetadata("mutableCollection.kt") + public void testMutableCollection() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableCollection.kt"); + } + + @TestMetadata("mutableIterable.kt") + public void testMutableIterable() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableIterable.kt"); + } + + @TestMetadata("mutableIterator.kt") + public void testMutableIterator() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableIterator.kt"); + } + + @TestMetadata("mutableList.kt") + public void testMutableList() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableList.kt"); + } + + @TestMetadata("mutableMap.kt") + public void testMutableMap() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableMap.kt"); + } + + @TestMetadata("mutableMapEntry.kt") + public void testMutableMapEntry() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableMapEntry.kt"); + } + + @TestMetadata("mutableSet.kt") + public void testMutableSet() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/mutableSet.kt"); + } + + @TestMetadata("set.kt") + public void testSet() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollectionOfInlineClass/set.kt"); + } + } } @TestMetadata("compiler/testData/codegen/bytecodeListing/jvm8") diff --git a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java index a792bf5bd3a..a5446ab9794 100644 --- a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java @@ -323,6 +323,11 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase { runTest("compiler/testData/ir/irText/declarations/genericDelegatedProperty.kt"); } + @TestMetadata("inlineCollectionOfInlineClass.kt") + public void testInlineCollectionOfInlineClass() throws Exception { + runTest("compiler/testData/ir/irText/declarations/inlineCollectionOfInlineClass.kt"); + } + @TestMetadata("interfaceProperties.kt") public void testInterfaceProperties() throws Exception { runTest("compiler/testData/ir/irText/declarations/interfaceProperties.kt");