Add tests for KT-40152

This commit is contained in:
Dmitry Petrov
2020-09-23 16:16:01 +03:00
parent cd37301ea2
commit 1c4567c999
10 changed files with 126 additions and 0 deletions
@@ -5043,6 +5043,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/collections/removeClashWithGenerics.kt");
}
@TestMetadata("removeNullFromList.kt")
public void testRemoveNullFromList() throws Exception {
runTest("compiler/testData/codegen/box/collections/removeNullFromList.kt");
}
@TestMetadata("removeOverriddenInJava.kt")
public void testRemoveOverriddenInJava() throws Exception {
runTest("compiler/testData/codegen/box/collections/removeOverriddenInJava.kt");
@@ -0,0 +1,34 @@
// TARGET_BACKEND: JVM
// FILE: removeNullFromList.kt
class MyList : List<String> {
override val size: Int get() = 0
override fun contains(element: String): Boolean = false
override fun containsAll(elements: Collection<String>): Boolean = false
override fun get(index: Int): String = TODO()
override fun indexOf(element: String): Int = -1
override fun isEmpty(): Boolean = true
override fun iterator(): Iterator<String> = TODO()
override fun lastIndexOf(element: String): Int = -1
override fun listIterator(): ListIterator<String> = TODO()
override fun listIterator(index: Int): ListIterator<String> = TODO()
override fun subList(fromIndex: Int, toIndex: Int): List<String> = this
}
fun box(): String {
try {
J.test(MyList())
} catch (e: UnsupportedOperationException) {
return "OK"
}
return "J.test(MyList()) should have thrown UnsupportedOperationException"
}
// FILE: J.java
import java.util.List;
public class J {
public static void test(List<String> list) {
list.remove(null);
}
}
@@ -0,0 +1,4 @@
class SimplePlatform
open class TargetPlatform(val componentPlatforms: Set<SimplePlatform>) :
Collection<SimplePlatform> by componentPlatforms
@@ -0,0 +1,29 @@
@kotlin.Metadata
public final class SimplePlatform {
// source: 'collectionByDelegation.kt'
public method <init>(): void
}
@kotlin.Metadata
public class TargetPlatform {
// source: 'collectionByDelegation.kt'
private final @org.jetbrains.annotations.NotNull field componentPlatforms: java.util.Set
public method <init>(@org.jetbrains.annotations.NotNull p0: java.util.Set): void
public method add(p0: SimplePlatform): boolean
public synthetic method add(p0: java.lang.Object): boolean
public method addAll(p0: java.util.Collection): boolean
public method clear(): void
public method contains(@org.jetbrains.annotations.NotNull p0: SimplePlatform): boolean
public bridge final method contains(p0: java.lang.Object): boolean
public method containsAll(@org.jetbrains.annotations.NotNull p0: java.util.Collection): boolean
public final @org.jetbrains.annotations.NotNull method getComponentPlatforms(): java.util.Set
public method getSize(): int
public method isEmpty(): boolean
public @org.jetbrains.annotations.NotNull method iterator(): 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[]
}
@@ -0,0 +1,29 @@
@kotlin.Metadata
public final class SimplePlatform {
// source: 'collectionByDelegation.kt'
public method <init>(): void
}
@kotlin.Metadata
public class TargetPlatform {
// source: 'collectionByDelegation.kt'
private final @org.jetbrains.annotations.NotNull field componentPlatforms: java.util.Set
public method <init>(@org.jetbrains.annotations.NotNull p0: java.util.Set): void
public method add(p0: SimplePlatform): boolean
public synthetic bridge method add(p0: java.lang.Object): boolean
public method addAll(p0: java.util.Collection): boolean
public method clear(): void
public method contains(@org.jetbrains.annotations.NotNull p0: SimplePlatform): boolean
public bridge final method contains(p0: java.lang.Object): boolean
public method containsAll(@org.jetbrains.annotations.NotNull p0: java.util.Collection): boolean
public final @org.jetbrains.annotations.NotNull method getComponentPlatforms(): java.util.Set
public method getSize(): int
public method isEmpty(): boolean
public @org.jetbrains.annotations.NotNull method iterator(): 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[]
}
@@ -5073,6 +5073,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/collections/removeClashWithGenerics.kt");
}
@TestMetadata("removeNullFromList.kt")
public void testRemoveNullFromList() throws Exception {
runTest("compiler/testData/codegen/box/collections/removeNullFromList.kt");
}
@TestMetadata("removeOverriddenInJava.kt")
public void testRemoveOverriddenInJava() throws Exception {
runTest("compiler/testData/codegen/box/collections/removeOverriddenInJava.kt");
@@ -229,6 +229,11 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeListing/collectionStubs"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@TestMetadata("collectionByDelegation.kt")
public void testCollectionByDelegation() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/collectionStubs/collectionByDelegation.kt");
}
@TestMetadata("collectionsWithFullJdk.kt")
public void testCollectionsWithFullJdk() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/collectionStubs/collectionsWithFullJdk.kt");
@@ -5073,6 +5073,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/collections/removeClashWithGenerics.kt");
}
@TestMetadata("removeNullFromList.kt")
public void testRemoveNullFromList() throws Exception {
runTest("compiler/testData/codegen/box/collections/removeNullFromList.kt");
}
@TestMetadata("removeOverriddenInJava.kt")
public void testRemoveOverriddenInJava() throws Exception {
runTest("compiler/testData/codegen/box/collections/removeOverriddenInJava.kt");
@@ -5043,6 +5043,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/collections/removeClashWithGenerics.kt");
}
@TestMetadata("removeNullFromList.kt")
public void testRemoveNullFromList() throws Exception {
runTest("compiler/testData/codegen/box/collections/removeNullFromList.kt");
}
@TestMetadata("removeOverriddenInJava.kt")
public void testRemoveOverriddenInJava() throws Exception {
runTest("compiler/testData/codegen/box/collections/removeOverriddenInJava.kt");
@@ -229,6 +229,11 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeListing/collectionStubs"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@TestMetadata("collectionByDelegation.kt")
public void testCollectionByDelegation() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/collectionStubs/collectionByDelegation.kt");
}
@TestMetadata("collectionsWithFullJdk.kt")
public void testCollectionsWithFullJdk() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/collectionStubs/collectionsWithFullJdk.kt");