KT-51282 Add tests
diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java
index 1a1ad73..4d7f9be5 100644
--- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java
+++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java
@@ -26793,6 +26793,18 @@
             }
 
             @Test
+            @TestMetadata("kt51282.kt")
+            public void testKt51282() throws Exception {
+                runTest("compiler/testData/codegen/box/invokedynamic/sam/kt51282.kt");
+            }
+
+            @Test
+            @TestMetadata("kt512832_inherit_multifile_parts.kt")
+            public void testKt512832_inherit_multifile_parts() throws Exception {
+                runTest("compiler/testData/codegen/box/invokedynamic/sam/kt512832_inherit_multifile_parts.kt");
+            }
+
+            @Test
             @TestMetadata("kt51868_contravariantGenericSam.kt")
             public void testKt51868_contravariantGenericSam() throws Exception {
                 runTest("compiler/testData/codegen/box/invokedynamic/sam/kt51868_contravariantGenericSam.kt");
diff --git a/compiler/testData/codegen/box/invokedynamic/sam/kt51282.kt b/compiler/testData/codegen/box/invokedynamic/sam/kt51282.kt
new file mode 100644
index 0000000..39ccc2f
--- /dev/null
+++ b/compiler/testData/codegen/box/invokedynamic/sam/kt51282.kt
@@ -0,0 +1,40 @@
+// SAM_CONVERSIONS: INDY
+// TARGET_BACKEND: JVM_IR
+// JVM_TARGET: 1.8
+// WITH_STDLIB
+
+// FILE: Foo.java
+package org.example.foo;
+public interface Foo {
+    String foo(String s);
+}
+
+// FILE: bar1.kt
+
+@file:JvmMultifileClass
+@file:JvmName("Bar")
+
+package org.example.bar
+
+fun doFoo(s: String): String = s.toUpperCase()
+
+// FILE: bar2.kt
+
+@file:JvmMultifileClass
+@file:JvmName("Bar")
+
+package org.example.bar
+
+val unused = 1
+
+// FILE: Baz.kt
+
+package org.example.baz
+
+import org.example.foo.Foo
+import org.example.bar.doFoo
+
+fun box(): String {
+    val foo = Foo(::doFoo)
+    return foo.foo("ok")
+}
\ No newline at end of file
diff --git a/compiler/testData/codegen/box/invokedynamic/sam/kt512832_inherit_multifile_parts.kt b/compiler/testData/codegen/box/invokedynamic/sam/kt512832_inherit_multifile_parts.kt
new file mode 100644
index 0000000..85d7232
--- /dev/null
+++ b/compiler/testData/codegen/box/invokedynamic/sam/kt512832_inherit_multifile_parts.kt
@@ -0,0 +1,41 @@
+// INHERIT_MULTIFILE_PARTS
+// SAM_CONVERSIONS: INDY
+// TARGET_BACKEND: JVM_IR
+// JVM_TARGET: 1.8
+// WITH_STDLIB
+
+// FILE: Foo.java
+package org.example.foo;
+public interface Foo {
+    String foo(String s);
+}
+
+// FILE: bar1.kt
+
+@file:JvmMultifileClass
+@file:JvmName("Bar")
+
+package org.example.bar
+
+fun doFoo(s: String): String = s.toUpperCase()
+
+// FILE: bar2.kt
+
+@file:JvmMultifileClass
+@file:JvmName("Bar")
+
+package org.example.bar
+
+const val unused = 1
+
+// FILE: Baz.kt
+
+package org.example.baz
+
+import org.example.foo.Foo
+import org.example.bar.doFoo
+
+fun box(): String {
+    val foo = Foo(::doFoo)
+    return foo.foo("ok")
+}
\ No newline at end of file
diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java
index a3e1fff..3798227 100644
--- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java
+++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java
@@ -26793,6 +26793,18 @@
             }
 
             @Test
+            @TestMetadata("kt51282.kt")
+            public void testKt51282() throws Exception {
+                runTest("compiler/testData/codegen/box/invokedynamic/sam/kt51282.kt");
+            }
+
+            @Test
+            @TestMetadata("kt512832_inherit_multifile_parts.kt")
+            public void testKt512832_inherit_multifile_parts() throws Exception {
+                runTest("compiler/testData/codegen/box/invokedynamic/sam/kt512832_inherit_multifile_parts.kt");
+            }
+
+            @Test
             @TestMetadata("kt51868_contravariantGenericSam.kt")
             public void testKt51868_contravariantGenericSam() throws Exception {
                 runTest("compiler/testData/codegen/box/invokedynamic/sam/kt51868_contravariantGenericSam.kt");