diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java
index 15c672656f4..a3ad4829eab 100644
--- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java
+++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java
@@ -5058,6 +5058,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/collections/javaCollectionWithRemovePrimitiveInt.kt");
}
+ @TestMetadata("kt40305.kt")
+ public void testKt40305() throws Exception {
+ runTest("compiler/testData/codegen/box/collections/kt40305.kt");
+ }
+
@TestMetadata("kt41123.kt")
public void testKt41123() throws Exception {
runTest("compiler/testData/codegen/box/collections/kt41123.kt");
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt
index d525bb4b723..94f2f148fbf 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt
@@ -295,6 +295,7 @@ class ExpressionCodegen(
irFunction.origin == IrDeclarationOrigin.BRIDGE_SPECIAL ||
irFunction.origin == JvmLoweredDeclarationOrigin.DEFAULT_IMPLS_BRIDGE ||
irFunction.origin == JvmLoweredDeclarationOrigin.JVM_STATIC_WRAPPER ||
+ irFunction.origin == IrDeclarationOrigin.IR_BUILTINS_STUB ||
irFunction.parentAsClass.origin == JvmLoweredDeclarationOrigin.CONTINUATION_CLASS ||
irFunction.parentAsClass.origin == JvmLoweredDeclarationOrigin.SUSPEND_LAMBDA ||
irFunction.isMultifileBridge()
diff --git a/compiler/testData/codegen/box/collections/kt40305.kt b/compiler/testData/codegen/box/collections/kt40305.kt
new file mode 100644
index 00000000000..f932a3e3f97
--- /dev/null
+++ b/compiler/testData/codegen/box/collections/kt40305.kt
@@ -0,0 +1,35 @@
+// TARGET_BACKEND: JVM
+// WITH_RUNTIME
+// FILE: kt40305.kt
+
+class ListImpl(private val list: List): List {
+ override val size: Int get() = list.size
+ override fun contains(element: A): Boolean = list.contains(element)
+ override fun containsAll(elements: Collection): Boolean = list.containsAll(elements)
+ override fun get(index: Int): A = list.get(index)
+ override fun indexOf(element: A): Int = list.indexOf(element)
+ override fun isEmpty(): Boolean = list.isEmpty()
+ override fun iterator(): Iterator = list.iterator()
+ override fun lastIndexOf(element: A): 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)
+}
+
+fun box(): String {
+ try {
+ J.testAddAllNull(ListImpl(listOf()))
+ } catch (e: UnsupportedOperationException) {
+ return "OK"
+ }
+ return "J.testAddAllNull(ListImpl(...)) should throw UnsupportedOperationException"
+}
+
+// FILE: J.java
+import java.util.List;
+
+public class J {
+ public static void testAddAllNull(List list) {
+ list.addAll(null);
+ }
+}
diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java
index 7efe75445da..b8f21d40e9c 100644
--- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java
+++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java
@@ -5088,6 +5088,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/collections/javaCollectionWithRemovePrimitiveInt.kt");
}
+ @TestMetadata("kt40305.kt")
+ public void testKt40305() throws Exception {
+ runTest("compiler/testData/codegen/box/collections/kt40305.kt");
+ }
+
@TestMetadata("kt41123.kt")
public void testKt41123() throws Exception {
runTest("compiler/testData/codegen/box/collections/kt41123.kt");
diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java
index c2f808a05e0..9a01f7b60b2 100644
--- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java
+++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java
@@ -5088,6 +5088,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/collections/javaCollectionWithRemovePrimitiveInt.kt");
}
+ @TestMetadata("kt40305.kt")
+ public void testKt40305() throws Exception {
+ runTest("compiler/testData/codegen/box/collections/kt40305.kt");
+ }
+
@TestMetadata("kt41123.kt")
public void testKt41123() throws Exception {
runTest("compiler/testData/codegen/box/collections/kt41123.kt");
diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java
index f0d1879aff3..b131d788a67 100644
--- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java
+++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java
@@ -5058,6 +5058,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/collections/javaCollectionWithRemovePrimitiveInt.kt");
}
+ @TestMetadata("kt40305.kt")
+ public void testKt40305() throws Exception {
+ runTest("compiler/testData/codegen/box/collections/kt40305.kt");
+ }
+
@TestMetadata("kt41123.kt")
public void testKt41123() throws Exception {
runTest("compiler/testData/codegen/box/collections/kt41123.kt");