[Commonizer] Don't filter out @Deprecated non-top-level functions
^KMM-238
This commit is contained in:
+8
-1
@@ -7,9 +7,10 @@ package org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ir
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.Interner
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.Interner
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.appendHashCode
|
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.hashCode
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.hashCode
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.appendHashCode
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.intern
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.intern
|
||||||
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.isUnderStandardKotlinPackages
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.resolve.constants.*
|
import org.jetbrains.kotlin.resolve.constants.*
|
||||||
@@ -64,6 +65,12 @@ internal fun checkSupportedInCommonization(constantValue: ConstantValue<*>, loca
|
|||||||
is EnumValue -> {
|
is EnumValue -> {
|
||||||
// OK
|
// OK
|
||||||
}
|
}
|
||||||
|
is AnnotationValue -> {
|
||||||
|
if (constantValue.value.fqName?.isUnderStandardKotlinPackages != true)
|
||||||
|
error("Only ${constantValue::class.java} const values from Kotlin standard packages are supported, $constantValue at ${location()}")
|
||||||
|
|
||||||
|
Unit
|
||||||
|
}
|
||||||
is ArrayValue -> {
|
is ArrayValue -> {
|
||||||
constantValue.value.forEachIndexed { index, innerConstantValue ->
|
constantValue.value.forEachIndexed { index, innerConstantValue ->
|
||||||
checkSupportedInCommonization(innerConstantValue) { "${location()}[$index]" }
|
checkSupportedInCommonization(innerConstantValue) { "${location()}[$index]" }
|
||||||
|
|||||||
+2
-2
@@ -10,7 +10,7 @@ import org.jetbrains.kotlin.descriptors.commonizer.core.Commonizer
|
|||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.*
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.*
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.fqNameWithTypeParameters
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.fqNameWithTypeParameters
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.isBlacklistedDarwinFunction
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.isBlacklistedDarwinFunction
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.isDeprecated
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.isDeprecatedTopLevelFunction
|
||||||
import org.jetbrains.kotlin.descriptors.commonizer.utils.isKniBridgeFunction
|
import org.jetbrains.kotlin.descriptors.commonizer.utils.isKniBridgeFunction
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||||
@@ -57,7 +57,7 @@ internal inline fun FunctionCollector(
|
|||||||
): (DeclarationDescriptor) -> Boolean = Collector<SimpleFunctionDescriptor> { candidate ->
|
): (DeclarationDescriptor) -> Boolean = Collector<SimpleFunctionDescriptor> { candidate ->
|
||||||
if (candidate.kind.isReal
|
if (candidate.kind.isReal
|
||||||
&& !candidate.isKniBridgeFunction()
|
&& !candidate.isKniBridgeFunction()
|
||||||
&& !candidate.isDeprecated()
|
&& !candidate.isDeprecatedTopLevelFunction()
|
||||||
&& !candidate.isBlacklistedDarwinFunction()
|
&& !candidate.isBlacklistedDarwinFunction()
|
||||||
) {
|
) {
|
||||||
typedCollector(candidate)
|
typedCollector(candidate)
|
||||||
|
|||||||
+2
-2
@@ -15,8 +15,8 @@ private val DEPRECATED_ANNOTATION_FQN = FqName(Deprecated::class.java.name)
|
|||||||
internal fun SimpleFunctionDescriptor.isKniBridgeFunction() =
|
internal fun SimpleFunctionDescriptor.isKniBridgeFunction() =
|
||||||
name.asString().startsWith("kniBridge")
|
name.asString().startsWith("kniBridge")
|
||||||
|
|
||||||
internal fun SimpleFunctionDescriptor.isDeprecated() =
|
internal fun SimpleFunctionDescriptor.isDeprecatedTopLevelFunction() =
|
||||||
annotations.hasAnnotation(DEPRECATED_ANNOTATION_FQN)
|
containingDeclaration is PackageFragmentDescriptor && annotations.hasAnnotation(DEPRECATED_ANNOTATION_FQN)
|
||||||
|
|
||||||
// the following logic determines Kotlin functions with conflicting overloads in Darwin library:
|
// the following logic determines Kotlin functions with conflicting overloads in Darwin library:
|
||||||
internal fun SimpleFunctionDescriptor.isBlacklistedDarwinFunction(): Boolean {
|
internal fun SimpleFunctionDescriptor.isBlacklistedDarwinFunction(): Boolean {
|
||||||
|
|||||||
Vendored
+5
@@ -16,3 +16,8 @@ expect fun externalFunction2()
|
|||||||
|
|
||||||
expect inline fun inlineFunction1() {}
|
expect inline fun inlineFunction1() {}
|
||||||
expect fun inlineFunction2() {}
|
expect fun inlineFunction2() {}
|
||||||
|
|
||||||
|
expect class Holder() {
|
||||||
|
expect fun deprecatedFunction1()
|
||||||
|
expect fun nonDeprecatedFunction1()
|
||||||
|
}
|
||||||
|
|||||||
+10
@@ -17,3 +17,13 @@ actual external fun externalFunction2()
|
|||||||
|
|
||||||
actual inline fun inlineFunction1() {}
|
actual inline fun inlineFunction1() {}
|
||||||
actual inline fun inlineFunction2() {}
|
actual inline fun inlineFunction2() {}
|
||||||
|
|
||||||
|
actual class Holder actual constructor() {
|
||||||
|
@Deprecated("This function is deprecated")
|
||||||
|
actual fun deprecatedFunction1() {}
|
||||||
|
@Deprecated("This function is deprecated")
|
||||||
|
fun deprecatedFunction2() {}
|
||||||
|
|
||||||
|
actual fun nonDeprecatedFunction1() {}
|
||||||
|
fun nonDeprecatedFunction2() {}
|
||||||
|
}
|
||||||
|
|||||||
+10
@@ -17,3 +17,13 @@ actual fun externalFunction2() {}
|
|||||||
|
|
||||||
actual inline fun inlineFunction1() {}
|
actual inline fun inlineFunction1() {}
|
||||||
actual fun inlineFunction2() {}
|
actual fun inlineFunction2() {}
|
||||||
|
|
||||||
|
actual class Holder actual constructor() {
|
||||||
|
@Deprecated("This function is deprecated")
|
||||||
|
actual fun deprecatedFunction1() {}
|
||||||
|
@Deprecated("This function is deprecated")
|
||||||
|
fun deprecatedFunction3() {}
|
||||||
|
|
||||||
|
actual fun nonDeprecatedFunction1() {}
|
||||||
|
fun nonDeprecatedFunction3() {}
|
||||||
|
}
|
||||||
|
|||||||
+12
-2
@@ -18,7 +18,17 @@ external fun externalFunction2()
|
|||||||
inline fun inlineFunction1() {}
|
inline fun inlineFunction1() {}
|
||||||
inline fun inlineFunction2() {}
|
inline fun inlineFunction2() {}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated("This function is deprecated")
|
||||||
fun deprecatedFunction1() {}
|
fun deprecatedFunction1() {}
|
||||||
@Deprecated
|
@Deprecated("This function is deprecated")
|
||||||
fun deprecatedFunction2() {}
|
fun deprecatedFunction2() {}
|
||||||
|
|
||||||
|
class Holder {
|
||||||
|
@Deprecated("This function is deprecated")
|
||||||
|
fun deprecatedFunction1() {}
|
||||||
|
@Deprecated("This function is deprecated")
|
||||||
|
fun deprecatedFunction2() {}
|
||||||
|
|
||||||
|
fun nonDeprecatedFunction1() {}
|
||||||
|
fun nonDeprecatedFunction2() {}
|
||||||
|
}
|
||||||
|
|||||||
+12
-2
@@ -18,7 +18,17 @@ fun externalFunction2() {}
|
|||||||
inline fun inlineFunction1() {}
|
inline fun inlineFunction1() {}
|
||||||
fun inlineFunction2() {}
|
fun inlineFunction2() {}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated("This function is deprecated")
|
||||||
fun deprecatedFunction1() {}
|
fun deprecatedFunction1() {}
|
||||||
@Deprecated
|
@Deprecated("This function is deprecated")
|
||||||
fun deprecatedFunction3() {}
|
fun deprecatedFunction3() {}
|
||||||
|
|
||||||
|
class Holder {
|
||||||
|
@Deprecated("This function is deprecated")
|
||||||
|
fun deprecatedFunction1() {}
|
||||||
|
@Deprecated("This function is deprecated")
|
||||||
|
fun deprecatedFunction3() {}
|
||||||
|
|
||||||
|
fun nonDeprecatedFunction1() {}
|
||||||
|
fun nonDeprecatedFunction3() {}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user