diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/untypedPropertyWithBackingFieldUsage.fir.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/untypedPropertyWithBackingFieldUsage.fir.txt new file mode 100644 index 00000000000..eca620ce422 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/untypedPropertyWithBackingFieldUsage.fir.txt @@ -0,0 +1,53 @@ +FILE: untypedPropertyWithBackingFieldUsage.kt + public final val simpleNoTypeBlock: + public get(): { + ^ # + } + public final val simpleNoTypeExpression: + public get(): { + ^ # + } + public final val simpleTypeBlock: R|kotlin/Int| + public get(): R|kotlin/Int| { + ^ F|/simpleTypeBlock| + } + public final val simpleTypeExpression: R|kotlin/Int| + public get(): R|kotlin/Int| { + ^ F|/simpleTypeExpression| + } + public final val withFieldNoTypeBlock: R|kotlin/Int| + public get(): R|kotlin/Int| { + ^ #.R|kotlin/text/toInt|() + } + public final val withFieldNoTypeExpression: R|kotlin/Int| + public get(): R|kotlin/Int| { + ^ #.R|kotlin/text/toInt|() + } + public final val withFieldTypeBlock: R|kotlin/Int| + public get(): R|kotlin/Int| { + ^ F|/withFieldTypeBlock|.R|kotlin/Double.toInt|() + } + public final val withFieldTypeExpression: R|kotlin/Int| + public get(): R|kotlin/Int| { + ^ F|/withFieldTypeExpression|.R|kotlin/Double.toInt|() + } + public final val minimalFieldWithInitializer: + public get(): + public final val minimalFieldWithNoInitializer: + public get(): + public final val constWithFieldNoTypeBlock: R|kotlin/Int| + public get(): R|kotlin/Int| { + ^ Int(10) + } + public final val constWithFieldNoTypeExpression: R|kotlin/Int| + public get(): R|kotlin/Int| { + ^ Int(10) + } + public final val constWithFieldTypeBlock: R|kotlin/Int| + public get(): R|kotlin/Int| { + ^ Int(10) + } + public final val constWithFieldTypeExpression: R|kotlin/Int| + public get(): R|kotlin/Int| { + ^ Int(10) + } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/untypedPropertyWithBackingFieldUsage.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/untypedPropertyWithBackingFieldUsage.kt new file mode 100644 index 00000000000..02bee414ad3 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/untypedPropertyWithBackingFieldUsage.kt @@ -0,0 +1,63 @@ +val simpleNoTypeBlock + get() { + return field + } + +val simpleNoTypeExpression + get() = field + +val simpleTypeBlock: Int + get() { + return field + } + +val simpleTypeExpression: Int + get() = field + +val withFieldNoTypeBlock + field = 3.14 + get() { + // *TODO: add support for this? + return field.toInt() + } + +val withFieldNoTypeExpression + field = 3.14 + get() = field.toInt() + +val withFieldTypeBlock: Int + field = 3.14 + get() { + return field.toInt() + } + +val withFieldTypeExpression: Int + field = 3.14 + get() = field.toInt() + +// If * is supported, this is a relevant message +// since adding a getter _may_ be enough +val minimalFieldWithInitializer + field = 1 + +val minimalFieldWithNoInitializer + field: Int + +// TODO: redundant backing field? +// Or we assume someone may still want +// to access it directly via `myProperty#field`? +val constWithFieldNoTypeBlock + field = 3.14 + get() = 10 + +val constWithFieldNoTypeExpression + field = 3.14 + get() = 10 + +val constWithFieldTypeBlock: Int + field = 3.14 + get() = 10 + +val constWithFieldTypeExpression: Int + field = 3.14 + get() = 10 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 d585f74f667..ade35c05d28 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 @@ -5627,6 +5627,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { public void testRedundantExplicitBackingField() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/redundantExplicitBackingField.kt"); } + + @Test + @TestMetadata("untypedPropertyWithBackingFieldUsage.kt") + public void testUntypedPropertyWithBackingFieldUsage() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/untypedPropertyWithBackingFieldUsage.kt"); + } } } 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 52fbd46eba9..970ae4cbcc8 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 @@ -5627,6 +5627,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos public void testRedundantExplicitBackingField() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/redundantExplicitBackingField.kt"); } + + @Test + @TestMetadata("untypedPropertyWithBackingFieldUsage.kt") + public void testUntypedPropertyWithBackingFieldUsage() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/untypedPropertyWithBackingFieldUsage.kt"); + } } } 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 2c8d7c30b76..6842de1ea0a 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 @@ -5627,6 +5627,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis public void testRedundantExplicitBackingField() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/redundantExplicitBackingField.kt"); } + + @Test + @TestMetadata("untypedPropertyWithBackingFieldUsage.kt") + public void testUntypedPropertyWithBackingFieldUsage() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/properties/backingField/untypedPropertyWithBackingFieldUsage.kt"); + } } }