diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/FirLazyBodiesCalculatorTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/FirLazyBodiesCalculatorTestGenerated.java index b8bdd7486c5..c885aff7e3d 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/FirLazyBodiesCalculatorTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/FirLazyBodiesCalculatorTestGenerated.java @@ -290,6 +290,64 @@ public class FirLazyBodiesCalculatorTestGenerated extends AbstractFirLazyBodiesC } } } + + @Nested + @TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType") + @TestDataPath("$PROJECT_ROOT") + public class NoParameterType { + @Test + public void testAllFilesPresentInNoParameterType() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + + @Test + @TestMetadata("noParameterTypRefInCatch.kt") + public void testNoParameterTypRefInCatch() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInCatch.kt"); + } + + @Test + @TestMetadata("noParameterTypRefInFuncionalType.kt") + public void testNoParameterTypRefInFuncionalType() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInFuncionalType.kt"); + } + + @Test + @TestMetadata("noParameterTypRefInFunction.kt") + public void testNoParameterTypRefInFunction() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInFunction.kt"); + } + + @Test + @TestMetadata("noParameterTypRefInLambda.kt") + public void testNoParameterTypRefInLambda() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInLambda.kt"); + } + + @Test + @TestMetadata("noParameterTypRefInPrimaryConstructor.kt") + public void testNoParameterTypRefInPrimaryConstructor() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInPrimaryConstructor.kt"); + } + + @Test + @TestMetadata("noParameterTypRefInPrimaryConsturctorVal.kt") + public void testNoParameterTypRefInPrimaryConsturctorVal() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInPrimaryConsturctorVal.kt"); + } + + @Test + @TestMetadata("noParameterTypRefInSecondaryConstructor.kt") + public void testNoParameterTypRefInSecondaryConstructor() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInSecondaryConstructor.kt"); + } + + @Test + @TestMetadata("noParameterTypRefInSetter.kt") + public void testNoParameterTypRefInSetter() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInSetter.kt"); + } + } } @Nested diff --git a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt index b7292d37be3..d8d80a8e7f7 100644 --- a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt +++ b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt @@ -940,7 +940,7 @@ class DeclarationsConverter( secondaryConstructor.forEachChildren { when (it.tokenType) { MODIFIER_LIST -> modifiers = convertModifierList(it) - VALUE_PARAMETER_LIST -> firValueParameters += convertValueParameters(it) + VALUE_PARAMETER_LIST -> firValueParameters += convertValueParameters(it, ValueParameterDeclaration.FUNCTION) CONSTRUCTOR_DELEGATION_CALL -> constructorDelegationCall = convertConstructorDelegationCall(it, classWrapper) BLOCK -> block = it } @@ -1522,7 +1522,7 @@ class DeclarationsConverter( setterParameter.forEachChildren { when (it.tokenType) { MODIFIER_LIST -> modifiers = convertModifierList(it) - VALUE_PARAMETER -> firValueParameter = convertValueParameter(it).firValueParameter + VALUE_PARAMETER -> firValueParameter = convertValueParameter(it, ValueParameterDeclaration.SETTER).firValueParameter } } @@ -1650,7 +1650,7 @@ class DeclarationsConverter( valueParametersList?.let { list -> valueParameters += convertValueParameters( list, - if (isAnonymousFunction) ValueParameterDeclaration.LAMBDA else ValueParameterDeclaration.OTHER + if (isAnonymousFunction) ValueParameterDeclaration.LAMBDA else ValueParameterDeclaration.FUNCTION ).map { it.firValueParameter } } @@ -2149,7 +2149,7 @@ class DeclarationsConverter( functionType.forEachChildren { when (it.tokenType) { FUNCTION_TYPE_RECEIVER -> receiverTypeReference = convertReceiverType(it) - VALUE_PARAMETER_LIST -> valueParametersList += convertValueParameters(it) + VALUE_PARAMETER_LIST -> valueParametersList += convertValueParameters(it, ValueParameterDeclaration.FUNCTIONAL_TYPE) TYPE_REFERENCE -> returnTypeReference = convertType(it) } } @@ -2174,7 +2174,7 @@ class DeclarationsConverter( */ fun convertValueParameters( valueParameters: LighterASTNode, - valueParameterDeclaration: ValueParameterDeclaration = ValueParameterDeclaration.OTHER, + valueParameterDeclaration: ValueParameterDeclaration, additionalAnnotations: List = emptyList() ): List { return valueParameters.forEachChildrenReturnList { node, container -> @@ -2189,7 +2189,7 @@ class DeclarationsConverter( */ fun convertValueParameter( valueParameter: LighterASTNode, - valueParameterDeclaration: ValueParameterDeclaration = ValueParameterDeclaration.OTHER, + valueParameterDeclaration: ValueParameterDeclaration, additionalAnnotations: List = emptyList() ): ValueParameter { var modifiers = Modifier() @@ -2216,7 +2216,11 @@ class DeclarationsConverter( source = valueParameter.toFirSourceElement() moduleData = baseModuleData origin = FirDeclarationOrigin.Source - returnTypeRef = firType ?: implicitType + returnTypeRef = firType + ?: when { + valueParameterDeclaration.shouldExplicitParameterTypeBePresent -> createNoTypeForParameterTypeRef() + else -> implicitType + } this.name = name symbol = FirValueParameterSymbol(name) defaultValue = firExpression diff --git a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt index 535bd0f8173..a8288d55999 100644 --- a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt +++ b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt @@ -1059,7 +1059,7 @@ class ExpressionsConverter( var blockNode: LighterASTNode? = null forLoop.forEachChildren { when (it.tokenType) { - VALUE_PARAMETER -> parameter = declarationsConverter.convertValueParameter(it) + VALUE_PARAMETER -> parameter = declarationsConverter.convertValueParameter(it, ValueParameterDeclaration.FOR_LOOP) LOOP_RANGE -> rangeExpression = getAsFirExpression(it, "No range in for loop") BODY -> blockNode = it } diff --git a/compiler/fir/raw-fir/light-tree2fir/tests-gen/org/jetbrains/kotlin/fir/lightTree/LightTree2FirConverterTestCaseGenerated.java b/compiler/fir/raw-fir/light-tree2fir/tests-gen/org/jetbrains/kotlin/fir/lightTree/LightTree2FirConverterTestCaseGenerated.java index e649fe53ce4..d31871bda2f 100644 --- a/compiler/fir/raw-fir/light-tree2fir/tests-gen/org/jetbrains/kotlin/fir/lightTree/LightTree2FirConverterTestCaseGenerated.java +++ b/compiler/fir/raw-fir/light-tree2fir/tests-gen/org/jetbrains/kotlin/fir/lightTree/LightTree2FirConverterTestCaseGenerated.java @@ -269,6 +269,59 @@ public class LightTree2FirConverterTestCaseGenerated extends AbstractLightTree2F } } } + + @TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class NoParameterType extends AbstractLightTree2FirConverterTestCase { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInNoParameterType() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + + @TestMetadata("noParameterTypRefInCatch.kt") + public void testNoParameterTypRefInCatch() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInCatch.kt"); + } + + @TestMetadata("noParameterTypRefInFuncionalType.kt") + public void testNoParameterTypRefInFuncionalType() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInFuncionalType.kt"); + } + + @TestMetadata("noParameterTypRefInFunction.kt") + public void testNoParameterTypRefInFunction() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInFunction.kt"); + } + + @TestMetadata("noParameterTypRefInLambda.kt") + public void testNoParameterTypRefInLambda() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInLambda.kt"); + } + + @TestMetadata("noParameterTypRefInPrimaryConstructor.kt") + public void testNoParameterTypRefInPrimaryConstructor() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInPrimaryConstructor.kt"); + } + + @TestMetadata("noParameterTypRefInPrimaryConsturctorVal.kt") + public void testNoParameterTypRefInPrimaryConsturctorVal() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInPrimaryConsturctorVal.kt"); + } + + @TestMetadata("noParameterTypRefInSecondaryConstructor.kt") + public void testNoParameterTypRefInSecondaryConstructor() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInSecondaryConstructor.kt"); + } + + @TestMetadata("noParameterTypRefInSetter.kt") + public void testNoParameterTypRefInSetter() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInSetter.kt"); + } + } } @TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions") diff --git a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt index 7a96c44bb17..03531ce90f1 100644 --- a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt +++ b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt @@ -179,7 +179,7 @@ open class RawFirBuilder( open fun convertValueParameter( valueParameter: KtParameter, defaultTypeRef: FirTypeRef? = null, - valueParameterDeclaration: ValueParameterDeclaration = ValueParameterDeclaration.OTHER, + valueParameterDeclaration: ValueParameterDeclaration, additionalAnnotations: List = emptyList() ): FirValueParameter = valueParameter.toFirValueParameter(defaultTypeRef, valueParameterDeclaration, additionalAnnotations) @@ -406,7 +406,7 @@ open class RawFirBuilder( annotations += accessorAnnotationsFromProperty this@RawFirBuilder.context.firFunctionTargets += accessorTarget extractValueParametersTo( - this, ValueParameterDeclaration.OTHER, propertyTypeRefToUse, parameterAnnotationsFromProperty + this, ValueParameterDeclaration.SETTER, propertyTypeRefToUse, parameterAnnotationsFromProperty ) if (!isGetter && valueParameters.isEmpty()) { valueParameters += buildDefaultSetterValueParameter { @@ -538,6 +538,7 @@ open class RawFirBuilder( returnTypeRef = when { typeReference != null -> typeReference.toFirOrErrorType() defaultTypeRef != null -> defaultTypeRef + valueParameterDeclaration.shouldExplicitParameterTypeBePresent -> createNoTypeForParameterTypeRef() else -> null.toFirOrImplicitType() } this.name = name @@ -568,7 +569,7 @@ open class RawFirBuilder( private fun KtParameter.toFirProperty(firParameter: FirValueParameter): FirProperty { require(hasValOrVar()) - val type = typeReference.toFirOrErrorType() + val type = typeReference.convertSafe() ?: createNoTypeForParameterTypeRef() val status = FirDeclarationStatusImpl(visibility, modality).apply { isExpect = hasExpectModifier() || this@RawFirBuilder.context.containerIsExpect isActual = hasActualModifier() @@ -1310,7 +1311,7 @@ open class RawFirBuilder( valueParameters += convertValueParameter( valueParameter, null, - if (isAnonymousFunction) ValueParameterDeclaration.LAMBDA else ValueParameterDeclaration.OTHER + if (isAnonymousFunction) ValueParameterDeclaration.LAMBDA else ValueParameterDeclaration.FUNCTION ) } val actualTypeParameters = if (this is FirSimpleFunctionBuilder) @@ -1485,7 +1486,7 @@ open class RawFirBuilder( this@RawFirBuilder.context.firFunctionTargets += target extractAnnotationsTo(this) typeParameters += constructorTypeParametersFromConstructedClass(ownerTypeParameters) - extractValueParametersTo(this, ValueParameterDeclaration.OTHER) + extractValueParametersTo(this, ValueParameterDeclaration.FUNCTION) val (body, _) = buildFirBody() @@ -1774,7 +1775,7 @@ open class RawFirBuilder( // TODO: probably implicit type should not be here returnTypeRef = unwrappedElement.returnTypeReference.toFirOrErrorType() for (valueParameter in unwrappedElement.parameters) { - valueParameters += valueParameter.convert() + valueParameters += convertValueParameter(valueParameter, valueParameterDeclaration = ValueParameterDeclaration.FUNCTIONAL_TYPE) } contextReceiverTypeRefs.addAll( @@ -1848,9 +1849,6 @@ open class RawFirBuilder( } } - override fun visitParameter(parameter: KtParameter, data: Unit): FirElement = - convertValueParameter(parameter) - override fun visitBlockExpression(expression: KtBlockExpression, data: Unit): FirElement { return configureBlockWithoutBuilding(expression).build() } diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInCatch.kt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInCatch.kt new file mode 100644 index 00000000000..2465999bbeb --- /dev/null +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInCatch.kt @@ -0,0 +1,5 @@ +fun foo() { + try { + + } catch(e) {} +} \ No newline at end of file diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInCatch.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInCatch.txt new file mode 100644 index 00000000000..66e251058c2 --- /dev/null +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInCatch.txt @@ -0,0 +1,8 @@ +FILE: noParameterTypRefInCatch.kt + public? final? fun foo(): R|kotlin/Unit| { + try { + } + catch (e: ) { + } + + } diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInFuncionalType.kt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInFuncionalType.kt new file mode 100644 index 00000000000..e7c739d1b41 --- /dev/null +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInFuncionalType.kt @@ -0,0 +1,3 @@ +fun x(p: (a) -> Int) { + +} \ No newline at end of file diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInFuncionalType.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInFuncionalType.txt new file mode 100644 index 00000000000..6d6ea487d2c --- /dev/null +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInFuncionalType.txt @@ -0,0 +1,3 @@ +FILE: noParameterTypRefInFuncionalType.kt + public? final? fun x(p: ( (a) -> Int )): R|kotlin/Unit| { + } diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInFunction.kt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInFunction.kt new file mode 100644 index 00000000000..addf477590e --- /dev/null +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInFunction.kt @@ -0,0 +1 @@ +fun foo(x) {} \ No newline at end of file diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInFunction.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInFunction.txt new file mode 100644 index 00000000000..34e1b73cb6c --- /dev/null +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInFunction.txt @@ -0,0 +1,3 @@ +FILE: noParameterTypRefInFunction.kt + public? final? fun foo(x: ): R|kotlin/Unit| { + } diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInLambda.kt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInLambda.kt new file mode 100644 index 00000000000..f58d3916656 --- /dev/null +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInLambda.kt @@ -0,0 +1,3 @@ +fun foo() { + 1.let { i -> i } +} \ No newline at end of file diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInLambda.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInLambda.txt new file mode 100644 index 00000000000..10b13e975d5 --- /dev/null +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInLambda.txt @@ -0,0 +1,7 @@ +FILE: noParameterTypRefInLambda.kt + public? final? fun foo(): R|kotlin/Unit| { + IntegerLiteral(1).let#( = let@fun .(i: ): { + i# + } + ) + } diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInPrimaryConstructor.kt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInPrimaryConstructor.kt new file mode 100644 index 00000000000..9ca7c16055e --- /dev/null +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInPrimaryConstructor.kt @@ -0,0 +1 @@ +class X(x) {} \ No newline at end of file diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInPrimaryConstructor.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInPrimaryConstructor.txt new file mode 100644 index 00000000000..54edeac5935 --- /dev/null +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInPrimaryConstructor.txt @@ -0,0 +1,7 @@ +FILE: noParameterTypRefInPrimaryConstructor.kt + public? final? class X : R|kotlin/Any| { + public? [ContainingClassKey=X] constructor(x: ): R|X| { + super() + } + + } diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInPrimaryConsturctorVal.kt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInPrimaryConsturctorVal.kt new file mode 100644 index 00000000000..d3398557418 --- /dev/null +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInPrimaryConsturctorVal.kt @@ -0,0 +1 @@ +class X(val x) {} \ No newline at end of file diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInPrimaryConsturctorVal.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInPrimaryConsturctorVal.txt new file mode 100644 index 00000000000..7be2339f957 --- /dev/null +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInPrimaryConsturctorVal.txt @@ -0,0 +1,10 @@ +FILE: noParameterTypRefInPrimaryConsturctorVal.kt + public? final? class X : R|kotlin/Any| { + public? [ContainingClassKey=X] constructor([CorrespondingProperty=/X.x] x: ): R|X| { + super() + } + + public? final? [IsFromPrimaryConstructor=true] val x: = R|/x| + public? [ContainingClassKey=X] get(): + + } diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInSecondaryConstructor.kt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInSecondaryConstructor.kt new file mode 100644 index 00000000000..8c5f0069c2c --- /dev/null +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInSecondaryConstructor.kt @@ -0,0 +1,3 @@ +class C { + constructor(x) {} +} \ No newline at end of file diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInSecondaryConstructor.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInSecondaryConstructor.txt new file mode 100644 index 00000000000..b5d778c4f21 --- /dev/null +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInSecondaryConstructor.txt @@ -0,0 +1,7 @@ +FILE: noParameterTypRefInSecondaryConstructor.kt + public? final? class C : R|kotlin/Any| { + public? [ContainingClassKey=C] constructor(x: ): R|C| { + super() + } + + } diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInSetter.kt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInSetter.kt new file mode 100644 index 00000000000..1dfe002c01b --- /dev/null +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInSetter.kt @@ -0,0 +1,2 @@ +var x: Int + set(value){} \ No newline at end of file diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInSetter.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInSetter.txt new file mode 100644 index 00000000000..83c0f8e67f8 --- /dev/null +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInSetter.txt @@ -0,0 +1,5 @@ +FILE: noParameterTypRefInSetter.kt + public? final? var x: Int + public? get(): Int + public? set(value: Int): R|kotlin/Unit| { + } diff --git a/compiler/fir/raw-fir/psi2fir/tests-gen/org/jetbrains/kotlin/fir/builder/RawFirBuilderLazyBodiesTestCaseGenerated.java b/compiler/fir/raw-fir/psi2fir/tests-gen/org/jetbrains/kotlin/fir/builder/RawFirBuilderLazyBodiesTestCaseGenerated.java index 9a3e391abad..5ac1b222ba3 100644 --- a/compiler/fir/raw-fir/psi2fir/tests-gen/org/jetbrains/kotlin/fir/builder/RawFirBuilderLazyBodiesTestCaseGenerated.java +++ b/compiler/fir/raw-fir/psi2fir/tests-gen/org/jetbrains/kotlin/fir/builder/RawFirBuilderLazyBodiesTestCaseGenerated.java @@ -269,6 +269,59 @@ public class RawFirBuilderLazyBodiesTestCaseGenerated extends AbstractRawFirBuil } } } + + @TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class NoParameterType extends AbstractRawFirBuilderLazyBodiesTestCase { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doRawFirTest, this, testDataFilePath); + } + + public void testAllFilesPresentInNoParameterType() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + + @TestMetadata("noParameterTypRefInCatch.kt") + public void testNoParameterTypRefInCatch() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInCatch.kt"); + } + + @TestMetadata("noParameterTypRefInFuncionalType.kt") + public void testNoParameterTypRefInFuncionalType() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInFuncionalType.kt"); + } + + @TestMetadata("noParameterTypRefInFunction.kt") + public void testNoParameterTypRefInFunction() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInFunction.kt"); + } + + @TestMetadata("noParameterTypRefInLambda.kt") + public void testNoParameterTypRefInLambda() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInLambda.kt"); + } + + @TestMetadata("noParameterTypRefInPrimaryConstructor.kt") + public void testNoParameterTypRefInPrimaryConstructor() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInPrimaryConstructor.kt"); + } + + @TestMetadata("noParameterTypRefInPrimaryConsturctorVal.kt") + public void testNoParameterTypRefInPrimaryConsturctorVal() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInPrimaryConsturctorVal.kt"); + } + + @TestMetadata("noParameterTypRefInSecondaryConstructor.kt") + public void testNoParameterTypRefInSecondaryConstructor() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInSecondaryConstructor.kt"); + } + + @TestMetadata("noParameterTypRefInSetter.kt") + public void testNoParameterTypRefInSetter() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInSetter.kt"); + } + } } @TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions") diff --git a/compiler/fir/raw-fir/psi2fir/tests-gen/org/jetbrains/kotlin/fir/builder/RawFirBuilderTestCaseGenerated.java b/compiler/fir/raw-fir/psi2fir/tests-gen/org/jetbrains/kotlin/fir/builder/RawFirBuilderTestCaseGenerated.java index 0af5e59bb1c..6dc6bfe2520 100644 --- a/compiler/fir/raw-fir/psi2fir/tests-gen/org/jetbrains/kotlin/fir/builder/RawFirBuilderTestCaseGenerated.java +++ b/compiler/fir/raw-fir/psi2fir/tests-gen/org/jetbrains/kotlin/fir/builder/RawFirBuilderTestCaseGenerated.java @@ -269,6 +269,59 @@ public class RawFirBuilderTestCaseGenerated extends AbstractRawFirBuilderTestCas } } } + + @TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class NoParameterType extends AbstractRawFirBuilderTestCase { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doRawFirTest, this, testDataFilePath); + } + + public void testAllFilesPresentInNoParameterType() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + + @TestMetadata("noParameterTypRefInCatch.kt") + public void testNoParameterTypRefInCatch() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInCatch.kt"); + } + + @TestMetadata("noParameterTypRefInFuncionalType.kt") + public void testNoParameterTypRefInFuncionalType() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInFuncionalType.kt"); + } + + @TestMetadata("noParameterTypRefInFunction.kt") + public void testNoParameterTypRefInFunction() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInFunction.kt"); + } + + @TestMetadata("noParameterTypRefInLambda.kt") + public void testNoParameterTypRefInLambda() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInLambda.kt"); + } + + @TestMetadata("noParameterTypRefInPrimaryConstructor.kt") + public void testNoParameterTypRefInPrimaryConstructor() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInPrimaryConstructor.kt"); + } + + @TestMetadata("noParameterTypRefInPrimaryConsturctorVal.kt") + public void testNoParameterTypRefInPrimaryConsturctorVal() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInPrimaryConsturctorVal.kt"); + } + + @TestMetadata("noParameterTypRefInSecondaryConstructor.kt") + public void testNoParameterTypRefInSecondaryConstructor() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInSecondaryConstructor.kt"); + } + + @TestMetadata("noParameterTypRefInSetter.kt") + public void testNoParameterTypRefInSetter() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInSetter.kt"); + } + } } @TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions") diff --git a/compiler/fir/raw-fir/raw-fir.common/src/org/jetbrains/kotlin/fir/builder/BaseFirBuilder.kt b/compiler/fir/raw-fir/raw-fir.common/src/org/jetbrains/kotlin/fir/builder/BaseFirBuilder.kt index 47e11c4e1c9..23d7c5659ef 100644 --- a/compiler/fir/raw-fir/raw-fir.common/src/org/jetbrains/kotlin/fir/builder/BaseFirBuilder.kt +++ b/compiler/fir/raw-fir/raw-fir.common/src/org/jetbrains/kotlin/fir/builder/BaseFirBuilder.kt @@ -28,8 +28,10 @@ import org.jetbrains.kotlin.fir.references.builder.* import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.types.ConeClassLikeType +import org.jetbrains.kotlin.fir.types.FirErrorTypeRef import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.builder.buildErrorTypeRef import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl @@ -39,7 +41,6 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.SpecialNames import org.jetbrains.kotlin.parsing.* -import org.jetbrains.kotlin.psi.KtObjectDeclaration import org.jetbrains.kotlin.psi.KtPsiUtil import org.jetbrains.kotlin.types.ConstantValueKind import org.jetbrains.kotlin.util.OperatorNameConventions @@ -1281,10 +1282,19 @@ abstract class BaseFirBuilder(val baseSession: FirSession, val context: Conte symbol = FirErrorPropertySymbol(diagnostic) } - enum class ValueParameterDeclaration { - OTHER, - LAMBDA, - CATCH, - PRIMARY_CONSTRUCTOR, + protected fun createNoTypeForParameterTypeRef(): FirErrorTypeRef { + return buildErrorTypeRef { + diagnostic = ConeSimpleDiagnostic("No type for parameter", DiagnosticKind.ValueParameterWithNoTypeAnnotation) + } + } + + enum class ValueParameterDeclaration(val shouldExplicitParameterTypeBePresent: Boolean) { + FUNCTION(shouldExplicitParameterTypeBePresent = true), + CATCH(shouldExplicitParameterTypeBePresent = true), + PRIMARY_CONSTRUCTOR(shouldExplicitParameterTypeBePresent = true), + FUNCTIONAL_TYPE(shouldExplicitParameterTypeBePresent = true), + SETTER(shouldExplicitParameterTypeBePresent = false), + LAMBDA(shouldExplicitParameterTypeBePresent = false), + FOR_LOOP(shouldExplicitParameterTypeBePresent = false), } } diff --git a/compiler/visualizer/tests-gen/org/jetbrains/kotlin/visualizer/fir/FirVisualizerForRawFirDataGenerated.java b/compiler/visualizer/tests-gen/org/jetbrains/kotlin/visualizer/fir/FirVisualizerForRawFirDataGenerated.java index 9bb63df4116..6a117f72c88 100644 --- a/compiler/visualizer/tests-gen/org/jetbrains/kotlin/visualizer/fir/FirVisualizerForRawFirDataGenerated.java +++ b/compiler/visualizer/tests-gen/org/jetbrains/kotlin/visualizer/fir/FirVisualizerForRawFirDataGenerated.java @@ -290,6 +290,64 @@ public class FirVisualizerForRawFirDataGenerated extends AbstractFirVisualizerTe } } } + + @Nested + @TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType") + @TestDataPath("$PROJECT_ROOT") + public class NoParameterType { + @Test + public void testAllFilesPresentInNoParameterType() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + + @Test + @TestMetadata("noParameterTypRefInCatch.kt") + public void testNoParameterTypRefInCatch() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInCatch.kt"); + } + + @Test + @TestMetadata("noParameterTypRefInFuncionalType.kt") + public void testNoParameterTypRefInFuncionalType() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInFuncionalType.kt"); + } + + @Test + @TestMetadata("noParameterTypRefInFunction.kt") + public void testNoParameterTypRefInFunction() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInFunction.kt"); + } + + @Test + @TestMetadata("noParameterTypRefInLambda.kt") + public void testNoParameterTypRefInLambda() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInLambda.kt"); + } + + @Test + @TestMetadata("noParameterTypRefInPrimaryConstructor.kt") + public void testNoParameterTypRefInPrimaryConstructor() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInPrimaryConstructor.kt"); + } + + @Test + @TestMetadata("noParameterTypRefInPrimaryConsturctorVal.kt") + public void testNoParameterTypRefInPrimaryConsturctorVal() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInPrimaryConsturctorVal.kt"); + } + + @Test + @TestMetadata("noParameterTypRefInSecondaryConstructor.kt") + public void testNoParameterTypRefInSecondaryConstructor() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInSecondaryConstructor.kt"); + } + + @Test + @TestMetadata("noParameterTypRefInSetter.kt") + public void testNoParameterTypRefInSetter() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInSetter.kt"); + } + } } @Nested diff --git a/compiler/visualizer/tests-gen/org/jetbrains/kotlin/visualizer/psi/PsiVisualizerForRawFirDataGenerated.java b/compiler/visualizer/tests-gen/org/jetbrains/kotlin/visualizer/psi/PsiVisualizerForRawFirDataGenerated.java index 02d82cd3fdc..31c18e1802f 100644 --- a/compiler/visualizer/tests-gen/org/jetbrains/kotlin/visualizer/psi/PsiVisualizerForRawFirDataGenerated.java +++ b/compiler/visualizer/tests-gen/org/jetbrains/kotlin/visualizer/psi/PsiVisualizerForRawFirDataGenerated.java @@ -290,6 +290,64 @@ public class PsiVisualizerForRawFirDataGenerated extends AbstractPsiVisualizerTe } } } + + @Nested + @TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType") + @TestDataPath("$PROJECT_ROOT") + public class NoParameterType { + @Test + public void testAllFilesPresentInNoParameterType() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + + @Test + @TestMetadata("noParameterTypRefInCatch.kt") + public void testNoParameterTypRefInCatch() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInCatch.kt"); + } + + @Test + @TestMetadata("noParameterTypRefInFuncionalType.kt") + public void testNoParameterTypRefInFuncionalType() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInFuncionalType.kt"); + } + + @Test + @TestMetadata("noParameterTypRefInFunction.kt") + public void testNoParameterTypRefInFunction() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInFunction.kt"); + } + + @Test + @TestMetadata("noParameterTypRefInLambda.kt") + public void testNoParameterTypRefInLambda() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInLambda.kt"); + } + + @Test + @TestMetadata("noParameterTypRefInPrimaryConstructor.kt") + public void testNoParameterTypRefInPrimaryConstructor() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInPrimaryConstructor.kt"); + } + + @Test + @TestMetadata("noParameterTypRefInPrimaryConsturctorVal.kt") + public void testNoParameterTypRefInPrimaryConsturctorVal() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInPrimaryConsturctorVal.kt"); + } + + @Test + @TestMetadata("noParameterTypRefInSecondaryConstructor.kt") + public void testNoParameterTypRefInSecondaryConstructor() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInSecondaryConstructor.kt"); + } + + @Test + @TestMetadata("noParameterTypRefInSetter.kt") + public void testNoParameterTypRefInSetter() throws Exception { + runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInSetter.kt"); + } + } } @Nested