diff --git a/compiler/testData/codegen/bytecodeText/builtinFunctions/contains.kt b/compiler/testData/codegen/bytecodeText/builtinFunctions/contains.kt index a939088c431..4422a29be04 100644 --- a/compiler/testData/codegen/bytecodeText/builtinFunctions/contains.kt +++ b/compiler/testData/codegen/bytecodeText/builtinFunctions/contains.kt @@ -97,12 +97,9 @@ fun foo( c.contains("") } -// 0 signature \(TQ;\)Z -// 0 signature \(TW;\)Z -// 0 signature \(TR;\)Z -// 6 signature \(Ljava/util/Collection<\+Ljava/lang/Object;>;\)Z -// 4 public final bridge contains\(Ljava/lang/Object;\)Z -// 3 INVOKEVIRTUAL A[0-9]\.contains \(Ljava/lang/String;\)Z +/* +* Calls to a1-a7, i1-i2, c in foo +*/ // 7 INVOKEVIRTUAL A[0-9]\.contains \(Ljava/lang/Object;\)Z // 1 INVOKEVIRTUAL A7\.contains \(I\)Z // 1 INVOKEINTERFACE java/util/Collection.contains \(Ljava/lang/Object;\)Z diff --git a/compiler/testData/codegen/bytecodeText/builtinFunctions/genericParameterBridge/IntMC.kt b/compiler/testData/codegen/bytecodeText/builtinFunctions/genericParameterBridge/IntMC.kt new file mode 100644 index 00000000000..1fddb59df4e --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/builtinFunctions/genericParameterBridge/IntMC.kt @@ -0,0 +1,8 @@ +abstract class A7 : MutableCollection { + override fun contains(o: Int): Boolean { + throw UnsupportedOperationException() + } +} + +// 1 public final bridge contains\(Ljava/lang/Object;\)Z +// 1 public final bridge remove\(Ljava/lang/Object;\)Z diff --git a/compiler/testData/codegen/bytecodeText/builtinFunctions/genericParameterBridge/abstractList.kt b/compiler/testData/codegen/bytecodeText/builtinFunctions/genericParameterBridge/abstractList.kt new file mode 100644 index 00000000000..0a2ab6d4ff1 --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/builtinFunctions/genericParameterBridge/abstractList.kt @@ -0,0 +1,28 @@ +abstract class A3 : java.util.AbstractList() +abstract class A4 : java.util.AbstractList() { + override fun contains(o: W): Boolean { + throw UnsupportedOperationException() + } + + override fun containsAll(c: Collection): Boolean { + throw UnsupportedOperationException() + } +} + +abstract class A5 : java.util.AbstractList() +abstract class A6 : java.util.AbstractList() { + override fun contains(o: String): Boolean { + throw UnsupportedOperationException() + } + + override fun containsAll(c: Collection): Boolean { + throw UnsupportedOperationException() + } +} + +// 0 signature \(TW;\)Z +// 2 signature \(Ljava/util/Collection<\+Ljava/lang/Object;>;\)Z +// 2 public final bridge contains\(Ljava/lang/Object;\)Z +// 2 public final bridge remove\(Ljava/lang/Object;\)Z +// 2 public final bridge indexOf\(Ljava/lang/Object;\)I +// 2 public final bridge lastIndexOf\(Ljava/lang/Object;\)I diff --git a/compiler/testData/codegen/bytecodeText/builtinFunctions/genericParameterBridge/mutableCollection.kt b/compiler/testData/codegen/bytecodeText/builtinFunctions/genericParameterBridge/mutableCollection.kt new file mode 100644 index 00000000000..061e13e246e --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/builtinFunctions/genericParameterBridge/mutableCollection.kt @@ -0,0 +1,25 @@ +abstract class A1 : MutableCollection { + override fun contains(o: Q): Boolean { + throw UnsupportedOperationException() + } + + override fun containsAll(c: Collection): Boolean { + throw UnsupportedOperationException() + } +} + +abstract class A2 : MutableCollection { + override fun contains(o: String): Boolean { + throw UnsupportedOperationException() + } + + override fun containsAll(c: Collection): Boolean { + throw UnsupportedOperationException() + } +} + +// 0 signature \(TQ;\)Z +// 2 signature \(Ljava/util/Collection<\+Ljava/lang/Object;>;\)Z +// 1 public final bridge contains\(Ljava/lang/Object;\)Z +// 1 public final bridge remove\(Ljava/lang/Object;\)Z +// 1 INVOKEVIRTUAL A[0-9]\.contains \(Ljava/lang/String;\)Z diff --git a/compiler/testData/codegen/bytecodeText/builtinFunctions/genericParameterBridge/mutableSetInterfaces.kt b/compiler/testData/codegen/bytecodeText/builtinFunctions/genericParameterBridge/mutableSetInterfaces.kt new file mode 100644 index 00000000000..39ab38aa45c --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/builtinFunctions/genericParameterBridge/mutableSetInterfaces.kt @@ -0,0 +1,24 @@ +interface I1 : MutableSet { + override fun contains(o: R): Boolean { + throw UnsupportedOperationException() + } + + override fun containsAll(c: Collection): Boolean { + throw UnsupportedOperationException() + } +} + +interface I2 : MutableSet { + override fun contains(o: String): Boolean { + throw UnsupportedOperationException() + } + + override fun containsAll(c: Collection): Boolean { + throw UnsupportedOperationException() + } +} + +abstract class A : I2 + +// 1 public final bridge contains\(Ljava/lang/Object;\)Z +// 1 public final bridge remove\(Ljava/lang/Object;\)Z diff --git a/compiler/testData/codegen/bytecodeText/builtinFunctions/genericParameterBridge/nullableAnyMC.kt b/compiler/testData/codegen/bytecodeText/builtinFunctions/genericParameterBridge/nullableAnyMC.kt new file mode 100644 index 00000000000..2ec00b18daf --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/builtinFunctions/genericParameterBridge/nullableAnyMC.kt @@ -0,0 +1,8 @@ +abstract class A8 : MutableCollection { + override fun contains(o: Any?): Boolean { + throw UnsupportedOperationException() + } +} + +// 1 bridge +// 1 public final bridge size diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java index c352c715ad7..870e4d93186 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java @@ -402,6 +402,45 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/builtinFunctions/size.kt"); doTest(fileName); } + + @TestMetadata("compiler/testData/codegen/bytecodeText/builtinFunctions/genericParameterBridge") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class GenericParameterBridge extends AbstractBytecodeTextTest { + @TestMetadata("abstractList.kt") + public void testAbstractList() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/builtinFunctions/genericParameterBridge/abstractList.kt"); + doTest(fileName); + } + + public void testAllFilesPresentInGenericParameterBridge() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/bytecodeText/builtinFunctions/genericParameterBridge"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("IntMC.kt") + public void testIntMC() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/builtinFunctions/genericParameterBridge/IntMC.kt"); + doTest(fileName); + } + + @TestMetadata("mutableCollection.kt") + public void testMutableCollection() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/builtinFunctions/genericParameterBridge/mutableCollection.kt"); + doTest(fileName); + } + + @TestMetadata("mutableSetInterfaces.kt") + public void testMutableSetInterfaces() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/builtinFunctions/genericParameterBridge/mutableSetInterfaces.kt"); + doTest(fileName); + } + + @TestMetadata("nullableAnyMC.kt") + public void testNullableAnyMC() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/builtinFunctions/genericParameterBridge/nullableAnyMC.kt"); + doTest(fileName); + } + } } @TestMetadata("compiler/testData/codegen/bytecodeText/conditions")