FIR: special visibility handling for monitor{Enter|Exit}
This commit is contained in:
committed by
Mikhail Glukhikh
parent
85f692ab40
commit
e1abaa9b51
+11
-1
@@ -438,7 +438,7 @@ internal object CheckVisibility : CheckerStage() {
|
||||
canSeePrivateMemberOf(containingDeclarations, ownerId, session)
|
||||
}
|
||||
} else {
|
||||
false
|
||||
declaration is FirSimpleFunction && declaration.isAllowedToBeAccessedFromOutside()
|
||||
}
|
||||
}
|
||||
Visibilities.PROTECTED -> {
|
||||
@@ -461,6 +461,16 @@ internal object CheckVisibility : CheckerStage() {
|
||||
return true
|
||||
}
|
||||
|
||||
// monitorEnter/monitorExit are the only functions which are accessed "illegally" (see kotlin/util/Synchronized.kt).
|
||||
// Since they are intrinsified in the codegen, FIR should treat it as visible.
|
||||
private fun FirSimpleFunction.isAllowedToBeAccessedFromOutside(): Boolean {
|
||||
if (!isFromLibrary) return false
|
||||
val packageName = symbol.callableId.packageName.asString()
|
||||
val name = name.asString()
|
||||
return packageName == "kotlin.jvm.internal.unsafe" &&
|
||||
(name == "monitorEnter" || name == "monitorExit")
|
||||
}
|
||||
|
||||
private fun AbstractFirBasedSymbol<*>.getOwnerId(): ClassId? {
|
||||
return when (this) {
|
||||
is FirClassLikeSymbol<*> -> {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
|
||||
import kotlin.jvm.internal.unsafe.*
|
||||
|
||||
Reference in New Issue
Block a user