[FIR] Add test data
diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/backingFieldModifiers.fir.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/backingFieldModifiers.fir.txt new file mode 100644 index 0000000..c625b85 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/backingFieldModifiers.fir.txt
@@ -0,0 +1,28 @@ +FILE: backingFieldModifiers.kt + public final class A : R|kotlin/Any| { + public constructor(): R|A| { + super<R|kotlin/Any|>() + } + + public final val a: R|kotlin/Number| + public get(): R|kotlin/Number| + + public final val b: R|kotlin/Number| + public get(): R|kotlin/Number| + + public final val c: R|kotlin/Number| + public get(): R|kotlin/Number| + + public final val d: R|kotlin/Number| + public get(): R|kotlin/Number| + + public final val e: R|kotlin/Number| + public get(): R|kotlin/Number| + + public final val f: R|kotlin/Number| + public get(): R|kotlin/Number| + + public final val g: R|kotlin/Number| + public get(): R|kotlin/Number| + + }
diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/backingFieldModifiers.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/backingFieldModifiers.kt new file mode 100644 index 0000000..27a4eb9 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/backingFieldModifiers.kt
@@ -0,0 +1,22 @@ +class A { + val a: Number + <!INAPPLICABLE_BACKING_FIELD_MODIFIER!>abstract<!> field = 1 + + val b: Number + <!INAPPLICABLE_BACKING_FIELD_MODIFIER!>open<!> field = 1 + + val c: Number + <!INAPPLICABLE_BACKING_FIELD_MODIFIER!>final<!> field = 1 + + val d: Number + <!INAPPLICABLE_BACKING_FIELD_MODIFIER!>inline<!> field = 1 + + val e: Number + <!INAPPLICABLE_BACKING_FIELD_MODIFIER!>noinline<!> field = 1 + + val f: Number + <!INAPPLICABLE_BACKING_FIELD_MODIFIER!>crossinline<!> field = 1 + + val g: Number + <!INAPPLICABLE_BACKING_FIELD_MODIFIER!>tailrec<!> field = 1 +}
diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/backingFieldVisibility.fir.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/backingFieldVisibility.fir.txt new file mode 100644 index 0000000..be2d478e --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/backingFieldVisibility.fir.txt
@@ -0,0 +1,41 @@ +Module: lib +FILE: A.kt + public final class A : R|kotlin/Any| { + public constructor(): R|A| { + super<R|kotlin/Any|>() + } + + public final val a: R|kotlin/Number| + public get(): R|kotlin/Number| + + public final val b: R|kotlin/Number| + public get(): R|kotlin/Number| + + public final val c: R|kotlin/Number| + public get(): R|kotlin/Number| + + public final val d: R|kotlin/Number| + public get(): R|kotlin/Number| + + public final fun rest(): R|kotlin/Unit| { + lval aI: R|kotlin/Int| = R|/A.A|().R|/A.a|.R|kotlin/Int.plus|(Int(10)) + lval bI: R|kotlin/Int| = R|/A.A|().R|/A.b|.R|kotlin/Int.plus|(Int(20)) + lval cI: <ERROR TYPE REF: Unresolved name: plus> = R|/A.A|().R|/A.c|.<Unresolved name: plus>#(Int(30)) + lval dI: <ERROR TYPE REF: Unresolved name: plus> = R|/A.A|().R|/A.d|.<Unresolved name: plus>#(Int(40)) + } + + } + public final fun test(): R|kotlin/Unit| { + lval aA: <ERROR TYPE REF: Unresolved name: plus> = R|/A.A|().R|/A.a|.<Unresolved name: plus>#(Int(10)) + lval bA: R|kotlin/Int| = R|/A.A|().R|/A.b|.R|kotlin/Int.plus|(Int(20)) + lval cA: <ERROR TYPE REF: Unresolved name: plus> = R|/A.A|().R|/A.c|.<Unresolved name: plus>#(Int(30)) + lval dA: <ERROR TYPE REF: Unresolved name: plus> = R|/A.A|().R|/A.d|.<Unresolved name: plus>#(Int(40)) + } +Module: main +FILE: B.kt + public final fun main(): R|kotlin/Unit| { + lval aB: <ERROR TYPE REF: Unresolved name: plus> = R|/A.A|().R|/A.a|.<Unresolved name: plus>#(Int(10)) + lval bB: <ERROR TYPE REF: Unresolved name: plus> = R|/A.A|().R|/A.b|.<Unresolved name: plus>#(Int(20)) + lval cB: <ERROR TYPE REF: Unresolved name: plus> = R|/A.A|().R|/A.c|.<Unresolved name: plus>#(Int(30)) + lval dB: <ERROR TYPE REF: Unresolved name: plus> = R|/A.A|().R|/A.d|.<Unresolved name: plus>#(Int(40)) + }
diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/backingFieldVisibility.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/backingFieldVisibility.kt new file mode 100644 index 0000000..5564270 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/backingFieldVisibility.kt
@@ -0,0 +1,40 @@ +// MODULE: lib +// FILE: A.kt + +class A { + val a: Number + private field = 1 + + val b: Number + internal field = 2 + + val c: Number + <!INAPPLICABLE_BACKING_FIELD_VISIBILITY!>protected<!> field = 3 + + val d: Number + <!INAPPLICABLE_BACKING_FIELD_VISIBILITY!>public<!> field = 5 + + fun rest() { + val aI = A().a + 10 + val bI = A().b + 20 + val cI = A().c <!UNRESOLVED_REFERENCE!>+<!> 30 + val dI = A().d <!UNRESOLVED_REFERENCE!>+<!> 40 + } +} + +fun test() { + val aA = A().a <!UNRESOLVED_REFERENCE!>+<!> 10 + val bA = A().b + 20 + val cA = A().c <!UNRESOLVED_REFERENCE!>+<!> 30 + val dA = A().d <!UNRESOLVED_REFERENCE!>+<!> 40 +} + +// MODULE: main(lib) +// FILE: B.kt + +fun main() { + val aB = A().a <!UNRESOLVED_REFERENCE!>+<!> 10 + val bB = A().b <!UNRESOLVED_REFERENCE!>+<!> 20 + val cB = A().c <!UNRESOLVED_REFERENCE!>+<!> 30 + val dB = A().d <!UNRESOLVED_REFERENCE!>+<!> 40 +}
diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/explicitBackingFieldInInterface.fir.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/explicitBackingFieldInInterface.fir.txt new file mode 100644 index 0000000..4b958d9 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/explicitBackingFieldInInterface.fir.txt
@@ -0,0 +1,6 @@ +FILE: explicitBackingFieldInInterface.kt + public abstract interface I : R|kotlin/Any| { + public abstract val it: R|kotlin/Number| + public get(): R|kotlin/Number| + + }
diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/explicitBackingFieldInInterface.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/explicitBackingFieldInInterface.kt new file mode 100644 index 0000000..b8ef155 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/explicitBackingFieldInInterface.kt
@@ -0,0 +1,4 @@ +interface I { + val it: Number + <!EXPLICIT_BACKING_FIELD_IN_INTERFACE!>field = 10<!> +}
diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/explicitBackingFieldType.fir.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/explicitBackingFieldType.fir.txt new file mode 100644 index 0000000..bd0df9f --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/explicitBackingFieldType.fir.txt
@@ -0,0 +1,49 @@ +FILE: explicitBackingFieldType.kt + public final class A : R|kotlin/Any| { + public constructor(): R|A| { + super<R|kotlin/Any|>() + } + + public final val a: R|kotlin/Int| = Int(20) + public get(): R|kotlin/Int| + + public final val it: R|kotlin/Number| + public get(): R|kotlin/Number| + + public final val joke: R|kotlin/Number| + + + public final val incompatible: R|kotlin/Number| + + + public final val customGetterNeeded: R|kotlin/Int| + + + public final val invertedTypes: R|kotlin/Int| + public get(): R|kotlin/Int| { + ^ Int(30) + } + + public final val uninitialized: R|kotlin/Number| + public get(): R|kotlin/Number| + + public final val uninitializedWithGetter: R|kotlin/Number| + public get(): R|kotlin/Number| { + ^ Int(2) + } + + public final val initiaizedWithExplicitBackingField: R|kotlin/collections/List<kotlin/Int>| = R|kotlin/collections/listOf|<R|kotlin/Int|>(vararg(Int(1), Int(2))) + public get(): R|kotlin/collections/List<kotlin/Int>| + + public final val p: R|kotlin/Int| = Int(5) + public get(): R|kotlin/Int| { + ^ this@R|/A|.F|/A.p| + } + + public final var setterNeeded: R|kotlin/Int| + public get(): R|kotlin/Int| { + ^ this@R|/A|.F|/A.setterNeeded|.R|kotlin/String.length| + } + + + }
diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/explicitBackingFieldType.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/explicitBackingFieldType.kt new file mode 100644 index 0000000..3089812 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/explicitBackingFieldType.kt
@@ -0,0 +1,36 @@ +class A { + val a = 20 + + val it: Number + field = 4 + + <!PROPERTY_MUST_HAVE_GETTER!>val joke: Number + field = "Haha"<!> + + <!PROPERTY_MUST_HAVE_GETTER!>val incompatible: Number + field: Any? = 42<!> + + <!PROPERTY_MUST_HAVE_GETTER!>val customGetterNeeded: Int + field: Number = 42<!> + + val invertedTypes: Int + field: Number = 42 + get() = 30 + + val uninitialized: Number + <!PROPERTY_FIELD_DECLARATION_MISSING_INITIALIZER!>field: Int<!> + + val uninitializedWithGetter: Number + <!PROPERTY_FIELD_DECLARATION_MISSING_INITIALIZER!>field: Int<!> + get() = 2 + + val initiaizedWithExplicitBackingField = <!PROPERTY_INITIALIZER_WITH_EXPLICIT_FIELD_DECLARATION!>listOf(1, 2)<!> + <!PROPERTY_FIELD_DECLARATION_MISSING_INITIALIZER!>field: MutableList<Int><!> + + val p = 5 + get() = field + + <!PROPERTY_MUST_HAVE_SETTER!>var setterNeeded: Int + field = "test" + get() = field.length<!> +}
diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/localVariablesWithBackingFields.fir.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/localVariablesWithBackingFields.fir.txt new file mode 100644 index 0000000..123c3e0 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/localVariablesWithBackingFields.fir.txt
@@ -0,0 +1,26 @@ +FILE: localVariablesWithBackingFields.kt + public final val that: R|kotlin/Number| + public get(): R|kotlin/Number| + public final fun test(): R|kotlin/Unit| { + lval a: R|kotlin/Number| + <Unresolved name: field># = Int(1) + lval b: R|kotlin/Number|by R|kotlin/lazy|<R|kotlin/Int|>(<L> = lazy@fun <anonymous>(): R|kotlin/Int| <inline=NoInline> { + ^ Int(2) + } + ) + <Unresolved name: field># = Int(10) + } + public final class A : R|kotlin/Any| { + public constructor(): R|A| { + super<R|kotlin/Any|>() + } + + public final val c: R|kotlin/Number|by R|kotlin/lazy|<R|kotlin/Int|>(<L> = lazy@fun <anonymous>(): R|kotlin/Int| <inline=NoInline> { + ^ Int(2) + } + ) + public get(): R|kotlin/Number| { + ^ this@R|/A|.D|/A.c|.R|kotlin/getValue|<R|kotlin/Int|>(this@R|/A|, ::R|/A.c|) + } + + }
diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/localVariablesWithBackingFields.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/localVariablesWithBackingFields.kt new file mode 100644 index 0000000..9bb8174 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/localVariablesWithBackingFields.kt
@@ -0,0 +1,15 @@ +val that: Number + field = 239 + +fun test() { + val a: Number + <!UNRESOLVED_REFERENCE!>field<!> = 1 + + val b: Number by lazy { 2 } + <!UNRESOLVED_REFERENCE!>field<!> = 10 +} + +class A { + val c: Number by lazy { 2 } + field = 10 +}
diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/overriddenPropertiesWithExplicitBackingFields.fir.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/overriddenPropertiesWithExplicitBackingFields.fir.txt new file mode 100644 index 0000000..81fadca --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/overriddenPropertiesWithExplicitBackingFields.fir.txt
@@ -0,0 +1,30 @@ +FILE: overriddenPropertiesWithExplicitBackingFields.kt + public open class A : R|kotlin/Any| { + public constructor(): R|A| { + super<R|kotlin/Any|>() + } + + public open var it: R|kotlin/Number| + public get(): R|kotlin/Number| + public set(value: R|kotlin/Number|): R|kotlin/Unit| { + this@R|/A|.F|/A.it| = R|<local>/value|.R|kotlin/Number.toInt|() + } + + public final fun test(): R|kotlin/Unit| { + <Ambiguity: println, [kotlin/io/println, kotlin/io/println, kotlin/io/println, kotlin/io/println, kotlin/io/println, kotlin/io/println, kotlin/io/println, kotlin/io/println, kotlin/io/println, kotlin/io/println]>#(this@R|/A|.R|/A.it|.<Unresolved name: plus>#(Int(1))) + } + + } + public open class B : R|A| { + public constructor(): R|B| { + super<R|A|>() + } + + public open override var it: R|kotlin/Number| + public get(): R|kotlin/Number| { + ^ Double(3.14) + } + public set(value: R|kotlin/Number|): R|kotlin/Unit| { + } + + }
diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/overriddenPropertiesWithExplicitBackingFields.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/overriddenPropertiesWithExplicitBackingFields.kt new file mode 100644 index 0000000..d018472 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/overriddenPropertiesWithExplicitBackingFields.kt
@@ -0,0 +1,20 @@ +open class A { + open var it: Number + private field = 3 + set(value) { + field = value.toInt() + } + + fun test() { + // error, because `it` is not + // final, so no smart type narrowing + // is provided + <!OVERLOAD_RESOLUTION_AMBIGUITY!>println<!>(it <!UNRESOLVED_REFERENCE!>+<!> 1) + } +} + +open class B : A() { + override var it: Number + get() = 3.14 + set(value) {} +}
diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/propertyTypeNarrowing.fir.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/propertyTypeNarrowing.fir.txt new file mode 100644 index 0000000..f1f6c68 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/propertyTypeNarrowing.fir.txt
@@ -0,0 +1,24 @@ +FILE: propertyTypeNarrowing.kt + public final class A : R|kotlin/Any| { + public constructor(): R|A| { + super<R|kotlin/Any|>() + } + + public final val it: R|kotlin/Number| + public get(): R|kotlin/Number| + + public final fun test(): R|kotlin/Int| { + ^test this@R|/A|.R|/A.it|.R|kotlin/Int.plus|(Int(3)) + } + + public final val p: R|kotlin/Int| = Int(5) + public get(): R|kotlin/Int| { + ^ this@R|/A|.F|/A.p| + } + + } + public final fun test(): R|kotlin/Unit| { + lval c: <ERROR TYPE REF: Unresolved name: plus> = R|/A.A|().R|/A.it|.<Unresolved name: plus>#(Int(1)) + lval d: R|kotlin/Unit| = R|/test|() + lval b: R|kotlin/Int| = R|/A.A|().R|/A.p|.R|kotlin/Int.plus|(Int(2)) + }
diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/propertyTypeNarrowing.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/propertyTypeNarrowing.kt new file mode 100644 index 0000000..ebd1d9e --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/propertyTypeNarrowing.kt
@@ -0,0 +1,15 @@ +class A { + val it: Number + field = 4 + + fun test() = it + 3 + + val p = 5 + get() = field +} + +fun test() { + val c = A().it <!UNRESOLVED_REFERENCE!>+<!> 1 + val d = test() + val b = A().p + 2 +}
diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/randomWeirdBackingFields.fir.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/randomWeirdBackingFields.fir.txt new file mode 100644 index 0000000..beaec6f --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/randomWeirdBackingFields.fir.txt
@@ -0,0 +1,10 @@ +FILE: randomWeirdBackingFields.kt + public abstract class Some1 : R|kotlin/Any| { + public constructor(): R|Some1| { + super<R|kotlin/Any|>() + } + + public abstract val foo: R|kotlin/collections/List<kotlin/Int>| + public get(): R|kotlin/collections/List<kotlin/Int>| + + }
diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/randomWeirdBackingFields.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/randomWeirdBackingFields.kt new file mode 100644 index 0000000..d542584 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/randomWeirdBackingFields.kt
@@ -0,0 +1,4 @@ +abstract class Some1 { + abstract val foo: List<Int> + <!EXPLICIT_BACKING_FIELD_IN_ABSTRACT_PROPERTY!>internal field = mutableListOf<Int>()<!> +}
diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java index f743752..3757329 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java
@@ -5427,6 +5427,74 @@ } @Nested + @TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties") + @TestDataPath("$PROJECT_ROOT") + public class Properties { + @Test + public void testAllFilesPresentInProperties() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @Nested + @TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField") + @TestDataPath("$PROJECT_ROOT") + public class BackingField { + @Test + public void testAllFilesPresentInBackingField() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @Test + @TestMetadata("backingFieldModifiers.kt") + public void testBackingFieldModifiers() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/backingFieldModifiers.kt"); + } + + @Test + @TestMetadata("backingFieldVisibility.kt") + public void testBackingFieldVisibility() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/backingFieldVisibility.kt"); + } + + @Test + @TestMetadata("explicitBackingFieldInInterface.kt") + public void testExplicitBackingFieldInInterface() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/explicitBackingFieldInInterface.kt"); + } + + @Test + @TestMetadata("explicitBackingFieldType.kt") + public void testExplicitBackingFieldType() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/explicitBackingFieldType.kt"); + } + + @Test + @TestMetadata("localVariablesWithBackingFields.kt") + public void testLocalVariablesWithBackingFields() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/localVariablesWithBackingFields.kt"); + } + + @Test + @TestMetadata("overriddenPropertiesWithExplicitBackingFields.kt") + public void testOverriddenPropertiesWithExplicitBackingFields() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/overriddenPropertiesWithExplicitBackingFields.kt"); + } + + @Test + @TestMetadata("propertyTypeNarrowing.kt") + public void testPropertyTypeNarrowing() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/propertyTypeNarrowing.kt"); + } + + @Test + @TestMetadata("randomWeirdBackingFields.kt") + public void testRandomWeirdBackingFields() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/randomWeirdBackingFields.kt"); + } + } + } + + @Nested @TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/reinitializations") @TestDataPath("$PROJECT_ROOT") public class Reinitializations {
diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java index 0e11e04..f347ce1 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java
@@ -5427,6 +5427,74 @@ } @Nested + @TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties") + @TestDataPath("$PROJECT_ROOT") + public class Properties { + @Test + public void testAllFilesPresentInProperties() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @Nested + @TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField") + @TestDataPath("$PROJECT_ROOT") + public class BackingField { + @Test + public void testAllFilesPresentInBackingField() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @Test + @TestMetadata("backingFieldModifiers.kt") + public void testBackingFieldModifiers() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/backingFieldModifiers.kt"); + } + + @Test + @TestMetadata("backingFieldVisibility.kt") + public void testBackingFieldVisibility() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/backingFieldVisibility.kt"); + } + + @Test + @TestMetadata("explicitBackingFieldInInterface.kt") + public void testExplicitBackingFieldInInterface() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/explicitBackingFieldInInterface.kt"); + } + + @Test + @TestMetadata("explicitBackingFieldType.kt") + public void testExplicitBackingFieldType() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/explicitBackingFieldType.kt"); + } + + @Test + @TestMetadata("localVariablesWithBackingFields.kt") + public void testLocalVariablesWithBackingFields() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/localVariablesWithBackingFields.kt"); + } + + @Test + @TestMetadata("overriddenPropertiesWithExplicitBackingFields.kt") + public void testOverriddenPropertiesWithExplicitBackingFields() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/overriddenPropertiesWithExplicitBackingFields.kt"); + } + + @Test + @TestMetadata("propertyTypeNarrowing.kt") + public void testPropertyTypeNarrowing() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/propertyTypeNarrowing.kt"); + } + + @Test + @TestMetadata("randomWeirdBackingFields.kt") + public void testRandomWeirdBackingFields() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/randomWeirdBackingFields.kt"); + } + } + } + + @Nested @TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/reinitializations") @TestDataPath("$PROJECT_ROOT") public class Reinitializations {
diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java index 8839b64..e9c4433 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java
@@ -22038,6 +22038,22 @@ } @Nested + @TestMetadata("compiler/testData/diagnostics/tests/properties/backingField") + @TestDataPath("$PROJECT_ROOT") + public class BackingField { + @Test + public void testAllFilesPresentInBackingField() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/properties/backingField"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); + } + + @Test + @TestMetadata("trivialExplicitBackingFIeld.kt") + public void testTrivialExplicitBackingFIeld() throws Exception { + runTest("compiler/testData/diagnostics/tests/properties/backingField/trivialExplicitBackingFIeld.kt"); + } + } + + @Nested @TestMetadata("compiler/testData/diagnostics/tests/properties/inferenceFromGetters") @TestDataPath("$PROJECT_ROOT") public class InferenceFromGetters {
diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java index ac0e56a..d396ef3 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java
@@ -22038,6 +22038,22 @@ } @Nested + @TestMetadata("compiler/testData/diagnostics/tests/properties/backingField") + @TestDataPath("$PROJECT_ROOT") + public class BackingField { + @Test + public void testAllFilesPresentInBackingField() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/properties/backingField"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); + } + + @Test + @TestMetadata("trivialExplicitBackingFIeld.kt") + public void testTrivialExplicitBackingFIeld() throws Exception { + runTest("compiler/testData/diagnostics/tests/properties/backingField/trivialExplicitBackingFIeld.kt"); + } + } + + @Nested @TestMetadata("compiler/testData/diagnostics/tests/properties/inferenceFromGetters") @TestDataPath("$PROJECT_ROOT") public class InferenceFromGetters {
diff --git a/compiler/fir/fir2ir/testData/codegen/box/properties/backingField/backingFieldVisibility.kt b/compiler/fir/fir2ir/testData/codegen/box/properties/backingField/backingFieldVisibility.kt new file mode 100644 index 0000000..d67f3f3 --- /dev/null +++ b/compiler/fir/fir2ir/testData/codegen/box/properties/backingField/backingFieldVisibility.kt
@@ -0,0 +1,18 @@ +// MODULE: lib +// FILE: A.kt + +class A { + val a: Number + private field = 1 + + val b: Number + internal field = a + 3 +} + +fun box(): String { + return if (A().b + 20 == 24) { + "OK" + } else { + "fail: A().b = " + A().b.toString() + } +}
diff --git a/compiler/fir/fir2ir/testData/codegen/box/properties/backingField/independentBackingFieldType.kt b/compiler/fir/fir2ir/testData/codegen/box/properties/backingField/independentBackingFieldType.kt new file mode 100644 index 0000000..857ad0b --- /dev/null +++ b/compiler/fir/fir2ir/testData/codegen/box/properties/backingField/independentBackingFieldType.kt
@@ -0,0 +1,40 @@ +fun createString() = "AAA" + "BBB" + +class A { + var it: Int + field = 3.14 + get() = (field + 10).toInt() + set(value) { + field = (value - 10).toDouble() + + if (field < -3 || -1 < field) { + throw Exception("fail: value = $value, field = $field") + } + } + + var that: Int + field = createString() + "!" + get() = field.length + set(value) { + field = value.toString() + + if (field != "17") { + throw Exception("fail: value = $value, field = $field") + } + } +} + +fun box(): String { + try { + val a = A() + + val it: Int = A().it and 10 + a.it = it + + val that: Int = a.that + a.that = that + 10 + } catch (e: Exception) { + return e.message ?: "fail" + } + return "OK" +}
diff --git a/compiler/fir/fir2ir/testData/codegen/box/properties/backingField/overriddenPropertiesWithExplicitBackingFields.kt b/compiler/fir/fir2ir/testData/codegen/box/properties/backingField/overriddenPropertiesWithExplicitBackingFields.kt new file mode 100644 index 0000000..469ecd5 --- /dev/null +++ b/compiler/fir/fir2ir/testData/codegen/box/properties/backingField/overriddenPropertiesWithExplicitBackingFields.kt
@@ -0,0 +1,30 @@ +open class A { + open var it: Number + private field = 3 + set(value) { + field = value.toInt() + } + + fun test(): String { + // Note that `it` is open, + // so no smart type narrowing + // is possible, and we expect + // here a call to the possibly + // overridden getter + return if (it.toInt() + 1 == 11) { + "OK" + } else { + "fail: $it" + } + } +} + +open class B : A() { + override var it: Number + get() = 10.12 + set(value) {} +} + +fun box(): String { + return B().test() +}
diff --git a/compiler/fir/fir2ir/testData/ir/irText/properties/backingField/backingFieldVisibility.kt b/compiler/fir/fir2ir/testData/ir/irText/properties/backingField/backingFieldVisibility.kt new file mode 100644 index 0000000..11e34da --- /dev/null +++ b/compiler/fir/fir2ir/testData/ir/irText/properties/backingField/backingFieldVisibility.kt
@@ -0,0 +1,23 @@ +// FIR_IDENTICAL +// MODULE: lib +// FILE: A.kt + +class A { + val a: Number + private field = 1 + + val b: Number + internal field = a + 2 + + val c = 1 + val d = c + 2 + + fun rest() { + val aI = A().a + 10 + val bI = A().b + 20 + } +} + +fun test() { + val bA = A().b + 20 +}
diff --git a/compiler/fir/fir2ir/testData/ir/irText/properties/backingField/backingFieldVisibility.kt.txt b/compiler/fir/fir2ir/testData/ir/irText/properties/backingField/backingFieldVisibility.kt.txt new file mode 100644 index 0000000..3e2db1d --- /dev/null +++ b/compiler/fir/fir2ir/testData/ir/irText/properties/backingField/backingFieldVisibility.kt.txt
@@ -0,0 +1,34 @@ +class A { + constructor() /* primary */ { + super/*Any*/() + /* <init>() */ + + } + + val a: Int + field = 1 + get + + val b: Int + field = <this>.<get-a>().plus(other = 2) + get + + val c: Int + field = 1 + get + + val d: Int + field = <this>.<get-c>().plus(other = 2) + get + + fun rest() { + val aI: Int = A().<get-a>().plus(other = 10) + val bI: Int = A().<get-b>().plus(other = 20) + } + +} + +fun test() { + val bA: Int = A().<get-b>().plus(other = 20) +} +
diff --git a/compiler/fir/fir2ir/testData/ir/irText/properties/backingField/backingFieldVisibility.txt b/compiler/fir/fir2ir/testData/ir/irText/properties/backingField/backingFieldVisibility.txt new file mode 100644 index 0000000..f50ba97 --- /dev/null +++ b/compiler/fir/fir2ir/testData/ir/irText/properties/backingField/backingFieldVisibility.txt
@@ -0,0 +1,90 @@ +FILE fqName:<root> fileName:/A.kt + CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.A + CONSTRUCTOR visibility:public <> () returnType:<root>.A [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:a visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:private [final] + EXPRESSION_BODY + CONST Int type=kotlin.Int value=1 + FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a> visibility:public modality:FINAL <> ($this:<root>.A) returnType:kotlin.Int + correspondingProperty: PROPERTY name:a visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name:<this> type:<root>.A + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun <get-a> (): kotlin.Int declared in <root>.A' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:private [final]' type=kotlin.Number origin=null + receiver: GET_VAR '<this>: <root>.A declared in <root>.A.<get-a>' type=<root>.A origin=null + PROPERTY name:b visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.Int visibility:internal [final] + EXPRESSION_BODY + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS + $this: CALL 'public final fun <get-a> (): kotlin.Int declared in <root>.A' type=kotlin.Number origin=GET_PROPERTY + $this: GET_VAR '<this>: <root>.A declared in <root>.A' type=<root>.A origin=null + other: CONST Int type=kotlin.Int value=2 + FUN DEFAULT_PROPERTY_ACCESSOR name:<get-b> visibility:public modality:FINAL <> ($this:<root>.A) returnType:kotlin.Int + correspondingProperty: PROPERTY name:b visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name:<this> type:<root>.A + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun <get-b> (): kotlin.Int declared in <root>.A' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.Int visibility:internal [final]' type=kotlin.Number origin=null + receiver: GET_VAR '<this>: <root>.A declared in <root>.A.<get-b>' type=<root>.A origin=null + PROPERTY name:c visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Int visibility:private [final] + EXPRESSION_BODY + CONST Int type=kotlin.Int value=1 + FUN DEFAULT_PROPERTY_ACCESSOR name:<get-c> visibility:public modality:FINAL <> ($this:<root>.A) returnType:kotlin.Int + correspondingProperty: PROPERTY name:c visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name:<this> type:<root>.A + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun <get-c> (): kotlin.Int declared in <root>.A' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR '<this>: <root>.A declared in <root>.A.<get-c>' type=<root>.A origin=null + PROPERTY name:d visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:d type:kotlin.Int visibility:private [final] + EXPRESSION_BODY + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS + $this: CALL 'public final fun <get-c> (): kotlin.Int declared in <root>.A' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR '<this>: <root>.A declared in <root>.A' type=<root>.A origin=null + other: CONST Int type=kotlin.Int value=2 + FUN DEFAULT_PROPERTY_ACCESSOR name:<get-d> visibility:public modality:FINAL <> ($this:<root>.A) returnType:kotlin.Int + correspondingProperty: PROPERTY name:d visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name:<this> type:<root>.A + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun <get-d> (): kotlin.Int declared in <root>.A' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:d type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR '<this>: <root>.A declared in <root>.A.<get-d>' type=<root>.A origin=null + FUN name:rest visibility:public modality:FINAL <> ($this:<root>.A) returnType:kotlin.Unit + $this: VALUE_PARAMETER name:<this> type:<root>.A + BLOCK_BODY + VAR name:aI type:kotlin.Int [val] + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS + $this: CALL 'public final fun <get-a> (): kotlin.Int declared in <root>.A' type=kotlin.Number origin=GET_PROPERTY + $this: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.A' type=<root>.A origin=null + other: CONST Int type=kotlin.Int value=10 + VAR name:bI type:kotlin.Int [val] + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS + $this: CALL 'public final fun <get-b> (): kotlin.Int declared in <root>.A' type=kotlin.Number origin=GET_PROPERTY + $this: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.A' type=<root>.A origin=null + other: CONST Int type=kotlin.Int value=20 + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name:<this> type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name:<this> type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name:<this> type:kotlin.Any + FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + VAR name:bA type:kotlin.Int [val] + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS + $this: CALL 'public final fun <get-b> (): kotlin.Int declared in <root>.A' type=kotlin.Number origin=GET_PROPERTY + $this: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.A' type=<root>.A origin=null + other: CONST Int type=kotlin.Int value=20
diff --git a/compiler/fir/fir2ir/testData/ir/irText/properties/backingField/explicitBackingFieldType.kt b/compiler/fir/fir2ir/testData/ir/irText/properties/backingField/explicitBackingFieldType.kt new file mode 100644 index 0000000..a467840 --- /dev/null +++ b/compiler/fir/fir2ir/testData/ir/irText/properties/backingField/explicitBackingFieldType.kt
@@ -0,0 +1,14 @@ +// FIR_IDENTICAL +class A { + val a = 20 + + val it: Number + field = 4 + + var invertedTypes: Int + field: Number = 42 + get() = if (field.toInt() > 10) field.toInt() else 10 + + val p = 5 + get() = field +}
diff --git a/compiler/fir/fir2ir/testData/ir/irText/properties/backingField/explicitBackingFieldType.kt.txt b/compiler/fir/fir2ir/testData/ir/irText/properties/backingField/explicitBackingFieldType.kt.txt new file mode 100644 index 0000000..db86318 --- /dev/null +++ b/compiler/fir/fir2ir/testData/ir/irText/properties/backingField/explicitBackingFieldType.kt.txt
@@ -0,0 +1,33 @@ +class A { + constructor() /* primary */ { + super/*Any*/() + /* <init>() */ + + } + + val a: Int + field = 20 + get + + val it: Int + field = 4 + get + + var invertedTypes: Number + field = 42 + get(): Int { + return when { + greater(arg0 = <this>.#invertedTypes.toInt(), arg1 = 10) -> <this>.#invertedTypes.toInt() + else -> 10 + } + } + set + + val p: Int + field = 5 + get(): Int { + return <this>.#p + } + +} +
diff --git a/compiler/fir/fir2ir/testData/ir/irText/properties/backingField/explicitBackingFieldType.txt b/compiler/fir/fir2ir/testData/ir/irText/properties/backingField/explicitBackingFieldType.txt new file mode 100644 index 0000000..57d81ab --- /dev/null +++ b/compiler/fir/fir2ir/testData/ir/irText/properties/backingField/explicitBackingFieldType.txt
@@ -0,0 +1,83 @@ +FILE fqName:<root> fileName:/explicitBackingFieldType.kt + CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.A + CONSTRUCTOR visibility:public <> () returnType:<root>.A [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:a visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:private [final] + EXPRESSION_BODY + CONST Int type=kotlin.Int value=20 + FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a> visibility:public modality:FINAL <> ($this:<root>.A) returnType:kotlin.Int + correspondingProperty: PROPERTY name:a visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name:<this> type:<root>.A + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun <get-a> (): kotlin.Int declared in <root>.A' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR '<this>: <root>.A declared in <root>.A.<get-a>' type=<root>.A origin=null + PROPERTY name:it visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:it type:kotlin.Int visibility:private [final] + EXPRESSION_BODY + CONST Int type=kotlin.Int value=4 + FUN DEFAULT_PROPERTY_ACCESSOR name:<get-it> visibility:public modality:FINAL <> ($this:<root>.A) returnType:kotlin.Int + correspondingProperty: PROPERTY name:it visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name:<this> type:<root>.A + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun <get-it> (): kotlin.Int declared in <root>.A' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:it type:kotlin.Int visibility:private [final]' type=kotlin.Number origin=null + receiver: GET_VAR '<this>: <root>.A declared in <root>.A.<get-it>' type=<root>.A origin=null + PROPERTY name:invertedTypes visibility:public modality:FINAL [var] + FIELD PROPERTY_BACKING_FIELD name:invertedTypes type:kotlin.Number visibility:private + EXPRESSION_BODY + CONST Int type=kotlin.Int value=42 + FUN name:<get-invertedTypes> visibility:public modality:FINAL <> ($this:<root>.A) returnType:kotlin.Int + correspondingProperty: PROPERTY name:invertedTypes visibility:public modality:FINAL [var] + $this: VALUE_PARAMETER name:<this> type:<root>.A + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun <get-invertedTypes> (): kotlin.Int declared in <root>.A' + WHEN type=kotlin.Int origin=IF + BRANCH + if: CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT + arg0: CALL 'public abstract fun toInt (): kotlin.Int declared in kotlin.Number' type=kotlin.Int origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:invertedTypes type:kotlin.Number visibility:private' type=kotlin.Number origin=GET_PROPERTY + receiver: GET_VAR '<this>: <root>.A declared in <root>.A.<get-invertedTypes>' type=<root>.A origin=null + arg1: CONST Int type=kotlin.Int value=10 + then: CALL 'public abstract fun toInt (): kotlin.Int declared in kotlin.Number' type=kotlin.Int origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:invertedTypes type:kotlin.Number visibility:private' type=kotlin.Number origin=GET_PROPERTY + receiver: GET_VAR '<this>: <root>.A declared in <root>.A.<get-invertedTypes>' type=<root>.A origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Int type=kotlin.Int value=10 + FUN DEFAULT_PROPERTY_ACCESSOR name:<set-invertedTypes> visibility:public modality:FINAL <> ($this:<root>.A, <set-?>:kotlin.Int) returnType:kotlin.Unit + correspondingProperty: PROPERTY name:invertedTypes visibility:public modality:FINAL [var] + $this: VALUE_PARAMETER name:<this> type:<root>.A + VALUE_PARAMETER name:<set-?> index:0 type:kotlin.Int + BLOCK_BODY + SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:invertedTypes type:kotlin.Number visibility:private' type=kotlin.Unit origin=null + receiver: GET_VAR '<this>: <root>.A declared in <root>.A.<set-invertedTypes>' type=<root>.A origin=null + value: GET_VAR '<set-?>: kotlin.Int declared in <root>.A.<set-invertedTypes>' type=kotlin.Int origin=null + PROPERTY name:p visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:p type:kotlin.Int visibility:private [final] + EXPRESSION_BODY + CONST Int type=kotlin.Int value=5 + FUN name:<get-p> visibility:public modality:FINAL <> ($this:<root>.A) returnType:kotlin.Int + correspondingProperty: PROPERTY name:p visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name:<this> type:<root>.A + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun <get-p> (): kotlin.Int declared in <root>.A' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:p type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=GET_PROPERTY + receiver: GET_VAR '<this>: <root>.A declared in <root>.A.<get-p>' type=<root>.A origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name:<this> type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name:<this> type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name:<this> type:kotlin.Any
diff --git a/compiler/fir/fir2ir/testData/ir/irText/properties/backingField/independentBackingFieldType.kt b/compiler/fir/fir2ir/testData/ir/irText/properties/backingField/independentBackingFieldType.kt new file mode 100644 index 0000000..22650f7 --- /dev/null +++ b/compiler/fir/fir2ir/testData/ir/irText/properties/backingField/independentBackingFieldType.kt
@@ -0,0 +1,15 @@ +// FIR_IDENTICAL +class A { + var it: Int + field = 3.14 + get() = (field + 10).toInt() + set(value) { + field = (value - 10).toDouble() + } +} + +fun test() { + val a = A() + val it: Int = A().it and 10 + a.it = it +}
diff --git a/compiler/fir/fir2ir/testData/ir/irText/properties/backingField/independentBackingFieldType.kt.txt b/compiler/fir/fir2ir/testData/ir/irText/properties/backingField/independentBackingFieldType.kt.txt new file mode 100644 index 0000000..7182e37 --- /dev/null +++ b/compiler/fir/fir2ir/testData/ir/irText/properties/backingField/independentBackingFieldType.kt.txt
@@ -0,0 +1,23 @@ +class A { + constructor() /* primary */ { + super/*Any*/() + /* <init>() */ + + } + + var it: Double + field = 3.14 + get(): Int { + return <this>.#it.plus(other = 10).toInt() + } + set(value: Int) { + <this>.#it = value.minus(other = 10).toDouble() + } + +} + +fun test() { + val a: A = A() + val it: Int = A().<get-it>().and(other = 10) + a.<set-it>(value = it) +}
diff --git a/compiler/fir/fir2ir/testData/ir/irText/properties/backingField/independentBackingFieldType.txt b/compiler/fir/fir2ir/testData/ir/irText/properties/backingField/independentBackingFieldType.txt new file mode 100644 index 0000000..5d9dc92 --- /dev/null +++ b/compiler/fir/fir2ir/testData/ir/irText/properties/backingField/independentBackingFieldType.txt
@@ -0,0 +1,57 @@ +FILE fqName:<root> fileName:/independentBackingFieldType.kt + CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.A + CONSTRUCTOR visibility:public <> () returnType:<root>.A [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:it visibility:public modality:FINAL [var] + FIELD PROPERTY_BACKING_FIELD name:it type:kotlin.Double visibility:private + EXPRESSION_BODY + CONST Double type=kotlin.Double value=3.14 + FUN name:<get-it> visibility:public modality:FINAL <> ($this:<root>.A) returnType:kotlin.Int + correspondingProperty: PROPERTY name:it visibility:public modality:FINAL [var] + $this: VALUE_PARAMETER name:<this> type:<root>.A + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun <get-it> (): kotlin.Int declared in <root>.A' + CALL 'public open fun toInt (): kotlin.Int declared in kotlin.Double' type=kotlin.Int origin=null + $this: CALL 'public final fun plus (other: kotlin.Int): kotlin.Double [operator] declared in kotlin.Double' type=kotlin.Double origin=PLUS + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:it type:kotlin.Double visibility:private' type=kotlin.Double origin=GET_PROPERTY + receiver: GET_VAR '<this>: <root>.A declared in <root>.A.<get-it>' type=<root>.A origin=null + other: CONST Int type=kotlin.Int value=10 + FUN name:<set-it> visibility:public modality:FINAL <> ($this:<root>.A, value:kotlin.Int) returnType:kotlin.Unit + correspondingProperty: PROPERTY name:it visibility:public modality:FINAL [var] + $this: VALUE_PARAMETER name:<this> type:<root>.A + VALUE_PARAMETER name:value index:0 type:kotlin.Int + BLOCK_BODY + SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:it type:kotlin.Double visibility:private' type=kotlin.Unit origin=EQ + receiver: GET_VAR '<this>: <root>.A declared in <root>.A.<set-it>' type=<root>.A origin=null + value: CALL 'public open fun toDouble (): kotlin.Double declared in kotlin.Int' type=kotlin.Double origin=null + $this: CALL 'public final fun minus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=MINUS + $this: GET_VAR 'value: kotlin.Int declared in <root>.A.<set-it>' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=10 + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name:<this> type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name:<this> type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name:<this> type:kotlin.Any + FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + VAR name:a type:<root>.A [val] + CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.A' type=<root>.A origin=null + VAR name:it type:kotlin.Int [val] + CALL 'public final fun and (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun <get-it> (): kotlin.Int declared in <root>.A' type=kotlin.Int origin=GET_PROPERTY + $this: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.A' type=<root>.A origin=null + other: CONST Int type=kotlin.Int value=10 + CALL 'public final fun <set-it> (value: kotlin.Int): kotlin.Unit declared in <root>.A' type=kotlin.Unit origin=EQ + $this: GET_VAR 'val a: <root>.A [val] declared in <root>.test' type=<root>.A origin=null + value: GET_VAR 'val it: kotlin.Int [val] declared in <root>.test' type=kotlin.Int origin=null
diff --git a/compiler/fir/fir2ir/testData/ir/irText/properties/backingField/propertyTypeNarrowing.kt b/compiler/fir/fir2ir/testData/ir/irText/properties/backingField/propertyTypeNarrowing.kt new file mode 100644 index 0000000..e5ae473 --- /dev/null +++ b/compiler/fir/fir2ir/testData/ir/irText/properties/backingField/propertyTypeNarrowing.kt
@@ -0,0 +1,15 @@ +// FIR_IDENTICAL +class A { + val it: Number + field = 4 + + fun test() = it + 3 + + val p = 5 + get() = field +} + +fun test() { + val d = test() + val b = A().p + 2 +}
diff --git a/compiler/fir/fir2ir/testData/ir/irText/properties/backingField/propertyTypeNarrowing.kt.txt b/compiler/fir/fir2ir/testData/ir/irText/properties/backingField/propertyTypeNarrowing.kt.txt new file mode 100644 index 0000000..77083eb --- /dev/null +++ b/compiler/fir/fir2ir/testData/ir/irText/properties/backingField/propertyTypeNarrowing.kt.txt
@@ -0,0 +1,28 @@ +class A { + constructor() /* primary */ { + super/*Any*/() + /* <init>() */ + + } + + val it: Int + field = 4 + get + + fun test(): Int { + return <this>.<get-it>().plus(other = 3) + } + + val p: Int + field = 5 + get(): Int { + return <this>.#p + } + +} + +fun test() { + val d: Unit = test() + val b: Int = A().<get-p>().plus(other = 2) +} +
diff --git a/compiler/fir/fir2ir/testData/ir/irText/properties/backingField/propertyTypeNarrowing.txt b/compiler/fir/fir2ir/testData/ir/irText/properties/backingField/propertyTypeNarrowing.txt new file mode 100644 index 0000000..e4c388b --- /dev/null +++ b/compiler/fir/fir2ir/testData/ir/irText/properties/backingField/propertyTypeNarrowing.txt
@@ -0,0 +1,59 @@ +FILE fqName:<root> fileName:/propertyTypeNarrowing.kt + CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.A + CONSTRUCTOR visibility:public <> () returnType:<root>.A [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:it visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:it type:kotlin.Int visibility:private [final] + EXPRESSION_BODY + CONST Int type=kotlin.Int value=4 + FUN DEFAULT_PROPERTY_ACCESSOR name:<get-it> visibility:public modality:FINAL <> ($this:<root>.A) returnType:kotlin.Int + correspondingProperty: PROPERTY name:it visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name:<this> type:<root>.A + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun <get-it> (): kotlin.Int declared in <root>.A' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:it type:kotlin.Int visibility:private [final]' type=kotlin.Number origin=null + receiver: GET_VAR '<this>: <root>.A declared in <root>.A.<get-it>' type=<root>.A origin=null + FUN name:test visibility:public modality:FINAL <> ($this:<root>.A) returnType:kotlin.Int + $this: VALUE_PARAMETER name:<this> type:<root>.A + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun test (): kotlin.Int declared in <root>.A' + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS + $this: CALL 'public final fun <get-it> (): kotlin.Int declared in <root>.A' type=kotlin.Number origin=GET_PROPERTY + $this: GET_VAR '<this>: <root>.A declared in <root>.A.test' type=<root>.A origin=null + other: CONST Int type=kotlin.Int value=3 + PROPERTY name:p visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:p type:kotlin.Int visibility:private [final] + EXPRESSION_BODY + CONST Int type=kotlin.Int value=5 + FUN name:<get-p> visibility:public modality:FINAL <> ($this:<root>.A) returnType:kotlin.Int + correspondingProperty: PROPERTY name:p visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name:<this> type:<root>.A + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun <get-p> (): kotlin.Int declared in <root>.A' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:p type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=GET_PROPERTY + receiver: GET_VAR '<this>: <root>.A declared in <root>.A.<get-p>' type=<root>.A origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name:<this> type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name:<this> type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name:<this> type:kotlin.Any + FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + VAR name:d type:kotlin.Unit [val] + CALL 'public final fun test (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null + VAR name:b type:kotlin.Int [val] + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS + $this: CALL 'public final fun <get-p> (): kotlin.Int declared in <root>.A' type=kotlin.Int origin=GET_PROPERTY + $this: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.A' type=<root>.A origin=null + other: CONST Int type=kotlin.Int value=2
diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirSpecificBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirSpecificBlackBoxCodegenTestGenerated.java index a69096e..654a6f4 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirSpecificBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirSpecificBlackBoxCodegenTestGenerated.java
@@ -30,4 +30,42 @@ public void testSample() throws Exception { runTest("compiler/fir/fir2ir/testData/codegen/box/sample.kt"); } + + @Nested + @TestMetadata("compiler/fir/fir2ir/testData/codegen/box/properties") + @TestDataPath("$PROJECT_ROOT") + public class Properties { + @Test + public void testAllFilesPresentInProperties() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/fir2ir/testData/codegen/box/properties"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Nested + @TestMetadata("compiler/fir/fir2ir/testData/codegen/box/properties/backingField") + @TestDataPath("$PROJECT_ROOT") + public class BackingField { + @Test + public void testAllFilesPresentInBackingField() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/fir2ir/testData/codegen/box/properties/backingField"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("backingFieldVisibility.kt") + public void testBackingFieldVisibility() throws Exception { + runTest("compiler/fir/fir2ir/testData/codegen/box/properties/backingField/backingFieldVisibility.kt"); + } + + @Test + @TestMetadata("independentBackingFieldType.kt") + public void testIndependentBackingFieldType() throws Exception { + runTest("compiler/fir/fir2ir/testData/codegen/box/properties/backingField/independentBackingFieldType.kt"); + } + + @Test + @TestMetadata("overriddenPropertiesWithExplicitBackingFields.kt") + public void testOverriddenPropertiesWithExplicitBackingFields() throws Exception { + runTest("compiler/fir/fir2ir/testData/codegen/box/properties/backingField/overriddenPropertiesWithExplicitBackingFields.kt"); + } + } + } }
diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrSpecificTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrSpecificTextTestGenerated.java index 0a1a830..d901d25 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrSpecificTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrSpecificTextTestGenerated.java
@@ -30,4 +30,48 @@ public void testSample() throws Exception { runTest("compiler/fir/fir2ir/testData/ir/irText/sample.kt"); } + + @Nested + @TestMetadata("compiler/fir/fir2ir/testData/ir/irText/properties") + @TestDataPath("$PROJECT_ROOT") + public class Properties { + @Test + public void testAllFilesPresentInProperties() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/fir2ir/testData/ir/irText/properties"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Nested + @TestMetadata("compiler/fir/fir2ir/testData/ir/irText/properties/backingField") + @TestDataPath("$PROJECT_ROOT") + public class BackingField { + @Test + public void testAllFilesPresentInBackingField() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/fir2ir/testData/ir/irText/properties/backingField"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("backingFieldVisibility.kt") + public void testBackingFieldVisibility() throws Exception { + runTest("compiler/fir/fir2ir/testData/ir/irText/properties/backingField/backingFieldVisibility.kt"); + } + + @Test + @TestMetadata("explicitBackingFieldType.kt") + public void testExplicitBackingFieldType() throws Exception { + runTest("compiler/fir/fir2ir/testData/ir/irText/properties/backingField/explicitBackingFieldType.kt"); + } + + @Test + @TestMetadata("independentBackingFieldType.kt") + public void testIndependentBackingFieldType() throws Exception { + runTest("compiler/fir/fir2ir/testData/ir/irText/properties/backingField/independentBackingFieldType.kt"); + } + + @Test + @TestMetadata("propertyTypeNarrowing.kt") + public void testPropertyTypeNarrowing() throws Exception { + runTest("compiler/fir/fir2ir/testData/ir/irText/properties/backingField/propertyTypeNarrowing.kt"); + } + } + } }
diff --git a/compiler/testData/diagnostics/tests/properties/backingField/trivialExplicitBackingFIeld.fir.kt b/compiler/testData/diagnostics/tests/properties/backingField/trivialExplicitBackingFIeld.fir.kt new file mode 100644 index 0000000..c1652b9 --- /dev/null +++ b/compiler/testData/diagnostics/tests/properties/backingField/trivialExplicitBackingFIeld.fir.kt
@@ -0,0 +1,4 @@ +class A { + val number: Number + field = 1 +}
diff --git a/compiler/testData/diagnostics/tests/properties/backingField/trivialExplicitBackingFIeld.kt b/compiler/testData/diagnostics/tests/properties/backingField/trivialExplicitBackingFIeld.kt new file mode 100644 index 0000000..8e65971 --- /dev/null +++ b/compiler/testData/diagnostics/tests/properties/backingField/trivialExplicitBackingFIeld.kt
@@ -0,0 +1,4 @@ +class A { + <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>val number: Number<!> + <!EXPLICIT_BACKING_FIELDS_UNSUPPORTED!>field = 1<!> +}
diff --git a/compiler/testData/diagnostics/tests/properties/backingField/trivialExplicitBackingFIeld.txt b/compiler/testData/diagnostics/tests/properties/backingField/trivialExplicitBackingFIeld.txt new file mode 100644 index 0000000..4ae91ff --- /dev/null +++ b/compiler/testData/diagnostics/tests/properties/backingField/trivialExplicitBackingFIeld.txt
@@ -0,0 +1,9 @@ +package + +public final class A { + public constructor A() + public final val number: kotlin.Number + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +}
diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index 516031c..26c821b 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java
@@ -22044,6 +22044,22 @@ } @Nested + @TestMetadata("compiler/testData/diagnostics/tests/properties/backingField") + @TestDataPath("$PROJECT_ROOT") + public class BackingField { + @Test + public void testAllFilesPresentInBackingField() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/properties/backingField"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); + } + + @Test + @TestMetadata("trivialExplicitBackingFIeld.kt") + public void testTrivialExplicitBackingFIeld() throws Exception { + runTest("compiler/testData/diagnostics/tests/properties/backingField/trivialExplicitBackingFIeld.kt"); + } + } + + @Nested @TestMetadata("compiler/testData/diagnostics/tests/properties/inferenceFromGetters") @TestDataPath("$PROJECT_ROOT") public class InferenceFromGetters {
diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/tests/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostic/compiler/based/DiagnosisCompilerFirTestdataTestGenerated.java b/idea/idea-frontend-fir/idea-fir-low-level-api/tests/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostic/compiler/based/DiagnosisCompilerFirTestdataTestGenerated.java index e5c70c2..edacd01 100644 --- a/idea/idea-frontend-fir/idea-fir-low-level-api/tests/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostic/compiler/based/DiagnosisCompilerFirTestdataTestGenerated.java +++ b/idea/idea-frontend-fir/idea-fir-low-level-api/tests/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostic/compiler/based/DiagnosisCompilerFirTestdataTestGenerated.java
@@ -5427,6 +5427,74 @@ } @Nested + @TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties") + @TestDataPath("$PROJECT_ROOT") + public class Properties { + @Test + public void testAllFilesPresentInProperties() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @Nested + @TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField") + @TestDataPath("$PROJECT_ROOT") + public class BackingField { + @Test + public void testAllFilesPresentInBackingField() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @Test + @TestMetadata("backingFieldModifiers.kt") + public void testBackingFieldModifiers() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/backingFieldModifiers.kt"); + } + + @Test + @TestMetadata("backingFieldVisibility.kt") + public void testBackingFieldVisibility() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/backingFieldVisibility.kt"); + } + + @Test + @TestMetadata("explicitBackingFieldInInterface.kt") + public void testExplicitBackingFieldInInterface() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/explicitBackingFieldInInterface.kt"); + } + + @Test + @TestMetadata("explicitBackingFieldType.kt") + public void testExplicitBackingFieldType() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/explicitBackingFieldType.kt"); + } + + @Test + @TestMetadata("localVariablesWithBackingFields.kt") + public void testLocalVariablesWithBackingFields() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/localVariablesWithBackingFields.kt"); + } + + @Test + @TestMetadata("overriddenPropertiesWithExplicitBackingFields.kt") + public void testOverriddenPropertiesWithExplicitBackingFields() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/overriddenPropertiesWithExplicitBackingFields.kt"); + } + + @Test + @TestMetadata("propertyTypeNarrowing.kt") + public void testPropertyTypeNarrowing() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/propertyTypeNarrowing.kt"); + } + + @Test + @TestMetadata("randomWeirdBackingFields.kt") + public void testRandomWeirdBackingFields() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/randomWeirdBackingFields.kt"); + } + } + } + + @Nested @TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/reinitializations") @TestDataPath("$PROJECT_ROOT") public class Reinitializations {
diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/tests/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java b/idea/idea-frontend-fir/idea-fir-low-level-api/tests/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java index 062d926..55ff670 100644 --- a/idea/idea-frontend-fir/idea-fir-low-level-api/tests/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java +++ b/idea/idea-frontend-fir/idea-fir-low-level-api/tests/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java
@@ -22038,6 +22038,22 @@ } @Nested + @TestMetadata("compiler/testData/diagnostics/tests/properties/backingField") + @TestDataPath("$PROJECT_ROOT") + public class BackingField { + @Test + public void testAllFilesPresentInBackingField() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/properties/backingField"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); + } + + @Test + @TestMetadata("trivialExplicitBackingFIeld.kt") + public void testTrivialExplicitBackingFIeld() throws Exception { + runTest("compiler/testData/diagnostics/tests/properties/backingField/trivialExplicitBackingFIeld.kt"); + } + } + + @Nested @TestMetadata("compiler/testData/diagnostics/tests/properties/inferenceFromGetters") @TestDataPath("$PROJECT_ROOT") public class InferenceFromGetters {