From d93885e71c763fcb67804736686c8a097fac1736 Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Tue, 21 Jul 2020 18:28:17 +0300 Subject: [PATCH] Add tests for deprecated properties --- .../kotlin/fir/Fir2IrTextTestGenerated.java | 5 + .../bytecodeListing/deprecatedProperty.kt | 53 +++++++ .../bytecodeListing/deprecatedProperty.txt | 45 ++++++ .../irText/declarations/deprecatedProperty.kt | 45 ++++++ .../declarations/deprecatedProperty.txt | 149 ++++++++++++++++++ .../codegen/BytecodeListingTestGenerated.java | 5 + .../ir/IrBytecodeListingTestGenerated.java | 5 + .../kotlin/ir/IrTextTestCaseGenerated.java | 5 + 8 files changed, 312 insertions(+) create mode 100644 compiler/testData/codegen/bytecodeListing/deprecatedProperty.kt create mode 100644 compiler/testData/codegen/bytecodeListing/deprecatedProperty.txt create mode 100644 compiler/testData/ir/irText/declarations/deprecatedProperty.kt create mode 100644 compiler/testData/ir/irText/declarations/deprecatedProperty.txt diff --git a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java index ce678357ae5..675bb8dafa1 100644 --- a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java @@ -289,6 +289,11 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { runTest("compiler/testData/ir/irText/declarations/delegatedProperties.kt"); } + @TestMetadata("deprecatedProperty.kt") + public void testDeprecatedProperty() throws Exception { + runTest("compiler/testData/ir/irText/declarations/deprecatedProperty.kt"); + } + @TestMetadata("extensionProperties.kt") public void testExtensionProperties() throws Exception { runTest("compiler/testData/ir/irText/declarations/extensionProperties.kt"); diff --git a/compiler/testData/codegen/bytecodeListing/deprecatedProperty.kt b/compiler/testData/codegen/bytecodeListing/deprecatedProperty.kt new file mode 100644 index 00000000000..921f1172114 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/deprecatedProperty.kt @@ -0,0 +1,53 @@ +@Deprecated("") +val testVal = 1 + +@Deprecated("") +var testVar = 1 + +@Deprecated("") +val testValWithExplicitDefaultGet = 1 + get + +@Deprecated("") +val testValWithExplicitGet + get() = 1 + +@Deprecated("") +var testVarWithExplicitDefaultGet = 1 + get + +@Deprecated("") +var testVarWithExplicitDefaultSet = 1 + set + +@Deprecated("") +var testVarWithExplicitDefaultGetSet: Int = 1 + get + set + +@Deprecated("") +var testVarWithExplicitGetSet + get() = 1 + set(v) {} + +@Deprecated("") +lateinit var testLateinitVar: Any + +@Deprecated("") +val Any.testExtVal + get() = 1 + +@Deprecated("") +var Any.textExtVar + get() = 1 + set(v) {} + +@Deprecated("") +val List.testGenExtVal + get() = 1 + +@Deprecated("") +var List.textGenExtVar + get() = 1 + set(v) {} + diff --git a/compiler/testData/codegen/bytecodeListing/deprecatedProperty.txt b/compiler/testData/codegen/bytecodeListing/deprecatedProperty.txt new file mode 100644 index 00000000000..61e4bcb92fc --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/deprecatedProperty.txt @@ -0,0 +1,45 @@ +@kotlin.Metadata +public final class DeprecatedPropertyKt { + public deprecated static field testLateinitVar: java.lang.Object + private deprecated final static field testVal: int + private deprecated final static field testValWithExplicitDefaultGet: int + private deprecated static field testVar: int + private deprecated static field testVarWithExplicitDefaultGet: int + private deprecated static field testVarWithExplicitDefaultGetSet: int + private deprecated static field testVarWithExplicitDefaultSet: int + static method (): void + public synthetic deprecated static @kotlin.Deprecated method getTestExtVal$annotations(p0: java.lang.Object): void + public deprecated final static method getTestExtVal(@org.jetbrains.annotations.NotNull p0: java.lang.Object): int + public synthetic deprecated static @kotlin.Deprecated method getTestGenExtVal$annotations(p0: java.util.List): void + public deprecated final static method getTestGenExtVal(@org.jetbrains.annotations.NotNull p0: java.util.List): int + public synthetic deprecated static @kotlin.Deprecated method getTestLateinitVar$annotations(): void + public deprecated final static @org.jetbrains.annotations.NotNull method getTestLateinitVar(): java.lang.Object + public synthetic deprecated static @kotlin.Deprecated method getTestVal$annotations(): void + public deprecated final static method getTestVal(): int + public synthetic deprecated static @kotlin.Deprecated method getTestValWithExplicitDefaultGet$annotations(): void + public deprecated final static method getTestValWithExplicitDefaultGet(): int + public synthetic deprecated static @kotlin.Deprecated method getTestValWithExplicitGet$annotations(): void + public deprecated final static method getTestValWithExplicitGet(): int + public synthetic deprecated static @kotlin.Deprecated method getTestVar$annotations(): void + public deprecated final static method getTestVar(): int + public synthetic deprecated static @kotlin.Deprecated method getTestVarWithExplicitDefaultGet$annotations(): void + public deprecated final static method getTestVarWithExplicitDefaultGet(): int + public synthetic deprecated static @kotlin.Deprecated method getTestVarWithExplicitDefaultGetSet$annotations(): void + public deprecated final static method getTestVarWithExplicitDefaultGetSet(): int + public synthetic deprecated static @kotlin.Deprecated method getTestVarWithExplicitDefaultSet$annotations(): void + public deprecated final static method getTestVarWithExplicitDefaultSet(): int + public synthetic deprecated static @kotlin.Deprecated method getTestVarWithExplicitGetSet$annotations(): void + public deprecated final static method getTestVarWithExplicitGetSet(): int + public synthetic deprecated static @kotlin.Deprecated method getTextExtVar$annotations(p0: java.lang.Object): void + public deprecated final static method getTextExtVar(@org.jetbrains.annotations.NotNull p0: java.lang.Object): int + public synthetic deprecated static @kotlin.Deprecated method getTextGenExtVar$annotations(p0: java.util.List): void + public deprecated final static method getTextGenExtVar(@org.jetbrains.annotations.NotNull p0: java.util.List): int + public deprecated final static method setTestLateinitVar(@org.jetbrains.annotations.NotNull p0: java.lang.Object): void + public deprecated final static method setTestVar(p0: int): void + public deprecated final static method setTestVarWithExplicitDefaultGet(p0: int): void + public deprecated final static method setTestVarWithExplicitDefaultGetSet(p0: int): void + public deprecated final static method setTestVarWithExplicitDefaultSet(p0: int): void + public deprecated final static method setTestVarWithExplicitGetSet(p0: int): void + public deprecated final static method setTextExtVar(@org.jetbrains.annotations.NotNull p0: java.lang.Object, p1: int): void + public deprecated final static method setTextGenExtVar(@org.jetbrains.annotations.NotNull p0: java.util.List, p1: int): void +} diff --git a/compiler/testData/ir/irText/declarations/deprecatedProperty.kt b/compiler/testData/ir/irText/declarations/deprecatedProperty.kt new file mode 100644 index 00000000000..a4f8201569e --- /dev/null +++ b/compiler/testData/ir/irText/declarations/deprecatedProperty.kt @@ -0,0 +1,45 @@ +// FIR_IDENTICAL + +@Deprecated("") +val testVal = 1 + +@Deprecated("") +var testVar = 1 + +@Deprecated("") +val testValWithExplicitDefaultGet = 1 + get + +@Deprecated("") +val testValWithExplicitGet + get() = 1 + +@Deprecated("") +var testVarWithExplicitDefaultGet = 1 + get + +@Deprecated("") +var testVarWithExplicitDefaultSet = 1 + set + +@Deprecated("") +var testVarWithExplicitDefaultGetSet: Int = 1 + get + set + +@Deprecated("") +var testVarWithExplicitGetSet + get() = 1 + set(v) {} + +@Deprecated("") +lateinit var testLateinitVar: Any + +@Deprecated("") +val Any.testExtVal + get() = 1 + +@Deprecated("") +var Any.textExtVar + get() = 1 + set(v) {} \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/deprecatedProperty.txt b/compiler/testData/ir/irText/declarations/deprecatedProperty.txt new file mode 100644 index 00000000000..0a83917d490 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/deprecatedProperty.txt @@ -0,0 +1,149 @@ +FILE fqName: fileName:/deprecatedProperty.kt + PROPERTY name:testVal visibility:public modality:FINAL [val] + annotations: + Deprecated(message = '', replaceWith = , level = ) + FIELD PROPERTY_BACKING_FIELD name:testVal type:kotlin.Int visibility:private [final,static] + EXPRESSION_BODY + CONST Int type=kotlin.Int value=1 + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int + correspondingProperty: PROPERTY name:testVal visibility:public modality:FINAL [val] + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:testVal type:kotlin.Int visibility:private [final,static]' type=kotlin.Int origin=null + PROPERTY name:testVar visibility:public modality:FINAL [var] + annotations: + Deprecated(message = '', replaceWith = , level = ) + FIELD PROPERTY_BACKING_FIELD name:testVar type:kotlin.Int visibility:private [static] + EXPRESSION_BODY + CONST Int type=kotlin.Int value=1 + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int + correspondingProperty: PROPERTY name:testVar visibility:public modality:FINAL [var] + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:testVar type:kotlin.Int visibility:private [static]' type=kotlin.Int origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> (:kotlin.Int) returnType:kotlin.Unit + correspondingProperty: PROPERTY name:testVar visibility:public modality:FINAL [var] + VALUE_PARAMETER name: index:0 type:kotlin.Int + BLOCK_BODY + SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:testVar type:kotlin.Int visibility:private [static]' type=kotlin.Unit origin=null + value: GET_VAR ': kotlin.Int declared in .' type=kotlin.Int origin=null + PROPERTY name:testValWithExplicitDefaultGet visibility:public modality:FINAL [val] + annotations: + Deprecated(message = '', replaceWith = , level = ) + FIELD PROPERTY_BACKING_FIELD name:testValWithExplicitDefaultGet type:kotlin.Int visibility:private [final,static] + EXPRESSION_BODY + CONST Int type=kotlin.Int value=1 + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int + correspondingProperty: PROPERTY name:testValWithExplicitDefaultGet visibility:public modality:FINAL [val] + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:testValWithExplicitDefaultGet type:kotlin.Int visibility:private [final,static]' type=kotlin.Int origin=null + PROPERTY name:testValWithExplicitGet visibility:public modality:FINAL [val] + annotations: + Deprecated(message = '', replaceWith = , level = ) + FUN name: visibility:public modality:FINAL <> () returnType:kotlin.Int + correspondingProperty: PROPERTY name:testValWithExplicitGet visibility:public modality:FINAL [val] + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' + CONST Int type=kotlin.Int value=1 + PROPERTY name:testVarWithExplicitDefaultGet visibility:public modality:FINAL [var] + annotations: + Deprecated(message = '', replaceWith = , level = ) + FIELD PROPERTY_BACKING_FIELD name:testVarWithExplicitDefaultGet type:kotlin.Int visibility:private [static] + EXPRESSION_BODY + CONST Int type=kotlin.Int value=1 + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int + correspondingProperty: PROPERTY name:testVarWithExplicitDefaultGet visibility:public modality:FINAL [var] + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:testVarWithExplicitDefaultGet type:kotlin.Int visibility:private [static]' type=kotlin.Int origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> (:kotlin.Int) returnType:kotlin.Unit + correspondingProperty: PROPERTY name:testVarWithExplicitDefaultGet visibility:public modality:FINAL [var] + VALUE_PARAMETER name: index:0 type:kotlin.Int + BLOCK_BODY + SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:testVarWithExplicitDefaultGet type:kotlin.Int visibility:private [static]' type=kotlin.Unit origin=null + value: GET_VAR ': kotlin.Int declared in .' type=kotlin.Int origin=null + PROPERTY name:testVarWithExplicitDefaultSet visibility:public modality:FINAL [var] + annotations: + Deprecated(message = '', replaceWith = , level = ) + FIELD PROPERTY_BACKING_FIELD name:testVarWithExplicitDefaultSet type:kotlin.Int visibility:private [static] + EXPRESSION_BODY + CONST Int type=kotlin.Int value=1 + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int + correspondingProperty: PROPERTY name:testVarWithExplicitDefaultSet visibility:public modality:FINAL [var] + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:testVarWithExplicitDefaultSet type:kotlin.Int visibility:private [static]' type=kotlin.Int origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> (:kotlin.Int) returnType:kotlin.Unit + correspondingProperty: PROPERTY name:testVarWithExplicitDefaultSet visibility:public modality:FINAL [var] + VALUE_PARAMETER name: index:0 type:kotlin.Int + BLOCK_BODY + SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:testVarWithExplicitDefaultSet type:kotlin.Int visibility:private [static]' type=kotlin.Unit origin=null + value: GET_VAR ': kotlin.Int declared in .' type=kotlin.Int origin=null + PROPERTY name:testVarWithExplicitDefaultGetSet visibility:public modality:FINAL [var] + annotations: + Deprecated(message = '', replaceWith = , level = ) + FIELD PROPERTY_BACKING_FIELD name:testVarWithExplicitDefaultGetSet type:kotlin.Int visibility:private [static] + EXPRESSION_BODY + CONST Int type=kotlin.Int value=1 + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int + correspondingProperty: PROPERTY name:testVarWithExplicitDefaultGetSet visibility:public modality:FINAL [var] + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:testVarWithExplicitDefaultGetSet type:kotlin.Int visibility:private [static]' type=kotlin.Int origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> (:kotlin.Int) returnType:kotlin.Unit + correspondingProperty: PROPERTY name:testVarWithExplicitDefaultGetSet visibility:public modality:FINAL [var] + VALUE_PARAMETER name: index:0 type:kotlin.Int + BLOCK_BODY + SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:testVarWithExplicitDefaultGetSet type:kotlin.Int visibility:private [static]' type=kotlin.Unit origin=null + value: GET_VAR ': kotlin.Int declared in .' type=kotlin.Int origin=null + PROPERTY name:testVarWithExplicitGetSet visibility:public modality:FINAL [var] + annotations: + Deprecated(message = '', replaceWith = , level = ) + FUN name: visibility:public modality:FINAL <> () returnType:kotlin.Int + correspondingProperty: PROPERTY name:testVarWithExplicitGetSet visibility:public modality:FINAL [var] + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' + CONST Int type=kotlin.Int value=1 + FUN name: visibility:public modality:FINAL <> (v:kotlin.Int) returnType:kotlin.Unit + correspondingProperty: PROPERTY name:testVarWithExplicitGetSet visibility:public modality:FINAL [var] + VALUE_PARAMETER name:v index:0 type:kotlin.Int + BLOCK_BODY + PROPERTY name:testLateinitVar visibility:public modality:FINAL [lateinit,var] + annotations: + Deprecated(message = '', replaceWith = , level = ) + FIELD PROPERTY_BACKING_FIELD name:testLateinitVar type:kotlin.Any visibility:public [static] + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Any + correspondingProperty: PROPERTY name:testLateinitVar visibility:public modality:FINAL [lateinit,var] + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Any declared in ' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:testLateinitVar type:kotlin.Any visibility:public [static]' type=kotlin.Any origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> (:kotlin.Any) returnType:kotlin.Unit + correspondingProperty: PROPERTY name:testLateinitVar visibility:public modality:FINAL [lateinit,var] + VALUE_PARAMETER name: index:0 type:kotlin.Any + BLOCK_BODY + SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:testLateinitVar type:kotlin.Any visibility:public [static]' type=kotlin.Unit origin=null + value: GET_VAR ': kotlin.Any declared in .' type=kotlin.Any origin=null + PROPERTY name:testExtVal visibility:public modality:FINAL [val] + annotations: + Deprecated(message = '', replaceWith = , level = ) + FUN name: visibility:public modality:FINAL <> ($receiver:kotlin.Any) returnType:kotlin.Int + correspondingProperty: PROPERTY name:testExtVal visibility:public modality:FINAL [val] + $receiver: VALUE_PARAMETER name: type:kotlin.Any + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' + CONST Int type=kotlin.Int value=1 + PROPERTY name:textExtVar visibility:public modality:FINAL [var] + annotations: + Deprecated(message = '', replaceWith = , level = ) + FUN name: visibility:public modality:FINAL <> ($receiver:kotlin.Any) returnType:kotlin.Int + correspondingProperty: PROPERTY name:textExtVar visibility:public modality:FINAL [var] + $receiver: VALUE_PARAMETER name: type:kotlin.Any + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' + CONST Int type=kotlin.Int value=1 + FUN name: visibility:public modality:FINAL <> ($receiver:kotlin.Any, v:kotlin.Int) returnType:kotlin.Unit + correspondingProperty: PROPERTY name:textExtVar visibility:public modality:FINAL [var] + $receiver: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:v index:0 type:kotlin.Int + BLOCK_BODY diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java index 5b740166e4d..ceb4fa0f839 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java @@ -59,6 +59,11 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest { runTest("compiler/testData/codegen/bytecodeListing/deprecatedLateinitVar.kt"); } + @TestMetadata("deprecatedProperty.kt") + public void testDeprecatedProperty() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/deprecatedProperty.kt"); + } + @TestMetadata("emptyMultifileFacade.kt") public void testEmptyMultifileFacade() throws Exception { runTest("compiler/testData/codegen/bytecodeListing/emptyMultifileFacade.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java index 5ac2ebe01c6..3b58390a514 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java @@ -59,6 +59,11 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes runTest("compiler/testData/codegen/bytecodeListing/deprecatedLateinitVar.kt"); } + @TestMetadata("deprecatedProperty.kt") + public void testDeprecatedProperty() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/deprecatedProperty.kt"); + } + @TestMetadata("emptyMultifileFacade.kt") public void testEmptyMultifileFacade() throws Exception { runTest("compiler/testData/codegen/bytecodeListing/emptyMultifileFacade.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java index 22fd7baaa4e..9f0d4f8dc45 100644 --- a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java @@ -288,6 +288,11 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase { runTest("compiler/testData/ir/irText/declarations/delegatedProperties.kt"); } + @TestMetadata("deprecatedProperty.kt") + public void testDeprecatedProperty() throws Exception { + runTest("compiler/testData/ir/irText/declarations/deprecatedProperty.kt"); + } + @TestMetadata("extensionProperties.kt") public void testExtensionProperties() throws Exception { runTest("compiler/testData/ir/irText/declarations/extensionProperties.kt");