[FIR] Source for property delegates should not be null

^KT-60327 fixed


Merge-request: KT-MR-13221
Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
This commit is contained in:
Egor Kulikov
2023-11-29 08:27:53 +00:00
committed by Space Team
parent 5cf33c3556
commit 001e9a4489
15 changed files with 75 additions and 0 deletions
@@ -52,6 +52,12 @@ public class Fe10IdeNormalAnalysisSourceModuleCollectDiagnosticsTestGenerated ex
runTest("analysis/analysis-api/testData/components/diagnosticsProvider/diagnostics/declarationErrors.kt");
}
@Test
@TestMetadata("incompleteDelegation.kt")
public void testIncompleteDelegation() throws Exception {
runTest("analysis/analysis-api/testData/components/diagnosticsProvider/diagnostics/incompleteDelegation.kt");
}
@Test
@TestMetadata("incompleteFor.kt")
public void testIncompleteFor() throws Exception {
@@ -52,6 +52,12 @@ public class FirIdeNormalAnalysisSourceModuleCollectDiagnosticsTestGenerated ext
runTest("analysis/analysis-api/testData/components/diagnosticsProvider/diagnostics/declarationErrors.kt");
}
@Test
@TestMetadata("incompleteDelegation.kt")
public void testIncompleteDelegation() throws Exception {
runTest("analysis/analysis-api/testData/components/diagnosticsProvider/diagnostics/incompleteDelegation.kt");
}
@Test
@TestMetadata("incompleteFor.kt")
public void testIncompleteFor() throws Exception {
@@ -52,6 +52,12 @@ public class FirStandaloneNormalAnalysisSourceModuleCollectDiagnosticsTestGenera
runTest("analysis/analysis-api/testData/components/diagnosticsProvider/diagnostics/declarationErrors.kt");
}
@Test
@TestMetadata("incompleteDelegation.kt")
public void testIncompleteDelegation() throws Exception {
runTest("analysis/analysis-api/testData/components/diagnosticsProvider/diagnostics/incompleteDelegation.kt");
}
@Test
@TestMetadata("incompleteFor.kt")
public void testIncompleteFor() throws Exception {
@@ -0,0 +1,7 @@
Diagnostics from elements:
for PSI element of type KtParameter at (3,21-28)
UNUSED_PARAMETER text ranges: [(53,54)]
PSI: KtParameter at (3,21-28)
for PSI element of type KtParameter at (3,30-45)
UNUSED_PARAMETER text ranges: [(62,63)]
PSI: KtParameter at (3,30-45)
@@ -0,0 +1,4 @@
import kotlin.reflect.KProperty
fun String.getValue(x: Any?, y: KProperty<*>) = ""
val x: String by <caret>
@@ -0,0 +1 @@
Diagnostics from elements:
@@ -201,6 +201,12 @@ public class FirOutOfContentRootLazyBodiesCalculatorTestGenerated extends Abstra
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/genericProperty.kt");
}
@Test
@TestMetadata("incompletePropertyWithDelegate.kt")
public void testIncompletePropertyWithDelegate() throws Exception {
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/incompletePropertyWithDelegate.kt");
}
@Test
@TestMetadata("initBlockWithDeclarations.kt")
public void testInitBlockWithDeclarations() throws Exception {
@@ -201,6 +201,12 @@ public class FirSourceLazyBodiesCalculatorTestGenerated extends AbstractFirSourc
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/genericProperty.kt");
}
@Test
@TestMetadata("incompletePropertyWithDelegate.kt")
public void testIncompletePropertyWithDelegate() throws Exception {
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/incompletePropertyWithDelegate.kt");
}
@Test
@TestMetadata("initBlockWithDeclarations.kt")
public void testInitBlockWithDeclarations() throws Exception {
@@ -181,6 +181,11 @@ public class LightTree2FirConverterTestCaseGenerated extends AbstractLightTree2F
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/genericProperty.kt");
}
@TestMetadata("incompletePropertyWithDelegate.kt")
public void testIncompletePropertyWithDelegate() throws Exception {
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/incompletePropertyWithDelegate.kt");
}
@TestMetadata("initBlockWithDeclarations.kt")
public void testInitBlockWithDeclarations() throws Exception {
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/initBlockWithDeclarations.kt");
@@ -1976,6 +1976,7 @@ open class PsiRawFirBuilder(
val delegateBuilder = FirWrappedDelegateExpressionBuilder().apply {
val delegateFirExpression = extractDelegateExpression()
source = delegateFirExpression.source?.fakeElement(KtFakeSourceElementKind.WrappedDelegate)
?: this@toFirProperty.delegate?.toFirSourceElement(KtFakeSourceElementKind.WrappedDelegate)
expression = delegateFirExpression
}
@@ -2042,6 +2043,7 @@ open class PsiRawFirBuilder(
val delegateBuilder = FirWrappedDelegateExpressionBuilder().apply {
val delegateExpression = extractDelegateExpression()
source = delegateExpression.source?.fakeElement(KtFakeSourceElementKind.WrappedDelegate)
?: this@toFirProperty.delegate?.toFirSourceElement(KtFakeSourceElementKind.WrappedDelegate)
expression = delegateExpression
}
@@ -0,0 +1,4 @@
import kotlin.reflect.KProperty
fun String.getValue(x: Any?, y: KProperty<*>) = ""
val x: String by
@@ -0,0 +1,4 @@
FILE: incompletePropertyWithDelegate.kt
public? final? fun String.getValue(x: Any?, y: KProperty<*>): <implicit> { LAZY_BLOCK }
public? final? val x: Stringby LAZY_EXPRESSION
public? get(): <implicit> { LAZY_BLOCK }
@@ -0,0 +1,8 @@
FILE: incompletePropertyWithDelegate.kt
public? final? fun String.getValue(x: Any?, y: KProperty<*>): <implicit> {
^getValue String()
}
public? final? val x: Stringby ERROR_EXPR(Should have delegate)
public? get(): <implicit> {
^ D|/x|.getValue#(Null(null), ::R|/x|)
}
@@ -181,6 +181,11 @@ public class RawFirBuilderLazyBodiesTestCaseGenerated extends AbstractRawFirBuil
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/genericProperty.kt");
}
@TestMetadata("incompletePropertyWithDelegate.kt")
public void testIncompletePropertyWithDelegate() throws Exception {
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/incompletePropertyWithDelegate.kt");
}
@TestMetadata("initBlockWithDeclarations.kt")
public void testInitBlockWithDeclarations() throws Exception {
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/initBlockWithDeclarations.kt");
@@ -181,6 +181,11 @@ public class RawFirBuilderTestCaseGenerated extends AbstractRawFirBuilderTestCas
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/genericProperty.kt");
}
@TestMetadata("incompletePropertyWithDelegate.kt")
public void testIncompletePropertyWithDelegate() throws Exception {
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/incompletePropertyWithDelegate.kt");
}
@TestMetadata("initBlockWithDeclarations.kt")
public void testInitBlockWithDeclarations() throws Exception {
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/initBlockWithDeclarations.kt");