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)
|
canSeePrivateMemberOf(containingDeclarations, ownerId, session)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
false
|
declaration is FirSimpleFunction && declaration.isAllowedToBeAccessedFromOutside()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Visibilities.PROTECTED -> {
|
Visibilities.PROTECTED -> {
|
||||||
@@ -461,6 +461,16 @@ internal object CheckVisibility : CheckerStage() {
|
|||||||
return true
|
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? {
|
private fun AbstractFirBasedSymbol<*>.getOwnerId(): ClassId? {
|
||||||
return when (this) {
|
return when (this) {
|
||||||
is FirClassLikeSymbol<*> -> {
|
is FirClassLikeSymbol<*> -> {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
// TARGET_BACKEND: JVM
|
// TARGET_BACKEND: JVM
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
|
|
||||||
import kotlin.jvm.internal.unsafe.*
|
import kotlin.jvm.internal.unsafe.*
|
||||||
|
|||||||
Reference in New Issue
Block a user