Minor, move InlineOnly-related utilities to frontend
This commit is contained in:
@@ -17,20 +17,13 @@
|
||||
package org.jetbrains.kotlin.descriptors.annotations
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.MemberDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.constants.AnnotationValue
|
||||
import org.jetbrains.kotlin.resolve.constants.ArrayValue
|
||||
import org.jetbrains.kotlin.resolve.constants.EnumValue
|
||||
import org.jetbrains.kotlin.resolve.constants.StringValue
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
|
||||
fun KotlinBuiltIns.createDeprecatedAnnotation(
|
||||
message: String,
|
||||
@@ -67,24 +60,3 @@ private val DEPRECATED_REPLACE_WITH_NAME = Name.identifier("replaceWith")
|
||||
private val DEPRECATED_LEVEL_NAME = Name.identifier("level")
|
||||
private val REPLACE_WITH_EXPRESSION_NAME = Name.identifier("expression")
|
||||
private val REPLACE_WITH_IMPORTS_NAME = Name.identifier("imports")
|
||||
|
||||
private val INLINE_ONLY_ANNOTATION_FQ_NAME = FqName("kotlin.internal.InlineOnly")
|
||||
|
||||
fun MemberDescriptor.isInlineOnlyOrReifiable(): Boolean =
|
||||
this is CallableMemberDescriptor && (isReifiable() || DescriptorUtils.getDirectMember(this).isReifiable() || isInlineOnly())
|
||||
|
||||
// TODO: move to compiler modules
|
||||
fun MemberDescriptor.isEffectivelyInlineOnly(): Boolean =
|
||||
isInlineOnlyOrReifiable() || (this is FunctionDescriptor && isSuspend && isInline &&
|
||||
(valueParameters.any { it.isCrossinline } || visibility == Visibilities.PRIVATE))
|
||||
|
||||
fun MemberDescriptor.isInlineOnly(): Boolean {
|
||||
if (this !is FunctionDescriptor ||
|
||||
!(hasInlineOnlyAnnotation() || DescriptorUtils.getDirectMember(this).hasInlineOnlyAnnotation())) return false
|
||||
assert(isInline) { "Function is not inline: $this" }
|
||||
return true
|
||||
}
|
||||
|
||||
private fun CallableMemberDescriptor.isReifiable() = typeParameters.any { it.isReified }
|
||||
|
||||
private fun CallableMemberDescriptor.hasInlineOnlyAnnotation() = annotations.hasAnnotation(INLINE_ONLY_ANNOTATION_FQ_NAME)
|
||||
|
||||
Reference in New Issue
Block a user