FIR: handle SAM constructor properly in visibility checker
#KT-46074 Fixed
This commit is contained in:
+10
@@ -5,6 +5,12 @@ FILE: kotlinSam.kt
|
||||
}
|
||||
public final fun foo(m: R|MyRunnable|): R|kotlin/Unit| {
|
||||
}
|
||||
private abstract interface PrivateRunnable : R|kotlin/Any| {
|
||||
public abstract fun bar(x: R|kotlin/String|): R|kotlin/Boolean|
|
||||
|
||||
}
|
||||
private final fun bar(pr: R|PrivateRunnable|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun main(): R|kotlin/Unit| {
|
||||
R|/foo|(R|/MyRunnable|(<L> = MyRunnable@fun <anonymous>(x: R|kotlin/Int|): R|kotlin/Boolean| <inline=NoInline> {
|
||||
^ CMP(>, R|<local>/x|.R|kotlin/Int.compareTo|(Int(1)))
|
||||
@@ -19,4 +25,8 @@ FILE: kotlinSam.kt
|
||||
}
|
||||
|
||||
R|/foo|(R|/MyRunnable|(R|<local>/x|))
|
||||
R|/bar|(R|/PrivateRunnable|(<L> = PrivateRunnable@fun <anonymous>(s: R|kotlin/String|): R|kotlin/Boolean| <inline=NoInline> {
|
||||
^ CMP(>, R|<local>/s|.R|kotlin/String.length|.R|kotlin/Int.compareTo|(Int(0)))
|
||||
}
|
||||
))
|
||||
}
|
||||
|
||||
@@ -4,6 +4,12 @@ fun interface MyRunnable {
|
||||
|
||||
fun foo(m: MyRunnable) {}
|
||||
|
||||
private fun interface PrivateRunnable {
|
||||
fun bar(x: String): Boolean
|
||||
}
|
||||
|
||||
private fun bar(pr: PrivateRunnable) {}
|
||||
|
||||
fun main() {
|
||||
foo(MyRunnable { x ->
|
||||
x > 1
|
||||
@@ -14,4 +20,6 @@ fun main() {
|
||||
val x = { x: Int -> x > 1 }
|
||||
|
||||
foo(MyRunnable(x))
|
||||
|
||||
bar(PrivateRunnable { s -> s.length > 0 })
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.Candidate
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.FirSyntheticFunctionSymbol
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.ReceiverValue
|
||||
import org.jetbrains.kotlin.fir.resolve.firProvider
|
||||
import org.jetbrains.kotlin.fir.resolve.symbolProvider
|
||||
@@ -77,6 +78,11 @@ abstract class FirVisibilityChecker : FirSessionComponent {
|
||||
when {
|
||||
ownerId == null -> {
|
||||
val candidateFile = when (symbol) {
|
||||
is FirSyntheticFunctionSymbol -> {
|
||||
// SAM case
|
||||
val classId = ClassId(symbol.callableId.packageName, symbol.callableId.callableName)
|
||||
provider.getFirClassifierContainerFile(classId)
|
||||
}
|
||||
is FirClassLikeSymbol<*> -> provider.getFirClassifierContainerFileIfAny(symbol)
|
||||
is FirCallableSymbol<*> -> provider.getFirCallableContainerFile(symbol)
|
||||
else -> null
|
||||
|
||||
Reference in New Issue
Block a user