From 1adce11257190e1d2b4b8dbc4f7c6c5f2677215b Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Thu, 24 Sep 2020 15:13:55 +0300 Subject: [PATCH] Add tests for KT-40191 --- .../collectionStubs/emptyList.kt | 22 ++++++++++ .../collectionStubs/emptyList.txt | 42 +++++++++++++++++++ .../collectionStubs/emptyList_ir.txt | 42 +++++++++++++++++++ .../codegen/BytecodeListingTestGenerated.java | 5 +++ .../ir/IrBytecodeListingTestGenerated.java | 5 +++ 5 files changed, 116 insertions(+) create mode 100644 compiler/testData/codegen/bytecodeListing/collectionStubs/emptyList.kt create mode 100644 compiler/testData/codegen/bytecodeListing/collectionStubs/emptyList.txt create mode 100644 compiler/testData/codegen/bytecodeListing/collectionStubs/emptyList_ir.txt diff --git a/compiler/testData/codegen/bytecodeListing/collectionStubs/emptyList.kt b/compiler/testData/codegen/bytecodeListing/collectionStubs/emptyList.kt new file mode 100644 index 00000000000..29762fb66ac --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/collectionStubs/emptyList.kt @@ -0,0 +1,22 @@ +// WITH_RUNTIME + +internal object EmptyList : List, RandomAccess { + override fun equals(other: Any?): Boolean = TODO() + override fun hashCode(): Int = 1 + override fun toString(): String = "[]" + + override val size: Int get() = 0 + override fun isEmpty(): Boolean = true + override fun contains(element: Nothing): Boolean = false + override fun containsAll(elements: Collection): Boolean = elements.isEmpty() + + override fun get(index: Int): Nothing = TODO() + override fun indexOf(element: Nothing): Int = -1 + override fun lastIndexOf(element: Nothing): Int = -1 + + override fun iterator(): Iterator = TODO() + override fun listIterator(): ListIterator = TODO() + override fun listIterator(index: Int): ListIterator { TODO() } + + override fun subList(fromIndex: Int, toIndex: Int): List { TODO() } +} \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeListing/collectionStubs/emptyList.txt b/compiler/testData/codegen/bytecodeListing/collectionStubs/emptyList.txt new file mode 100644 index 00000000000..eb411496569 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/collectionStubs/emptyList.txt @@ -0,0 +1,42 @@ +@kotlin.Metadata +public final class EmptyList { + // source: 'emptyList.kt' + public final static @org.jetbrains.annotations.NotNull field INSTANCE: EmptyList + static method (): void + private method (): void + public synthetic method add(p0: int, p1: java.lang.Object): void + public method add(p0: int, p1: java.lang.Void): void + public synthetic method add(p0: java.lang.Object): boolean + public method add(p0: java.lang.Void): boolean + public method addAll(p0: int, p1: java.util.Collection): boolean + public method addAll(p0: java.util.Collection): boolean + public method clear(): void + public method contains(@org.jetbrains.annotations.NotNull p0: java.lang.Void): boolean + public bridge final method contains(p0: java.lang.Object): boolean + public method containsAll(@org.jetbrains.annotations.NotNull p0: java.util.Collection): boolean + public method equals(@org.jetbrains.annotations.Nullable p0: java.lang.Object): boolean + public synthetic bridge method get(p0: int): java.lang.Object + public @org.jetbrains.annotations.NotNull method get(p0: int): java.lang.Void + public method getSize(): int + public method hashCode(): int + public method indexOf(@org.jetbrains.annotations.NotNull p0: java.lang.Void): int + public bridge final method indexOf(p0: java.lang.Object): int + public method isEmpty(): boolean + public @org.jetbrains.annotations.NotNull method iterator(): java.util.Iterator + public method lastIndexOf(@org.jetbrains.annotations.NotNull p0: java.lang.Void): int + public bridge final method lastIndexOf(p0: java.lang.Object): int + public @org.jetbrains.annotations.NotNull method listIterator(): java.util.ListIterator + public @org.jetbrains.annotations.NotNull method listIterator(p0: int): java.util.ListIterator + public synthetic method remove(p0: int): java.lang.Object + public method remove(p0: int): java.lang.Void + 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(p0: int, p1: java.lang.Void): java.lang.Void + public bridge final method size(): int + public @org.jetbrains.annotations.NotNull method subList(p0: int, p1: int): java.util.List + public method toArray(): java.lang.Object[] + public method toArray(p0: java.lang.Object[]): java.lang.Object[] + public @org.jetbrains.annotations.NotNull method toString(): java.lang.String +} diff --git a/compiler/testData/codegen/bytecodeListing/collectionStubs/emptyList_ir.txt b/compiler/testData/codegen/bytecodeListing/collectionStubs/emptyList_ir.txt new file mode 100644 index 00000000000..f1d98e86ae0 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/collectionStubs/emptyList_ir.txt @@ -0,0 +1,42 @@ +@kotlin.Metadata +public final class EmptyList { + // source: 'emptyList.kt' + public final static @org.jetbrains.annotations.NotNull field INSTANCE: EmptyList + static method (): void + private method (): void + public synthetic bridge method add(p0: int, p1: java.lang.Object): void + public method add(p0: int, p1: java.lang.Void): void + public synthetic bridge method add(p0: java.lang.Object): boolean + public method add(p0: java.lang.Void): boolean + public method addAll(p0: int, p1: java.util.Collection): boolean + public method addAll(p0: java.util.Collection): boolean + public method clear(): void + public method contains(@org.jetbrains.annotations.NotNull p0: java.lang.Void): boolean + public bridge final method contains(p0: java.lang.Object): boolean + public method containsAll(@org.jetbrains.annotations.NotNull p0: java.util.Collection): boolean + public method equals(@org.jetbrains.annotations.Nullable p0: java.lang.Object): boolean + public synthetic bridge method get(p0: int): java.lang.Object + public @org.jetbrains.annotations.NotNull method get(p0: int): java.lang.Void + public method getSize(): int + public method hashCode(): int + public method indexOf(@org.jetbrains.annotations.NotNull p0: java.lang.Void): int + public bridge final method indexOf(p0: java.lang.Object): int + public method isEmpty(): boolean + public @org.jetbrains.annotations.NotNull method iterator(): java.util.Iterator + public method lastIndexOf(@org.jetbrains.annotations.NotNull p0: java.lang.Void): int + public bridge final method lastIndexOf(p0: java.lang.Object): int + public @org.jetbrains.annotations.NotNull method listIterator(): java.util.ListIterator + public @org.jetbrains.annotations.NotNull method listIterator(p0: int): java.util.ListIterator + public synthetic bridge method remove(p0: int): java.lang.Object + public method remove(p0: int): java.lang.Void + 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 set(p0: int, p1: java.lang.Object): java.lang.Object + public method set(p0: int, p1: java.lang.Void): java.lang.Void + public bridge final method size(): int + public @org.jetbrains.annotations.NotNull method subList(p0: int, p1: int): java.util.List + public method toArray(): java.lang.Object[] + public method toArray(p0: java.lang.Object[]): java.lang.Object[] + public @org.jetbrains.annotations.NotNull method toString(): java.lang.String +} diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java index 2702452a706..835aee39eac 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java @@ -249,6 +249,11 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest { runTest("compiler/testData/codegen/bytecodeListing/collectionStubs/customMutableListIterator.kt"); } + @TestMetadata("emptyList.kt") + public void testEmptyList() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/collectionStubs/emptyList.kt"); + } + @TestMetadata("noStubsForCollection.kt") public void testNoStubsForCollection() throws Exception { runTest("compiler/testData/codegen/bytecodeListing/collectionStubs/noStubsForCollection.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java index ac6d54edf85..2dc8d12c218 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java @@ -249,6 +249,11 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes runTest("compiler/testData/codegen/bytecodeListing/collectionStubs/customMutableListIterator.kt"); } + @TestMetadata("emptyList.kt") + public void testEmptyList() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/collectionStubs/emptyList.kt"); + } + @TestMetadata("noStubsForCollection.kt") public void testNoStubsForCollection() throws Exception { runTest("compiler/testData/codegen/bytecodeListing/collectionStubs/noStubsForCollection.kt");