JVM_IR KT-43524 static wrappers for deprecated accessors are deprecated
This commit is contained in:
+16
-1
@@ -24,6 +24,8 @@ import org.jetbrains.kotlin.codegen.signature.BothSignatureWriter
|
|||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
|
import org.jetbrains.kotlin.ir.expressions.IrCall
|
||||||
|
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrMemberAccessExpression
|
import org.jetbrains.kotlin.ir.expressions.IrMemberAccessExpression
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||||
@@ -356,7 +358,8 @@ val IrFunction.isSyntheticMethodForProperty: Boolean
|
|||||||
val IrFunction.isDeprecatedFunction: Boolean
|
val IrFunction.isDeprecatedFunction: Boolean
|
||||||
get() = isSyntheticMethodForProperty || isDeprecatedCallable ||
|
get() = isSyntheticMethodForProperty || isDeprecatedCallable ||
|
||||||
(this as? IrSimpleFunction)?.correspondingPropertySymbol?.owner?.isDeprecatedCallable == true ||
|
(this as? IrSimpleFunction)?.correspondingPropertySymbol?.owner?.isDeprecatedCallable == true ||
|
||||||
isAccessorForDeprecatedPropertyImplementedByDelegation
|
isAccessorForDeprecatedPropertyImplementedByDelegation ||
|
||||||
|
isAccessorForDeprecatedJvmStaticProperty
|
||||||
|
|
||||||
private val IrFunction.isAccessorForDeprecatedPropertyImplementedByDelegation: Boolean
|
private val IrFunction.isAccessorForDeprecatedPropertyImplementedByDelegation: Boolean
|
||||||
get() =
|
get() =
|
||||||
@@ -367,6 +370,18 @@ private val IrFunction.isAccessorForDeprecatedPropertyImplementedByDelegation: B
|
|||||||
it.owner.correspondingPropertySymbol?.owner?.isDeprecatedCallable == true
|
it.owner.correspondingPropertySymbol?.owner?.isDeprecatedCallable == true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val IrFunction.isAccessorForDeprecatedJvmStaticProperty: Boolean
|
||||||
|
get() {
|
||||||
|
if (origin != JvmLoweredDeclarationOrigin.JVM_STATIC_WRAPPER) return false
|
||||||
|
val irExpressionBody = this.body as? IrExpressionBody
|
||||||
|
?: throw AssertionError("IrExpressionBody expected for JvmStatic wrapper:\n${this.dump()}")
|
||||||
|
val irCall = irExpressionBody.expression as? IrCall
|
||||||
|
?: throw AssertionError("IrCall expected inside JvmStatic wrapper:\n${this.dump()}")
|
||||||
|
val callee = irCall.symbol.owner
|
||||||
|
val property = callee.correspondingPropertySymbol?.owner ?: return false
|
||||||
|
return property.isDeprecatedCallable
|
||||||
|
}
|
||||||
|
|
||||||
@OptIn(ObsoleteDescriptorBasedAPI::class)
|
@OptIn(ObsoleteDescriptorBasedAPI::class)
|
||||||
val IrDeclaration.psiElement: PsiElement?
|
val IrDeclaration.psiElement: PsiElement?
|
||||||
get() = (descriptor as? DeclarationDescriptorWithSource)?.psiElement
|
get() = (descriptor as? DeclarationDescriptorWithSource)?.psiElement
|
||||||
|
|||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
// WITH_RUNTIME
|
||||||
|
// JVM_TARGET: 1.8
|
||||||
|
|
||||||
|
class TestClass {
|
||||||
|
companion object {
|
||||||
|
@Deprecated("")
|
||||||
|
@JvmStatic
|
||||||
|
val a: Int = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object TestObject {
|
||||||
|
@Deprecated("")
|
||||||
|
@JvmStatic
|
||||||
|
val a: Int = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TestInterface {
|
||||||
|
companion object {
|
||||||
|
@Deprecated("")
|
||||||
|
@JvmStatic
|
||||||
|
val a: Int = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
+53
@@ -0,0 +1,53 @@
|
|||||||
|
@kotlin.Metadata
|
||||||
|
public final class TestClass$Companion {
|
||||||
|
// source: 'jvmStaticDeprecatedProperty.kt'
|
||||||
|
private method <init>(): void
|
||||||
|
public synthetic method <init>(p0: kotlin.jvm.internal.DefaultConstructorMarker): void
|
||||||
|
public synthetic deprecated static @kotlin.Deprecated @kotlin.jvm.JvmStatic method getA$annotations(): void
|
||||||
|
public deprecated final method getA(): int
|
||||||
|
public final inner class TestClass$Companion
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public final class TestClass {
|
||||||
|
// source: 'jvmStaticDeprecatedProperty.kt'
|
||||||
|
public final static @org.jetbrains.annotations.NotNull field Companion: TestClass$Companion
|
||||||
|
private deprecated final static field a: int
|
||||||
|
static method <clinit>(): void
|
||||||
|
public method <init>(): void
|
||||||
|
public synthetic final static method access$getA$cp(): int
|
||||||
|
public deprecated final static method getA(): int
|
||||||
|
public final inner class TestClass$Companion
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public final class TestInterface$Companion {
|
||||||
|
// source: 'jvmStaticDeprecatedProperty.kt'
|
||||||
|
synthetic final static field $$INSTANCE: TestInterface$Companion
|
||||||
|
private deprecated final static field a: int
|
||||||
|
static method <clinit>(): void
|
||||||
|
private method <init>(): void
|
||||||
|
public synthetic deprecated static @kotlin.Deprecated @kotlin.jvm.JvmStatic method getA$annotations(): void
|
||||||
|
public deprecated final method getA(): int
|
||||||
|
public final inner class TestInterface$Companion
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public interface TestInterface {
|
||||||
|
// source: 'jvmStaticDeprecatedProperty.kt'
|
||||||
|
public final static @org.jetbrains.annotations.NotNull field Companion: TestInterface$Companion
|
||||||
|
static method <clinit>(): void
|
||||||
|
public deprecated static method getA(): int
|
||||||
|
public final inner class TestInterface$Companion
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public final class TestObject {
|
||||||
|
// source: 'jvmStaticDeprecatedProperty.kt'
|
||||||
|
public final static @org.jetbrains.annotations.NotNull field INSTANCE: TestObject
|
||||||
|
private deprecated final static field a: int
|
||||||
|
static method <clinit>(): void
|
||||||
|
private method <init>(): void
|
||||||
|
public synthetic deprecated static @kotlin.Deprecated @kotlin.jvm.JvmStatic method getA$annotations(): void
|
||||||
|
public deprecated final static method getA(): int
|
||||||
|
}
|
||||||
+5
@@ -827,6 +827,11 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest {
|
|||||||
public void testInlineClassTypesInSignature() throws Exception {
|
public void testInlineClassTypesInSignature() throws Exception {
|
||||||
runTest("compiler/testData/codegen/bytecodeListing/deprecated/inlineClassTypesInSignature.kt");
|
runTest("compiler/testData/codegen/bytecodeListing/deprecated/inlineClassTypesInSignature.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jvmStaticDeprecatedProperty.kt")
|
||||||
|
public void testJvmStaticDeprecatedProperty() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/bytecodeListing/deprecated/jvmStaticDeprecatedProperty.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/bytecodeListing/inline")
|
@TestMetadata("compiler/testData/codegen/bytecodeListing/inline")
|
||||||
|
|||||||
+5
@@ -797,6 +797,11 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes
|
|||||||
public void testInlineClassTypesInSignature() throws Exception {
|
public void testInlineClassTypesInSignature() throws Exception {
|
||||||
runTest("compiler/testData/codegen/bytecodeListing/deprecated/inlineClassTypesInSignature.kt");
|
runTest("compiler/testData/codegen/bytecodeListing/deprecated/inlineClassTypesInSignature.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jvmStaticDeprecatedProperty.kt")
|
||||||
|
public void testJvmStaticDeprecatedProperty() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/bytecodeListing/deprecated/jvmStaticDeprecatedProperty.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/bytecodeListing/inline")
|
@TestMetadata("compiler/testData/codegen/bytecodeListing/inline")
|
||||||
|
|||||||
Reference in New Issue
Block a user