Skip to content

Commit 1ecd1d7

Browse files
mglukhikhSpace Team
authored andcommitted
K2: copy publishedApiEffectiveVisibility while creating synthetic SAM functions
#KT-80936 Fixed (cherry picked from commit e8557dc)
1 parent dabe604 commit 1ecd1d7

File tree

3 files changed

+10
-22
lines changed

3 files changed

+10
-22
lines changed

compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/FirSamResolver.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import org.jetbrains.kotlin.fir.moduleData
3131
import org.jetbrains.kotlin.fir.resolve.calls.FirSyntheticFunctionSymbol
3232
import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor
3333
import org.jetbrains.kotlin.fir.resolve.substitution.substitutorByMap
34+
import org.jetbrains.kotlin.fir.resolve.transformers.nonLazyPublishedApiEffectiveVisibility
3435
import org.jetbrains.kotlin.fir.scopes.impl.FirFakeOverrideGenerator
3536
import org.jetbrains.kotlin.fir.scopes.impl.TypeAliasConstructorInfo
3637
import org.jetbrains.kotlin.fir.scopes.impl.hasTypeOf
@@ -229,6 +230,7 @@ class FirSamResolver(
229230
resolvePhase = FirResolvePhase.BODY_RESOLVE
230231
}.apply {
231232
containingClassForStaticMemberAttr = outerClassManager?.outerClass(firRegularClass.symbol)?.toLookupTag()
233+
nonLazyPublishedApiEffectiveVisibility = firRegularClass.nonLazyPublishedApiEffectiveVisibility
232234
}.symbol
233235
}
234236

@@ -267,6 +269,8 @@ class FirSamResolver(
267269
typeAliasSymbol,
268270
substitutor = null,
269271
)
272+
// Typealias cannot be published itself, so we should take the attribute from the expansion class
273+
it.nonLazyPublishedApiEffectiveVisibility = expansionRegularClass.nonLazyPublishedApiEffectiveVisibility
270274
}.symbol
271275
}
272276

compiler/testData/diagnostics/tests/inline/publishedFunInterface.fir.kt

Lines changed: 0 additions & 20 deletions
This file was deleted.

compiler/testData/diagnostics/tests/inline/publishedFunInterface.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// RUN_PIPELINE_TILL: FRONTEND
1+
// FIR_IDENTICAL
2+
// RUN_PIPELINE_TILL: BACKEND
23
// ISSUE: KT-80936
34

45
// FILE: internal.kt
@@ -9,11 +10,14 @@ internal fun interface Foo {
910
suspend fun close()
1011
}
1112

13+
internal typealias TA = Foo
14+
1215
// FILE: use.kt
13-
import internal.Foo
16+
import internal.*
1417

1518
suspend inline fun use() {
1619
val foo = Foo {}
20+
val ta = TA {}
1721
}
1822

1923
/* GENERATED_FIR_TAGS: funInterface, functionDeclaration, inline, interfaceDeclaration, lambdaLiteral, localProperty,

0 commit comments

Comments
 (0)