FIR2IR: check for @JvmStatic also on property accessors
This commit is contained in:
committed by
teamcity
parent
0b453ee328
commit
a742c126c2
@@ -11,6 +11,7 @@ import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.fir.backend.Fir2IrComponents
|
||||
import org.jetbrains.kotlin.fir.backend.declareThisReceiverParameter
|
||||
import org.jetbrains.kotlin.fir.declarations.FirCallableDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirPropertyAccessor
|
||||
import org.jetbrains.kotlin.fir.declarations.hasAnnotation
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.*
|
||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||
@@ -86,12 +87,14 @@ abstract class AbstractFir2IrLazyFunction<F : FirCallableDeclaration>(
|
||||
get() = null
|
||||
set(_) = error("We should never need to store metadata of external declarations.")
|
||||
|
||||
protected fun shouldHaveDispatchReceiver(
|
||||
containingClass: IrClass,
|
||||
staticOwner: FirCallableDeclaration
|
||||
): Boolean {
|
||||
return !staticOwner.isStatic && !containingClass.isFacadeClass &&
|
||||
(!containingClass.isObject || containingClass.isCompanion || !staticOwner.hasAnnotation(JVM_STATIC_CLASS_ID))
|
||||
protected fun shouldHaveDispatchReceiver(containingClass: IrClass): Boolean {
|
||||
return !fir.isStatic && !containingClass.isFacadeClass &&
|
||||
(!containingClass.isObject || containingClass.isCompanion || !hasJvmStaticAnnotation())
|
||||
}
|
||||
|
||||
private fun hasJvmStaticAnnotation(): Boolean {
|
||||
return fir.hasAnnotation(JVM_STATIC_CLASS_ID) ||
|
||||
(fir as? FirPropertyAccessor)?.propertySymbol?.fir?.hasAnnotation(JVM_STATIC_CLASS_ID) == true
|
||||
}
|
||||
|
||||
protected fun createThisReceiverParameter(thisType: IrType): IrValueParameter {
|
||||
|
||||
@@ -61,8 +61,7 @@ class Fir2IrLazyPropertyAccessor(
|
||||
|
||||
override var dispatchReceiverParameter: IrValueParameter? by lazyVar(lock) {
|
||||
val containingClass = (parent as? IrClass)?.takeUnless { it.isFacadeClass }
|
||||
if (containingClass != null && shouldHaveDispatchReceiver(containingClass, firParentProperty)
|
||||
) {
|
||||
if (containingClass != null && shouldHaveDispatchReceiver(containingClass)) {
|
||||
createThisReceiverParameter(thisType = containingClass.thisReceiver?.type ?: error("No this receiver for containing class"))
|
||||
} else null
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ class Fir2IrLazySimpleFunction(
|
||||
|
||||
override var dispatchReceiverParameter: IrValueParameter? by lazyVar(lock) {
|
||||
val containingClass = parent as? IrClass
|
||||
if (containingClass != null && shouldHaveDispatchReceiver(containingClass, fir)) {
|
||||
if (containingClass != null && shouldHaveDispatchReceiver(containingClass)) {
|
||||
createThisReceiverParameter(thisType = containingClass.thisReceiver?.type ?: error("No this receiver for containing class"))
|
||||
} else null
|
||||
}
|
||||
|
||||
Vendored
-2
@@ -1,6 +1,4 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// FIR status: BKt$box$get$1 cannot be cast to kotlin.reflect.KMutableProperty0
|
||||
// WITH_STDLIB
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
|
||||
Reference in New Issue
Block a user