K2: copy publishedApiEffectiveVisibility while creating synthetic SAM functions

#KT-80936 Fixed

(cherry picked from commit e8557dc9dd8b2ada874c91dd1fd2285a4acb65ca)
diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/FirSamResolver.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/FirSamResolver.kt
index 9beaf4f..909dddf 100644
--- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/FirSamResolver.kt
+++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/FirSamResolver.kt
@@ -31,6 +31,7 @@
 import org.jetbrains.kotlin.fir.resolve.calls.FirSyntheticFunctionSymbol
 import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor
 import org.jetbrains.kotlin.fir.resolve.substitution.substitutorByMap
+import org.jetbrains.kotlin.fir.resolve.transformers.nonLazyPublishedApiEffectiveVisibility
 import org.jetbrains.kotlin.fir.scopes.impl.FirFakeOverrideGenerator
 import org.jetbrains.kotlin.fir.scopes.impl.TypeAliasConstructorInfo
 import org.jetbrains.kotlin.fir.scopes.impl.hasTypeOf
@@ -229,6 +230,7 @@
             resolvePhase = FirResolvePhase.BODY_RESOLVE
         }.apply {
             containingClassForStaticMemberAttr = outerClassManager?.outerClass(firRegularClass.symbol)?.toLookupTag()
+            nonLazyPublishedApiEffectiveVisibility = firRegularClass.nonLazyPublishedApiEffectiveVisibility
         }.symbol
     }
 
@@ -267,6 +269,8 @@
                 typeAliasSymbol,
                 substitutor = null,
             )
+            // Typealias cannot be published itself, so we should take the attribute from the expansion class
+            it.nonLazyPublishedApiEffectiveVisibility = expansionRegularClass.nonLazyPublishedApiEffectiveVisibility
         }.symbol
     }
 
diff --git a/compiler/testData/diagnostics/tests/inline/publishedFunInterface.fir.kt b/compiler/testData/diagnostics/tests/inline/publishedFunInterface.fir.kt
deleted file mode 100644
index dc18807..0000000
--- a/compiler/testData/diagnostics/tests/inline/publishedFunInterface.fir.kt
+++ /dev/null
@@ -1,20 +0,0 @@
-// RUN_PIPELINE_TILL: FRONTEND
-// ISSUE: KT-80936
-
-// FILE: internal.kt
-package internal
-
-@PublishedApi
-internal fun interface Foo {
-    suspend fun close()
-}
-
-// FILE: use.kt
-import internal.Foo
-
-suspend inline fun use() {
-    val foo = <!NON_PUBLIC_CALL_FROM_PUBLIC_INLINE!>Foo<!> {}
-}
-
-/* GENERATED_FIR_TAGS: funInterface, functionDeclaration, inline, interfaceDeclaration, lambdaLiteral, localProperty,
-propertyDeclaration, suspend */
diff --git a/compiler/testData/diagnostics/tests/inline/publishedFunInterface.kt b/compiler/testData/diagnostics/tests/inline/publishedFunInterface.kt
index e429286..1aa9410 100644
--- a/compiler/testData/diagnostics/tests/inline/publishedFunInterface.kt
+++ b/compiler/testData/diagnostics/tests/inline/publishedFunInterface.kt
@@ -1,4 +1,5 @@
-// RUN_PIPELINE_TILL: FRONTEND
+// FIR_IDENTICAL
+// RUN_PIPELINE_TILL: BACKEND
 // ISSUE: KT-80936
 
 // FILE: internal.kt
@@ -9,11 +10,14 @@
     suspend fun close()
 }
 
+internal typealias TA = Foo
+
 // FILE: use.kt
-import internal.Foo
+import internal.*
 
 suspend inline fun use() {
     val foo = Foo {}
+    val ta = TA {}
 }
 
 /* GENERATED_FIR_TAGS: funInterface, functionDeclaration, inline, interfaceDeclaration, lambdaLiteral, localProperty,