diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFirTestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFirTestdataTestGenerated.java index 15cee5f7dd5..655c6d094b4 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFirTestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFirTestdataTestGenerated.java @@ -3865,6 +3865,12 @@ public class DiagnosticCompilerTestFirTestdataTestGenerated extends AbstractDiag runTest("compiler/fir/analysis-tests/testData/resolve/problems/objectDerivedFromInnerClass.kt"); } + @Test + @TestMetadata("primaryConstructorParameterWithoutReturnType.kt") + public void testPrimaryConstructorParameterWithoutReturnType() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/problems/primaryConstructorParameterWithoutReturnType.kt"); + } + @Test @TestMetadata("questionableSmartCast.kt") public void testQuestionableSmartCast() throws Exception { diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFirTestDataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFirTestDataTestGenerated.java index 59729546ffc..bb3bf932120 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFirTestDataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFirTestDataTestGenerated.java @@ -3865,6 +3865,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFirTestDataTestGenerated runTest("compiler/fir/analysis-tests/testData/resolve/problems/objectDerivedFromInnerClass.kt"); } + @Test + @TestMetadata("primaryConstructorParameterWithoutReturnType.kt") + public void testPrimaryConstructorParameterWithoutReturnType() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/problems/primaryConstructorParameterWithoutReturnType.kt"); + } + @Test @TestMetadata("questionableSmartCast.kt") public void testQuestionableSmartCast() throws Exception { diff --git a/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTestGenerated.java b/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTestGenerated.java index b65e11ca27d..3dff52d8c8d 100644 --- a/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTestGenerated.java +++ b/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTestGenerated.java @@ -3396,6 +3396,11 @@ public class LazyBodyIsNotTouchedTestGenerated extends AbstractLazyBodyIsNotTouc runTest("compiler/fir/analysis-tests/testData/resolve/problems/objectDerivedFromInnerClass.kt"); } + @TestMetadata("primaryConstructorParameterWithoutReturnType.kt") + public void testPrimaryConstructorParameterWithoutReturnType() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/problems/primaryConstructorParameterWithoutReturnType.kt"); + } + @TestMetadata("questionableSmartCast.kt") public void testQuestionableSmartCast() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/problems/questionableSmartCast.kt"); diff --git a/compiler/fir/analysis-tests/testData/resolve/problems/primaryConstructorParameterWithoutReturnType.fir.txt b/compiler/fir/analysis-tests/testData/resolve/problems/primaryConstructorParameterWithoutReturnType.fir.txt new file mode 100644 index 00000000000..06ceb549e62 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/problems/primaryConstructorParameterWithoutReturnType.fir.txt @@ -0,0 +1,73 @@ +FILE: primaryConstructorParameterWithoutReturnType.kt + public final data class NoParameterNameAndReturnType : R|kotlin/Any| { + public constructor(): R|NoParameterNameAndReturnType| { + super() + } + + public final val : = R|/| + public get(): + + public final operator fun component1(): + + public final fun copy( = this@R|/NoParameterNameAndReturnType|.R|/NoParameterNameAndReturnType.|): R|NoParameterNameAndReturnType| + + } + public final data class NoParameterReturnTypeInTheMiddle : R|kotlin/Any| { + public constructor(x: R|kotlin/Int|, , z: R|kotlin/Int|): R|NoParameterReturnTypeInTheMiddle| { + super() + } + + public final val x: R|kotlin/Int| = R|/x| + public get(): R|kotlin/Int| + + public final val : = R|/| + public get(): + + public final val z: R|kotlin/Int| = R|/z| + public get(): R|kotlin/Int| + + public final operator fun component1(): R|kotlin/Int| + + public final operator fun component2(): + + public final operator fun component3(): R|kotlin/Int| + + public final fun copy(x: R|kotlin/Int| = this@R|/NoParameterReturnTypeInTheMiddle|.R|/NoParameterReturnTypeInTheMiddle.x|, = this@R|/NoParameterReturnTypeInTheMiddle|.R|/NoParameterReturnTypeInTheMiddle.|, z: R|kotlin/Int| = this@R|/NoParameterReturnTypeInTheMiddle|.R|/NoParameterReturnTypeInTheMiddle.z|): R|NoParameterReturnTypeInTheMiddle| + + } + public final data class NoParameterReturnType : R|kotlin/Any| { + public constructor(x: ): R|NoParameterReturnType| { + super() + } + + public final val x: = R|/x| + public get(): + + public final operator fun component1(): + + public final fun copy(x: = this@R|/NoParameterReturnType|.R|/NoParameterReturnType.x|): R|NoParameterReturnType| + + } + public final data class NoParameterReturnTypeInTheMiddle : R|kotlin/Any| { + public constructor(x: R|kotlin/Int|, y: , z: R|kotlin/Int|): R|NoParameterReturnTypeInTheMiddle| { + super() + } + + public final val x: R|kotlin/Int| = R|/x| + public get(): R|kotlin/Int| + + public final val y: = R|/y| + public get(): + + public final val z: R|kotlin/Int| = R|/z| + public get(): R|kotlin/Int| + + public final operator fun component1(): R|kotlin/Int| + + public final operator fun component2(): + + public final operator fun component3(): R|kotlin/Int| + + public final fun copy(x: R|kotlin/Int| = this@R|/NoParameterReturnTypeInTheMiddle|.R|/NoParameterReturnTypeInTheMiddle.x|, y: = this@R|/NoParameterReturnTypeInTheMiddle|.R|/NoParameterReturnTypeInTheMiddle.y|, z: R|kotlin/Int| = this@R|/NoParameterReturnTypeInTheMiddle|.R|/NoParameterReturnTypeInTheMiddle.z|): R|NoParameterReturnTypeInTheMiddle| + + } diff --git a/compiler/fir/analysis-tests/testData/resolve/problems/primaryConstructorParameterWithoutReturnType.kt b/compiler/fir/analysis-tests/testData/resolve/problems/primaryConstructorParameterWithoutReturnType.kt new file mode 100644 index 00000000000..d96069af5d1 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/problems/primaryConstructorParameterWithoutReturnType.kt @@ -0,0 +1,7 @@ +data class NoParameterNameAndReturnType(val) + +data class NoParameterReturnTypeInTheMiddle(val x: Int, val, val z: Int) + +data class NoParameterReturnType(val x) + +data class NoParameterReturnTypeInTheMiddle(val x: Int, val y, val z: Int) diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeDiagnosticsTestGenerated.java index 2c66e1f6aa7..0a4cccd1199 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeDiagnosticsTestGenerated.java @@ -3865,6 +3865,12 @@ public class FirLightTreeDiagnosticsTestGenerated extends AbstractFirLightTreeDi runTest("compiler/fir/analysis-tests/testData/resolve/problems/objectDerivedFromInnerClass.kt"); } + @Test + @TestMetadata("primaryConstructorParameterWithoutReturnType.kt") + public void testPrimaryConstructorParameterWithoutReturnType() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/problems/primaryConstructorParameterWithoutReturnType.kt"); + } + @Test @TestMetadata("questionableSmartCast.kt") public void testQuestionableSmartCast() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiDiagnosticTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiDiagnosticTestGenerated.java index 48dec3f5f80..d364a732d4a 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiDiagnosticTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiDiagnosticTestGenerated.java @@ -3865,6 +3865,12 @@ public class FirPsiDiagnosticTestGenerated extends AbstractFirPsiDiagnosticTest runTest("compiler/fir/analysis-tests/testData/resolve/problems/objectDerivedFromInnerClass.kt"); } + @Test + @TestMetadata("primaryConstructorParameterWithoutReturnType.kt") + public void testPrimaryConstructorParameterWithoutReturnType() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/problems/primaryConstructorParameterWithoutReturnType.kt"); + } + @Test @TestMetadata("questionableSmartCast.kt") public void testQuestionableSmartCast() throws Exception { diff --git a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/PsiRawFirBuilder.kt b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/PsiRawFirBuilder.kt index a8f16392a02..b6433ec8c30 100644 --- a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/PsiRawFirBuilder.kt +++ b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/PsiRawFirBuilder.kt @@ -1351,9 +1351,23 @@ open class PsiRawFirBuilder( createParameterTypeRefWithSourceKind = { property, newKind -> // just making a shallow copy isn't enough type ref may be a function type ref // and contain value parameters inside - withDefaultSourceElementKind(newKind) { - (property.returnTypeRef.psi as KtTypeReference?).toFirOrImplicitType() + + val returnTypeRef = property.returnTypeRef + + when (returnTypeRef) { + is FirErrorTypeRef -> { + buildErrorTypeRefCopy(returnTypeRef) { + source = returnTypeRef.source?.fakeElement(newKind) + } + } + else -> { + withDefaultSourceElementKind(newKind) { + (returnTypeRef.psi as KtTypeReference?).toFirOrImplicitType() + } + } } + + }, addValueParameterAnnotations = { addAnnotationsFrom(it as KtParameter, isFromPrimaryConstructor = true) }, ).generate()