diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerFirTestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerFirTestdataTestGenerated.java index 8e4672e2bed..8cbbb16a773 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerFirTestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerFirTestdataTestGenerated.java @@ -536,6 +536,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis runTest("compiler/fir/analysis-tests/testData/resolve/reifiedTypeOverload.kt"); } + @Test + @TestMetadata("returnFromDelegatedConstuctor.kt") + public void testReturnFromDelegatedConstuctor() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/returnFromDelegatedConstuctor.kt"); + } + @Test @TestMetadata("sealedClass.kt") public void testSealedClass() throws Exception { @@ -719,6 +725,18 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/annotations"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } + @Test + @TestMetadata("kt43936.kt") + public void testKt43936() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/annotations/kt43936.kt"); + } + + @Test + @TestMetadata("kt54478.kt") + public void testKt54478() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/annotations/kt54478.kt"); + } + @Test @TestMetadata("kt55286.kt") public void testKt55286() throws Exception { @@ -879,6 +897,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis runTest("compiler/fir/analysis-tests/testData/resolve/arguments/noParameterForName.kt"); } + @Test + @TestMetadata("nullForDifferentProjections.kt") + public void testNullForDifferentProjections() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/arguments/nullForDifferentProjections.kt"); + } + @Test @TestMetadata("operatorsOverLiterals.kt") public void testOperatorsOverLiterals() throws Exception { @@ -999,6 +1023,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/arraySetWithPlusAssign.kt"); } + @Test + @TestMetadata("chooseOverloadByShapeOfLambda.kt") + public void testChooseOverloadByShapeOfLambda() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/chooseOverloadByShapeOfLambda.kt"); + } + @Test @TestMetadata("companionInvoke.kt") public void testCompanionInvoke() throws Exception { @@ -1083,6 +1113,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/overloadsWithGenericAndGenericLambda.kt"); } + @Test + @TestMetadata("referenceToNestedClass.kt") + public void testReferenceToNestedClass() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/referenceToNestedClass.kt"); + } + @Test @TestMetadata("safeCallOnTypeAlias.kt") public void testSafeCallOnTypeAlias() throws Exception { @@ -1095,6 +1131,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/superAny.kt"); } + @Test + @TestMetadata("suspendCOnversionForReceiver.kt") + public void testSuspendCOnversionForReceiver() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/suspendCOnversionForReceiver.kt"); + } + @Test @TestMetadata("syntheticPropertiesWrongImplicitReceiver.kt") public void testSyntheticPropertiesWrongImplicitReceiver() throws Exception { @@ -1135,6 +1177,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis runTest("compiler/fir/analysis-tests/testData/resolve/cfa/initializationInTry.kt"); } + @Test + @TestMetadata("kt53819.kt") + public void testKt53819() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/cfa/kt53819.kt"); + } + @Test @TestMetadata("reassignOfNonLocalProperty_initializedProperties.kt") public void testReassignOfNonLocalProperty_initializedProperties() throws Exception { @@ -1265,6 +1313,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis runTest("compiler/fir/analysis-tests/testData/resolve/cfg/lambdaAsReturnOfLambda.kt"); } + @Test + @TestMetadata("lambdaInIfInTry.kt") + public void testLambdaInIfInTry() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/cfg/lambdaInIfInTry.kt"); + } + @Test @TestMetadata("lambdaReturningObject.kt") public void testLambdaReturningObject() throws Exception { @@ -1359,11 +1413,77 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/checkers"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } + @Test + @TestMetadata("complexConflictingProjections.kt") + public void testComplexConflictingProjections() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/complexConflictingProjections.kt"); + } + + @Test + @TestMetadata("importAnnotationWithRequiresOptIn.kt") + public void testImportAnnotationWithRequiresOptIn() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/importAnnotationWithRequiresOptIn.kt"); + } + + @Test + @TestMetadata("internalImplicitInvokeFromInlineFun.kt") + public void testInternalImplicitInvokeFromInlineFun() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/internalImplicitInvokeFromInlineFun.kt"); + } + + @Test + @TestMetadata("internalSuperCallFromInlineFun.kt") + public void testInternalSuperCallFromInlineFun() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/internalSuperCallFromInlineFun.kt"); + } + + @Test + @TestMetadata("invalidLhsOfClassLiteral.kt") + public void testInvalidLhsOfClassLiteral() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/invalidLhsOfClassLiteral.kt"); + } + + @Test + @TestMetadata("notUselessCast_1.kt") + public void testNotUselessCast_1() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/notUselessCast_1.kt"); + } + + @Test + @TestMetadata("notUselessCast_2.kt") + public void testNotUselessCast_2() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/notUselessCast_2.kt"); + } + + @Test + @TestMetadata("notUselessCast_3.kt") + public void testNotUselessCast_3() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/notUselessCast_3.kt"); + } + + @Test + @TestMetadata("recursiveDependencyBetweenReturnTypeAndSupertype.kt") + public void testRecursiveDependencyBetweenReturnTypeAndSupertype() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/recursiveDependencyBetweenReturnTypeAndSupertype.kt"); + } + @Test @TestMetadata("redundantNullCheckOnAsCast.kt") public void testRedundantNullCheckOnAsCast() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/checkers/redundantNullCheckOnAsCast.kt"); } + + @Test + @TestMetadata("unsuccessfullCastToStartProjectedType.kt") + public void testUnsuccessfullCastToStartProjectedType() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/unsuccessfullCastToStartProjectedType.kt"); + } + + @Test + @TestMetadata("uselessCastLeadsToRecursiveProblem.kt") + public void testUselessCastLeadsToRecursiveProblem() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/uselessCastLeadsToRecursiveProblem.kt"); + } } @Nested @@ -1443,6 +1563,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis runTest("compiler/fir/analysis-tests/testData/resolve/contracts/contractFromOtherModule_samePackage.kt"); } + @Test + @TestMetadata("contractOnInfixFunction.kt") + public void testContractOnInfixFunction() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/contracts/contractOnInfixFunction.kt"); + } + @Test @TestMetadata("disabledFeature.kt") public void testDisabledFeature() throws Exception { @@ -1454,6 +1580,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis public void testGenericContract() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/contracts/genericContract.kt"); } + + @Test + @TestMetadata("inPlaceAfterVararg.kt") + public void testInPlaceAfterVararg() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/contracts/inPlaceAfterVararg.kt"); + } } @Nested @@ -1910,6 +2042,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } + @Test + @TestMetadata("annotatedBranch.kt") + public void testAnnotatedBranch() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/annotatedBranch.kt"); + } + @Test @TestMetadata("exhaustiveWhenAndDNNType.kt") public void testExhaustiveWhenAndDNNType() throws Exception { @@ -1958,6 +2096,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/exhaustiveness_sealedSubClass.kt"); } + @Test + @TestMetadata("exhaustiveness_smartcastedBoolean.kt") + public void testExhaustiveness_smartcastedBoolean() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/exhaustiveness_smartcastedBoolean.kt"); + } + @Test @TestMetadata("nestedIfInLambda.kt") public void testNestedIfInLambda() throws Exception { @@ -1969,6 +2113,18 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis public void testNonExhaustiveWhenWithCoercionToUnit() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/nonExhaustiveWhenWithCoercionToUnit.kt"); } + + @Test + @TestMetadata("sameBranchMultipleConditions.kt") + public void testSameBranchMultipleConditions() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/sameBranchMultipleConditions.kt"); + } + + @Test + @TestMetadata("smartcastToExhaustiveInterface.kt") + public void testSmartcastToExhaustiveInterface() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/smartcastToExhaustiveInterface.kt"); + } } } @@ -3117,6 +3273,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis runTest("compiler/fir/analysis-tests/testData/resolve/inference/intersectionTypesInConstraints.kt"); } + @Test + @TestMetadata("javaCollector.kt") + public void testJavaCollector() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/inference/javaCollector.kt"); + } + @Test @TestMetadata("kt40131.kt") public void testKt40131() throws Exception { @@ -3129,6 +3291,24 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis runTest("compiler/fir/analysis-tests/testData/resolve/inference/kt41989.kt"); } + @Test + @TestMetadata("kt53494.kt") + public void testKt53494() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/inference/kt53494.kt"); + } + + @Test + @TestMetadata("kt54990.kt") + public void testKt54990() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/inference/kt54990.kt"); + } + + @Test + @TestMetadata("kt55555.kt") + public void testKt55555() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/inference/kt55555.kt"); + } + @Test @TestMetadata("lambdaAsReturnStatementOfLambda.kt") public void testLambdaAsReturnStatementOfLambda() throws Exception { @@ -3183,6 +3363,18 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis runTest("compiler/fir/analysis-tests/testData/resolve/inference/receiverWithCapturedType.kt"); } + @Test + @TestMetadata("recursiveSelfTypes.kt") + public void testRecursiveSelfTypes() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/inference/recursiveSelfTypes.kt"); + } + + @Test + @TestMetadata("selfTypeFromJava.kt") + public void testSelfTypeFromJava() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/inference/selfTypeFromJava.kt"); + } + @Test @TestMetadata("simpleCapturedTypes.kt") public void testSimpleCapturedTypes() throws Exception { @@ -3200,6 +3392,22 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis public void testUnitUpperBound() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/inference/unitUpperBound.kt"); } + + @Nested + @TestMetadata("compiler/fir/analysis-tests/testData/resolve/inference/builderInference") + @TestDataPath("$PROJECT_ROOT") + public class BuilderInference { + @Test + public void testAllFilesPresentInBuilderInference() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/inference/builderInference"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @Test + @TestMetadata("ifInBuildMap.kt") + public void testIfInBuildMap() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/inference/builderInference/ifInBuildMap.kt"); + } + } } @Nested @@ -3459,6 +3667,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/problems"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } + @Test + @TestMetadata("classLiteralWithExclExcl.kt") + public void testClassLiteralWithExclExcl() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/problems/classLiteralWithExclExcl.kt"); + } + @Test @TestMetadata("compilerPhase.kt") public void testCompilerPhase() throws Exception { @@ -3537,6 +3751,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis runTest("compiler/fir/analysis-tests/testData/resolve/problems/innerClassHierarchy.kt"); } + @Test + @TestMetadata("invalidCode.kt") + public void testInvalidCode() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/problems/invalidCode.kt"); + } + @Test @TestMetadata("javaClassWithEmptyAnnotationName.kt") public void testJavaClassWithEmptyAnnotationName() throws Exception { @@ -3602,6 +3822,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis public void testTransform() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/problems/transform.kt"); } + + @Test + @TestMetadata("typeArgumentsOnThis.kt") + public void testTypeArgumentsOnThis() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/problems/typeArgumentsOnThis.kt"); + } } @Nested @@ -3613,6 +3839,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/properties"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } + @Test + @TestMetadata("assignToStarProjectedType.kt") + public void testAssignToStarProjectedType() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/properties/assignToStarProjectedType.kt"); + } + @Test @TestMetadata("getterWithEarlyReturn.kt") public void testGetterWithEarlyReturn() throws Exception { @@ -3705,6 +3937,18 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/references"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } + @Test + @TestMetadata("ambigousParenthesizedReference.kt") + public void testAmbigousParenthesizedReference() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/references/ambigousParenthesizedReference.kt"); + } + + @Test + @TestMetadata("incorrectReferenceOnInnerClassMember.kt") + public void testIncorrectReferenceOnInnerClassMember() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/references/incorrectReferenceOnInnerClassMember.kt"); + } + @Test @TestMetadata("integerLiteralInLhs.kt") public void testIntegerLiteralInLhs() throws Exception { @@ -3729,6 +3973,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis runTest("compiler/fir/analysis-tests/testData/resolve/references/referenceToField.kt"); } + @Test + @TestMetadata("referenceToSyntheticJavaPropertyWithProjection.kt") + public void testReferenceToSyntheticJavaPropertyWithProjection() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/references/referenceToSyntheticJavaPropertyWithProjection.kt"); + } + @Test @TestMetadata("simple.kt") public void testSimple() throws Exception { @@ -3740,6 +3990,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis public void testSuperMember() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/references/superMember.kt"); } + + @Test + @TestMetadata("unresovledReferenceInFinally.kt") + public void testUnresovledReferenceInFinally() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/references/unresovledReferenceInFinally.kt"); + } } @Nested @@ -3821,6 +4077,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis runTest("compiler/fir/analysis-tests/testData/resolve/samConversions/notSamBecauseOfSupertype.kt"); } + @Test + @TestMetadata("nothingVararg.kt") + public void testNothingVararg() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/samConversions/nothingVararg.kt"); + } + @Test @TestMetadata("runnable.kt") public void testRunnable() throws Exception { @@ -3979,6 +4241,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/casts.kt"); } + @Test + @TestMetadata("contractSafeCall.kt") + public void testContractSafeCall() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/contractSafeCall.kt"); + } + @Test @TestMetadata("equalsAndIdentity.kt") public void testEqualsAndIdentity() throws Exception { @@ -4063,6 +4331,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastInByClause.kt"); } + @Test + @TestMetadata("smartcastOnFunctionalType.kt") + public void testSmartcastOnFunctionalType() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastOnFunctionalType.kt"); + } + @Test @TestMetadata("smartcastOnImplicitReceiverOfCallableReference.kt") public void testSmartcastOnImplicitReceiverOfCallableReference() throws Exception { @@ -4075,6 +4349,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToNothing.kt"); } + @Test + @TestMetadata("smartcastToStarProjectedType.kt") + public void testSmartcastToStarProjectedType() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToStarProjectedType.kt"); + } + @Test @TestMetadata("smartcastToTypeParameter.kt") public void testSmartcastToTypeParameter() throws Exception { @@ -4093,12 +4373,24 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastsFromEquals_sameModule.kt"); } + @Test + @TestMetadata("typeOfLambdaWithSmartcast.kt") + public void testTypeOfLambdaWithSmartcast() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/typeOfLambdaWithSmartcast.kt"); + } + @Test @TestMetadata("unstableSmartcastAndAmbiguity.kt") public void testUnstableSmartcastAndAmbiguity() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/unstableSmartcastAndAmbiguity.kt"); } + @Test + @TestMetadata("valCapturedInLambda.kt") + public void testValCapturedInLambda() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/valCapturedInLambda.kt"); + } + @Nested @TestMetadata("compiler/fir/analysis-tests/testData/resolve/smartcasts/booleans") @TestDataPath("$PROJECT_ROOT") @@ -4142,6 +4434,18 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } + @Test + @TestMetadata("assignToBoundSmartcastedVariable.kt") + public void testAssignToBoundSmartcastedVariable() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/assignToBoundSmartcastedVariable.kt"); + } + + @Test + @TestMetadata("boundSmartcastWithProjection.kt") + public void testBoundSmartcastWithProjection() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/boundSmartcastWithProjection.kt"); + } + @Test @TestMetadata("boundSmartcasts.kt") public void testBoundSmartcasts() throws Exception { @@ -4176,12 +4480,24 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } + @Test + @TestMetadata("earlyReturnInNonExhaustiveWhen.kt") + public void testEarlyReturnInNonExhaustiveWhen() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures/earlyReturnInNonExhaustiveWhen.kt"); + } + @Test @TestMetadata("elvis.kt") public void testElvis() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures/elvis.kt"); } + @Test + @TestMetadata("returnFromWhen.kt") + public void testReturnFromWhen() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures/returnFromWhen.kt"); + } + @Test @TestMetadata("returns.kt") public void testReturns() throws Exception { @@ -4256,6 +4572,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/loops/dataFlowInfoFromWhileCondition.kt"); } + @Test + @TestMetadata("elvisAtTheEndOfLoop.kt") + public void testElvisAtTheEndOfLoop() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/loops/elvisAtTheEndOfLoop.kt"); + } + @Test @TestMetadata("endlessLoops.kt") public void testEndlessLoops() throws Exception { @@ -4277,6 +4599,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis public void testInvoke() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/problems/invoke.kt"); } + + @Test + @TestMetadata("noSmartcastToNullableNothing.kt") + public void testNoSmartcastToNullableNothing() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/problems/noSmartcastToNullableNothing.kt"); + } } @Nested @@ -4476,6 +4804,28 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis } } + @Nested + @TestMetadata("compiler/fir/analysis-tests/testData/resolve/typeParameters") + @TestDataPath("$PROJECT_ROOT") + public class TypeParameters { + @Test + public void testAllFilesPresentInTypeParameters() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/typeParameters"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @Test + @TestMetadata("kt38288.kt") + public void testKt38288() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/typeParameters/kt38288.kt"); + } + + @Test + @TestMetadata("starProjectionForMultipleBounds.kt") + public void testStarProjectionForMultipleBounds() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/typeParameters/starProjectionForMultipleBounds.kt"); + } + } + @Nested @TestMetadata("compiler/fir/analysis-tests/testData/resolve/types") @TestDataPath("$PROJECT_ROOT") @@ -4631,6 +4981,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis runTest("compiler/fir/analysis-tests/testData/resolve/visibility/privateAliasInSamePackage.kt"); } + @Test + @TestMetadata("protectedAnnotationClassFromJava.kt") + public void testProtectedAnnotationClassFromJava() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/visibility/protectedAnnotationClassFromJava.kt"); + } + @Test @TestMetadata("protectedInCompanion.kt") public void testProtectedInCompanion() throws Exception { diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java index fab12e47397..e3df9dd7a7e 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java @@ -12194,6 +12194,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag runTest("compiler/testData/diagnostics/tests/generics/anonymousObjectSupertypeWithTypeParameterFromFunction.kt"); } + @Test + @TestMetadata("approximationOfInProjection.kt") + public void testApproximationOfInProjection() throws Exception { + runTest("compiler/testData/diagnostics/tests/generics/approximationOfInProjection.kt"); + } + @Test @TestMetadata("argumentsForT.kt") public void testArgumentsForT() throws Exception { diff --git a/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java b/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java index ee45108f547..078002824cf 100644 --- a/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java +++ b/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java @@ -454,6 +454,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract runTest("compiler/fir/analysis-tests/testData/resolve/reifiedTypeOverload.kt"); } + @TestMetadata("returnFromDelegatedConstuctor.kt") + public void testReturnFromDelegatedConstuctor() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/returnFromDelegatedConstuctor.kt"); + } + @TestMetadata("sealedClass.kt") public void testSealedClass() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/sealedClass.kt"); @@ -611,6 +616,16 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/annotations"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } + @TestMetadata("kt43936.kt") + public void testKt43936() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/annotations/kt43936.kt"); + } + + @TestMetadata("kt54478.kt") + public void testKt54478() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/annotations/kt54478.kt"); + } + @TestMetadata("kt55286.kt") public void testKt55286() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/annotations/kt55286.kt"); @@ -749,6 +764,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract runTest("compiler/fir/analysis-tests/testData/resolve/arguments/noParameterForName.kt"); } + @TestMetadata("nullForDifferentProjections.kt") + public void testNullForDifferentProjections() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/arguments/nullForDifferentProjections.kt"); + } + @TestMetadata("operatorsOverLiterals.kt") public void testOperatorsOverLiterals() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/arguments/operatorsOverLiterals.kt"); @@ -863,6 +883,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/arraySetWithPlusAssign.kt"); } + @TestMetadata("chooseOverloadByShapeOfLambda.kt") + public void testChooseOverloadByShapeOfLambda() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/chooseOverloadByShapeOfLambda.kt"); + } + @TestMetadata("companionInvoke.kt") public void testCompanionInvoke() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/companionInvoke.kt"); @@ -933,6 +958,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/overloadsWithGenericAndGenericLambda.kt"); } + @TestMetadata("referenceToNestedClass.kt") + public void testReferenceToNestedClass() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/referenceToNestedClass.kt"); + } + @TestMetadata("safeCallOnTypeAlias.kt") public void testSafeCallOnTypeAlias() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/safeCallOnTypeAlias.kt"); @@ -943,6 +973,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/superAny.kt"); } + @TestMetadata("suspendCOnversionForReceiver.kt") + public void testSuspendCOnversionForReceiver() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/suspendCOnversionForReceiver.kt"); + } + @TestMetadata("syntheticPropertiesWrongImplicitReceiver.kt") public void testSyntheticPropertiesWrongImplicitReceiver() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/syntheticPropertiesWrongImplicitReceiver.kt"); @@ -981,6 +1016,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract runTest("compiler/fir/analysis-tests/testData/resolve/cfa/initializationInTry.kt"); } + @TestMetadata("kt53819.kt") + public void testKt53819() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/cfa/kt53819.kt"); + } + @TestMetadata("reassignOfNonLocalProperty_initializedProperties.kt") public void testReassignOfNonLocalProperty_initializedProperties() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/cfa/reassignOfNonLocalProperty_initializedProperties.kt"); @@ -1094,6 +1134,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract runTest("compiler/fir/analysis-tests/testData/resolve/cfg/lambdaAsReturnOfLambda.kt"); } + @TestMetadata("lambdaInIfInTry.kt") + public void testLambdaInIfInTry() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/cfg/lambdaInIfInTry.kt"); + } + @TestMetadata("lambdaReturningObject.kt") public void testLambdaReturningObject() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/cfg/lambdaReturningObject.kt"); @@ -1177,10 +1222,65 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/checkers"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } + @TestMetadata("complexConflictingProjections.kt") + public void testComplexConflictingProjections() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/complexConflictingProjections.kt"); + } + + @TestMetadata("importAnnotationWithRequiresOptIn.kt") + public void testImportAnnotationWithRequiresOptIn() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/importAnnotationWithRequiresOptIn.kt"); + } + + @TestMetadata("internalImplicitInvokeFromInlineFun.kt") + public void testInternalImplicitInvokeFromInlineFun() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/internalImplicitInvokeFromInlineFun.kt"); + } + + @TestMetadata("internalSuperCallFromInlineFun.kt") + public void testInternalSuperCallFromInlineFun() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/internalSuperCallFromInlineFun.kt"); + } + + @TestMetadata("invalidLhsOfClassLiteral.kt") + public void testInvalidLhsOfClassLiteral() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/invalidLhsOfClassLiteral.kt"); + } + + @TestMetadata("notUselessCast_1.kt") + public void testNotUselessCast_1() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/notUselessCast_1.kt"); + } + + @TestMetadata("notUselessCast_2.kt") + public void testNotUselessCast_2() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/notUselessCast_2.kt"); + } + + @TestMetadata("notUselessCast_3.kt") + public void testNotUselessCast_3() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/notUselessCast_3.kt"); + } + + @TestMetadata("recursiveDependencyBetweenReturnTypeAndSupertype.kt") + public void testRecursiveDependencyBetweenReturnTypeAndSupertype() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/recursiveDependencyBetweenReturnTypeAndSupertype.kt"); + } + @TestMetadata("redundantNullCheckOnAsCast.kt") public void testRedundantNullCheckOnAsCast() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/checkers/redundantNullCheckOnAsCast.kt"); } + + @TestMetadata("unsuccessfullCastToStartProjectedType.kt") + public void testUnsuccessfullCastToStartProjectedType() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/unsuccessfullCastToStartProjectedType.kt"); + } + + @TestMetadata("uselessCastLeadsToRecursiveProblem.kt") + public void testUselessCastLeadsToRecursiveProblem() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/uselessCastLeadsToRecursiveProblem.kt"); + } } @TestMetadata("compiler/fir/analysis-tests/testData/resolve/constVal") @@ -1261,6 +1361,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract runTest("compiler/fir/analysis-tests/testData/resolve/contracts/contractFromOtherModule_samePackage.kt"); } + @TestMetadata("contractOnInfixFunction.kt") + public void testContractOnInfixFunction() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/contracts/contractOnInfixFunction.kt"); + } + @TestMetadata("disabledFeature.kt") public void testDisabledFeature() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/contracts/disabledFeature.kt"); @@ -1270,6 +1375,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract public void testGenericContract() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/contracts/genericContract.kt"); } + + @TestMetadata("inPlaceAfterVararg.kt") + public void testInPlaceAfterVararg() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/contracts/inPlaceAfterVararg.kt"); + } } @TestMetadata("compiler/fir/analysis-tests/testData/resolve/delegates") @@ -1678,6 +1788,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } + @TestMetadata("annotatedBranch.kt") + public void testAnnotatedBranch() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/annotatedBranch.kt"); + } + @TestMetadata("exhaustiveWhenAndDNNType.kt") public void testExhaustiveWhenAndDNNType() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/exhaustiveWhenAndDNNType.kt"); @@ -1718,6 +1833,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/exhaustiveness_sealedSubClass.kt"); } + @TestMetadata("exhaustiveness_smartcastedBoolean.kt") + public void testExhaustiveness_smartcastedBoolean() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/exhaustiveness_smartcastedBoolean.kt"); + } + @TestMetadata("nestedIfInLambda.kt") public void testNestedIfInLambda() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/nestedIfInLambda.kt"); @@ -1727,6 +1847,16 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract public void testNonExhaustiveWhenWithCoercionToUnit() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/nonExhaustiveWhenWithCoercionToUnit.kt"); } + + @TestMetadata("sameBranchMultipleConditions.kt") + public void testSameBranchMultipleConditions() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/sameBranchMultipleConditions.kt"); + } + + @TestMetadata("smartcastToExhaustiveInterface.kt") + public void testSmartcastToExhaustiveInterface() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/smartcastToExhaustiveInterface.kt"); + } } } @@ -2740,6 +2870,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract runTest("compiler/fir/analysis-tests/testData/resolve/inference/intersectionTypesInConstraints.kt"); } + @TestMetadata("javaCollector.kt") + public void testJavaCollector() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/inference/javaCollector.kt"); + } + @TestMetadata("kt40131.kt") public void testKt40131() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/inference/kt40131.kt"); @@ -2750,6 +2885,21 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract runTest("compiler/fir/analysis-tests/testData/resolve/inference/kt41989.kt"); } + @TestMetadata("kt53494.kt") + public void testKt53494() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/inference/kt53494.kt"); + } + + @TestMetadata("kt54990.kt") + public void testKt54990() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/inference/kt54990.kt"); + } + + @TestMetadata("kt55555.kt") + public void testKt55555() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/inference/kt55555.kt"); + } + @TestMetadata("lambdaAsReturnStatementOfLambda.kt") public void testLambdaAsReturnStatementOfLambda() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/inference/lambdaAsReturnStatementOfLambda.kt"); @@ -2795,6 +2945,16 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract runTest("compiler/fir/analysis-tests/testData/resolve/inference/receiverWithCapturedType.kt"); } + @TestMetadata("recursiveSelfTypes.kt") + public void testRecursiveSelfTypes() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/inference/recursiveSelfTypes.kt"); + } + + @TestMetadata("selfTypeFromJava.kt") + public void testSelfTypeFromJava() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/inference/selfTypeFromJava.kt"); + } + @TestMetadata("simpleCapturedTypes.kt") public void testSimpleCapturedTypes() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/inference/simpleCapturedTypes.kt"); @@ -2809,6 +2969,24 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract public void testUnitUpperBound() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/inference/unitUpperBound.kt"); } + + @TestMetadata("compiler/fir/analysis-tests/testData/resolve/inference/builderInference") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class BuilderInference extends AbstractLazyBodyIsNotTouchedTilContractsPhaseTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInBuilderInference() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/inference/builderInference"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("ifInBuildMap.kt") + public void testIfInBuildMap() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/inference/builderInference/ifInBuildMap.kt"); + } + } } @TestMetadata("compiler/fir/analysis-tests/testData/resolve/inlineClasses") @@ -3053,6 +3231,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/problems"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } + @TestMetadata("classLiteralWithExclExcl.kt") + public void testClassLiteralWithExclExcl() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/problems/classLiteralWithExclExcl.kt"); + } + @TestMetadata("compilerPhase.kt") public void testCompilerPhase() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/problems/compilerPhase.kt"); @@ -3118,6 +3301,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract runTest("compiler/fir/analysis-tests/testData/resolve/problems/innerClassHierarchy.kt"); } + @TestMetadata("invalidCode.kt") + public void testInvalidCode() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/problems/invalidCode.kt"); + } + @TestMetadata("javaClassWithEmptyAnnotationName.kt") public void testJavaClassWithEmptyAnnotationName() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/problems/javaClassWithEmptyAnnotationName.kt"); @@ -3172,6 +3360,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract public void testTransform() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/problems/transform.kt"); } + + @TestMetadata("typeArgumentsOnThis.kt") + public void testTypeArgumentsOnThis() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/problems/typeArgumentsOnThis.kt"); + } } @TestMetadata("compiler/fir/analysis-tests/testData/resolve/properties") @@ -3186,6 +3379,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/properties"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } + @TestMetadata("assignToStarProjectedType.kt") + public void testAssignToStarProjectedType() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/properties/assignToStarProjectedType.kt"); + } + @TestMetadata("getterWithEarlyReturn.kt") public void testGetterWithEarlyReturn() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/properties/getterWithEarlyReturn.kt"); @@ -3272,6 +3470,16 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/references"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } + @TestMetadata("ambigousParenthesizedReference.kt") + public void testAmbigousParenthesizedReference() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/references/ambigousParenthesizedReference.kt"); + } + + @TestMetadata("incorrectReferenceOnInnerClassMember.kt") + public void testIncorrectReferenceOnInnerClassMember() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/references/incorrectReferenceOnInnerClassMember.kt"); + } + @TestMetadata("integerLiteralInLhs.kt") public void testIntegerLiteralInLhs() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/references/integerLiteralInLhs.kt"); @@ -3292,6 +3500,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract runTest("compiler/fir/analysis-tests/testData/resolve/references/referenceToField.kt"); } + @TestMetadata("referenceToSyntheticJavaPropertyWithProjection.kt") + public void testReferenceToSyntheticJavaPropertyWithProjection() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/references/referenceToSyntheticJavaPropertyWithProjection.kt"); + } + @TestMetadata("simple.kt") public void testSimple() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/references/simple.kt"); @@ -3301,6 +3514,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract public void testSuperMember() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/references/superMember.kt"); } + + @TestMetadata("unresovledReferenceInFinally.kt") + public void testUnresovledReferenceInFinally() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/references/unresovledReferenceInFinally.kt"); + } } @TestMetadata("compiler/fir/analysis-tests/testData/resolve/samConstructors") @@ -3378,6 +3596,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract runTest("compiler/fir/analysis-tests/testData/resolve/samConversions/notSamBecauseOfSupertype.kt"); } + @TestMetadata("nothingVararg.kt") + public void testNothingVararg() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/samConversions/nothingVararg.kt"); + } + @TestMetadata("runnable.kt") public void testRunnable() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/samConversions/runnable.kt"); @@ -3519,6 +3742,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/casts.kt"); } + @TestMetadata("contractSafeCall.kt") + public void testContractSafeCall() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/contractSafeCall.kt"); + } + @TestMetadata("equalsAndIdentity.kt") public void testEqualsAndIdentity() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/equalsAndIdentity.kt"); @@ -3589,6 +3817,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastInByClause.kt"); } + @TestMetadata("smartcastOnFunctionalType.kt") + public void testSmartcastOnFunctionalType() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastOnFunctionalType.kt"); + } + @TestMetadata("smartcastOnImplicitReceiverOfCallableReference.kt") public void testSmartcastOnImplicitReceiverOfCallableReference() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastOnImplicitReceiverOfCallableReference.kt"); @@ -3599,6 +3832,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToNothing.kt"); } + @TestMetadata("smartcastToStarProjectedType.kt") + public void testSmartcastToStarProjectedType() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToStarProjectedType.kt"); + } + @TestMetadata("smartcastToTypeParameter.kt") public void testSmartcastToTypeParameter() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToTypeParameter.kt"); @@ -3614,11 +3852,21 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastsFromEquals_sameModule.kt"); } + @TestMetadata("typeOfLambdaWithSmartcast.kt") + public void testTypeOfLambdaWithSmartcast() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/typeOfLambdaWithSmartcast.kt"); + } + @TestMetadata("unstableSmartcastAndAmbiguity.kt") public void testUnstableSmartcastAndAmbiguity() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/unstableSmartcastAndAmbiguity.kt"); } + @TestMetadata("valCapturedInLambda.kt") + public void testValCapturedInLambda() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/valCapturedInLambda.kt"); + } + @TestMetadata("compiler/fir/analysis-tests/testData/resolve/smartcasts/booleans") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -3664,6 +3912,16 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } + @TestMetadata("assignToBoundSmartcastedVariable.kt") + public void testAssignToBoundSmartcastedVariable() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/assignToBoundSmartcastedVariable.kt"); + } + + @TestMetadata("boundSmartcastWithProjection.kt") + public void testBoundSmartcastWithProjection() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/boundSmartcastWithProjection.kt"); + } + @TestMetadata("boundSmartcasts.kt") public void testBoundSmartcasts() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/boundSmartcasts.kt"); @@ -3697,11 +3955,21 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } + @TestMetadata("earlyReturnInNonExhaustiveWhen.kt") + public void testEarlyReturnInNonExhaustiveWhen() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures/earlyReturnInNonExhaustiveWhen.kt"); + } + @TestMetadata("elvis.kt") public void testElvis() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures/elvis.kt"); } + @TestMetadata("returnFromWhen.kt") + public void testReturnFromWhen() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures/returnFromWhen.kt"); + } + @TestMetadata("returns.kt") public void testReturns() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures/returns.kt"); @@ -3773,6 +4041,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/loops/dataFlowInfoFromWhileCondition.kt"); } + @TestMetadata("elvisAtTheEndOfLoop.kt") + public void testElvisAtTheEndOfLoop() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/loops/elvisAtTheEndOfLoop.kt"); + } + @TestMetadata("endlessLoops.kt") public void testEndlessLoops() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/loops/endlessLoops.kt"); @@ -3795,6 +4068,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract public void testInvoke() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/problems/invoke.kt"); } + + @TestMetadata("noSmartcastToNullableNothing.kt") + public void testNoSmartcastToNullableNothing() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/problems/noSmartcastToNullableNothing.kt"); + } } @TestMetadata("compiler/fir/analysis-tests/testData/resolve/smartcasts/receivers") @@ -3994,6 +4272,29 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract } } + @TestMetadata("compiler/fir/analysis-tests/testData/resolve/typeParameters") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TypeParameters extends AbstractLazyBodyIsNotTouchedTilContractsPhaseTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInTypeParameters() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/typeParameters"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("kt38288.kt") + public void testKt38288() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/typeParameters/kt38288.kt"); + } + + @TestMetadata("starProjectionForMultipleBounds.kt") + public void testStarProjectionForMultipleBounds() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/typeParameters/starProjectionForMultipleBounds.kt"); + } + } + @TestMetadata("compiler/fir/analysis-tests/testData/resolve/types") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -4137,6 +4438,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract runTest("compiler/fir/analysis-tests/testData/resolve/visibility/privateAliasInSamePackage.kt"); } + @TestMetadata("protectedAnnotationClassFromJava.kt") + public void testProtectedAnnotationClassFromJava() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/visibility/protectedAnnotationClassFromJava.kt"); + } + @TestMetadata("protectedInCompanion.kt") public void testProtectedInCompanion() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/visibility/protectedInCompanion.kt"); diff --git a/compiler/fir/analysis-tests/testData/resolve/annotations/kt43936.fir.txt b/compiler/fir/analysis-tests/testData/resolve/annotations/kt43936.fir.txt new file mode 100644 index 00000000000..c17543e6e3e --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/annotations/kt43936.fir.txt @@ -0,0 +1,22 @@ +FILE: kt43936.kt + public abstract interface Operation : R|kotlin/Any| { + } + public final class FooOperation : R|Operation| { + public constructor(foo: R|kotlin/String|): R|FooOperation| { + super() + } + + public final val foo: R|kotlin/String| = R|/foo| + public get(): R|kotlin/String| + + @R|kotlin/Suppress|(names = vararg(String(test))) public final class Boom : R|kotlin/Any| { + public constructor(bar: R|kotlin/String|): R|FooOperation.Boom| { + super() + } + + public final val bar: R|kotlin/String| = R|/bar| + public get(): R|kotlin/String| + + } + + } diff --git a/compiler/fir/analysis-tests/testData/resolve/annotations/kt43936.kt b/compiler/fir/analysis-tests/testData/resolve/annotations/kt43936.kt new file mode 100644 index 00000000000..bc6e558f5bc --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/annotations/kt43936.kt @@ -0,0 +1,12 @@ +// ISSUE: KT-43936 +// WITH_STDLIB + +import FooOperation.* + +interface Operation + +class FooOperation(val foo: String) : Operation { + + @Suppress("test") + class Boom(val bar: String) +} diff --git a/compiler/fir/analysis-tests/testData/resolve/annotations/kt54478.fir.txt b/compiler/fir/analysis-tests/testData/resolve/annotations/kt54478.fir.txt new file mode 100644 index 00000000000..17ac1cec85a --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/annotations/kt54478.fir.txt @@ -0,0 +1,6 @@ +FILE: kt54478.kt + @FILE:R|kotlin/Suppress|(names = vararg(String(INVISIBLE_REFERENCE), String(INVISIBLE_MEMBER))) + public final fun test(block: R|kotlin/Any.() -> T|): R|kotlin/Unit| { + } + public final fun test(block: R|@NoInfer T|): R|kotlin/Unit| { + } diff --git a/compiler/fir/analysis-tests/testData/resolve/annotations/kt54478.kt b/compiler/fir/analysis-tests/testData/resolve/annotations/kt54478.kt new file mode 100644 index 00000000000..cb4d372c653 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/annotations/kt54478.kt @@ -0,0 +1,8 @@ +// ISSUE: KT-54478 + +@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") + +import kotlin.internal.NoInfer + +fun test(block: Any.() -> T) {} +fun test(block: @NoInfer T) {} diff --git a/compiler/fir/analysis-tests/testData/resolve/arguments/nullForDifferentProjections.fir.txt b/compiler/fir/analysis-tests/testData/resolve/arguments/nullForDifferentProjections.fir.txt new file mode 100644 index 00000000000..064fb29f2c8 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/arguments/nullForDifferentProjections.fir.txt @@ -0,0 +1,23 @@ +FILE: nullForDifferentProjections.kt + public abstract interface SomeFace : R|kotlin/Any| { + } + public final class SomeGene : R|kotlin/Any| { + public constructor(): R|SomeGene| { + super() + } + + public final fun setFace(face: R|SomeFace?|): R|kotlin/Unit| { + } + + public final fun setString(string: R|kotlin/String?|): R|kotlin/Unit| { + } + + } + public final fun nullTypeArg(invP: R|SomeGene|, inP: R|SomeGene|, outP: R|SomeGene|): R|kotlin/Unit| { + R|/invP|.R|SubstitutionOverride|(Null(null)) + R|/invP|.R|SubstitutionOverride|(Null(null)) + R|/inP|.R|SubstitutionOverride|(Null(null)) + R|/inP|.R|SubstitutionOverride|(Null(null)) + R|/outP|.R|SubstitutionOverride|(Null(null)) + R|/outP|.R|SubstitutionOverride|(Null(null)) + } diff --git a/compiler/fir/analysis-tests/testData/resolve/arguments/nullForDifferentProjections.kt b/compiler/fir/analysis-tests/testData/resolve/arguments/nullForDifferentProjections.kt new file mode 100644 index 00000000000..d3afda2362d --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/arguments/nullForDifferentProjections.kt @@ -0,0 +1,17 @@ +// ISSUE: KT-37490 + +interface SomeFace + +class SomeGene { + fun setFace(face: SomeFace?) {} + fun setString(string: String?) {} +} + +fun nullTypeArg(invP: SomeGene, inP: SomeGene, outP: SomeGene) { + invP.setFace(null) + invP.setString(null) + inP.setFace(null) + inP.setString(null) + outP.setFace(null) + outP.setString(null) +} diff --git a/compiler/fir/analysis-tests/testData/resolve/callResolution/chooseOverloadByShapeOfLambda.fir.txt b/compiler/fir/analysis-tests/testData/resolve/callResolution/chooseOverloadByShapeOfLambda.fir.txt new file mode 100644 index 00000000000..fcbd80acf90 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/callResolution/chooseOverloadByShapeOfLambda.fir.txt @@ -0,0 +1,32 @@ +FILE: chooseOverloadByShapeOfLambda.kt + public final fun foo(x: R|(@R|kotlin/ParameterName|(name = String(a)) kotlin/Int) -> kotlin/Unit|): R|kotlin/Int| { + ^foo Int(1) + } + public final fun foo(x: R|(@R|kotlin/ParameterName|(name = String(a)) kotlin/Int, @R|kotlin/ParameterName|(name = String(b)) kotlin/String) -> kotlin/Unit|): R|kotlin/String| { + ^foo String() + } + public final fun takeInt(x: R|kotlin/Int|): R|kotlin/Unit| { + } + public final fun takeString(x: R|kotlin/String|): R|kotlin/Unit| { + } + public final fun test_1(): R|kotlin/Unit| { + lval res: R|kotlin/Int| = R|/foo|( = foo@fun (x: R|@R|kotlin/ParameterName|(name = String(a)) kotlin/Int|): R|kotlin/Unit| { + ^@foo Unit + } + ) + R|/takeInt|(R|/res|) + } + public final fun test_2(): R|kotlin/Unit| { + lval res: R|kotlin/String| = R|/foo|( = foo@fun (x: R|@R|kotlin/ParameterName|(name = String(a)) kotlin/Int|, y: R|@R|kotlin/ParameterName|(name = String(b)) kotlin/String|): R|kotlin/Unit| { + ^@foo Unit + } + ) + R|/takeString|(R|/res|) + } + public final fun test_3(): R|kotlin/Unit| { + lval res: R|kotlin/Int| = R|/foo|( = foo@fun (it: R|@R|kotlin/ParameterName|(name = String(a)) kotlin/Int|): R|kotlin/Unit| { + ^@foo Unit + } + ) + R|/takeInt|(R|/res|) + } diff --git a/compiler/fir/analysis-tests/testData/resolve/callResolution/chooseOverloadByShapeOfLambda.kt b/compiler/fir/analysis-tests/testData/resolve/callResolution/chooseOverloadByShapeOfLambda.kt new file mode 100644 index 00000000000..15b365bdc3f --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/callResolution/chooseOverloadByShapeOfLambda.kt @@ -0,0 +1,22 @@ +// ISSUE: KT-42715 + +fun foo(x: (a: Int) -> Unit): Int = 1 // (1) +fun foo(x: (a: Int, b: String) -> Unit): String = "" // (2) + +fun takeInt(x: Int) {} +fun takeString(x: String) {} + +fun test_1() { + val res = foo { x -> } // (1) + takeInt(res) +} + +fun test_2() { + val res = foo { x, y -> } // (2) + takeString(res) +} + +fun test_3() { + val res = foo {} // (1) + takeInt(res) +} diff --git a/compiler/fir/analysis-tests/testData/resolve/callResolution/referenceToNestedClass.fir.txt b/compiler/fir/analysis-tests/testData/resolve/callResolution/referenceToNestedClass.fir.txt new file mode 100644 index 00000000000..43f3f1c4599 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/callResolution/referenceToNestedClass.fir.txt @@ -0,0 +1,37 @@ +FILE: referenceToNestedClass.kt + public final class Param : R|kotlin/Any| { + public constructor(): R|Param| { + super() + } + + } + public open class Base : R|kotlin/Any| { + public constructor(param: R|Param|): R|Base| { + super() + } + + public final val param: R|Param| = R|/param| + public get(): R|Param| + + } + public final class Outer : R|Base| { + public constructor(param: R|Param|): R|Outer| { + super(R|/param|) + } + + public final class Nested : R|Base| { + public constructor(param: R|Param|): R|Outer.Nested| { + super(R|/param|) + } + + } + + } + public final fun funWithCtor(ctor: R|kotlin/reflect/KFunction1|): R|kotlin/Unit| { + } + public final fun main(): R|kotlin/Unit| { + R|/funWithCtor|(::R|/Outer.Outer|) + R|/funWithCtor|(::R|/Outer.Nested.Nested|) + R|/funWithCtor|(Q|Outer|::R|/Outer.Nested.Nested|) + R|/funWithCtor|(Q|Outer|::R|/Outer.Nested.Nested|::R|SubstitutionOverride|) + } diff --git a/compiler/fir/analysis-tests/testData/resolve/callResolution/referenceToNestedClass.kt b/compiler/fir/analysis-tests/testData/resolve/callResolution/referenceToNestedClass.kt new file mode 100644 index 00000000000..88bd614de4e --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/callResolution/referenceToNestedClass.kt @@ -0,0 +1,21 @@ +// ISSUE: KT-41038 + +import kotlin.reflect.* +import Outer.Nested + +class Param + +open class Base(val param: Param) + +class Outer(param: Param) : Base(param) { + class Nested(param: Param) : Base(param) +} + +fun funWithCtor(ctor: KFunction1) {} + +fun main() { + funWithCtor(::Outer) + funWithCtor(::Nested) + funWithCtor(Outer::Nested) + funWithCtor(Outer::Nested::invoke) +} diff --git a/compiler/fir/analysis-tests/testData/resolve/callResolution/suspendCOnversionForReceiver.fir.txt b/compiler/fir/analysis-tests/testData/resolve/callResolution/suspendCOnversionForReceiver.fir.txt new file mode 100644 index 00000000000..212cd939833 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/callResolution/suspendCOnversionForReceiver.fir.txt @@ -0,0 +1,11 @@ +FILE: suspendCOnversionForReceiver.kt + public final fun R|suspend () -> kotlin/Unit|.extensionFunc(): R|kotlin/Unit| { + } + public final fun parameterFunc(func: R|suspend () -> kotlin/Unit|): R|kotlin/Unit| { + } + public final fun testFunc(): R|kotlin/Unit| { + } + public final fun main(): R|kotlin/Unit| { + R|/parameterFunc|(::R|/testFunc|) + ::R|/testFunc|.R|/extensionFunc|() + } diff --git a/compiler/fir/analysis-tests/testData/resolve/callResolution/suspendCOnversionForReceiver.kt b/compiler/fir/analysis-tests/testData/resolve/callResolution/suspendCOnversionForReceiver.kt new file mode 100644 index 00000000000..8baff6ddfdd --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/callResolution/suspendCOnversionForReceiver.kt @@ -0,0 +1,10 @@ +// ISSUE: KT-46288 + +fun (suspend () -> Unit).extensionFunc() {} +fun parameterFunc(func: suspend () -> Unit) {} +fun testFunc() {} + +fun main() { + parameterFunc(::testFunc) + (::testFunc).extensionFunc() +} diff --git a/compiler/fir/analysis-tests/testData/resolve/cfa/kt53819.fir.txt b/compiler/fir/analysis-tests/testData/resolve/cfa/kt53819.fir.txt new file mode 100644 index 00000000000..9ff77909295 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/cfa/kt53819.fir.txt @@ -0,0 +1,20 @@ +FILE: kt53819.kt + public final fun bar(): R|kotlin/Unit| { + local final class Foo : R|kotlin/Any| { + private final var _x: R|kotlin/Int| + private get(): R|kotlin/Int| + private set(value: R|kotlin/Int|): R|kotlin/Unit| + + public constructor(x: R|kotlin/Int|): R|Foo| { + super() + this@R|/Foo|.R|/_x| = R|/x| + } + + public final val x: R|kotlin/Int| + public get(): R|kotlin/Int| { + ^ this@R|/Foo|.R|/_x| + } + + } + + } diff --git a/compiler/fir/analysis-tests/testData/resolve/cfa/kt53819.kt b/compiler/fir/analysis-tests/testData/resolve/cfa/kt53819.kt new file mode 100644 index 00000000000..70b55f68531 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/cfa/kt53819.kt @@ -0,0 +1,14 @@ +// ISSUE: KT-53819 +fun bar() { + class Foo { + private var _x: Int + + constructor(x: Int) { + this._x = x + } + + val x: Int + get() = _x + } +} + diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/lambdaInIfInTry.fir.txt b/compiler/fir/analysis-tests/testData/resolve/cfg/lambdaInIfInTry.fir.txt new file mode 100644 index 00000000000..ec27fb11361 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/cfg/lambdaInIfInTry.fir.txt @@ -0,0 +1,27 @@ +FILE: lambdaInIfInTry.kt + public final suspend fun suspendRun(block: R|suspend () -> R|): R|R| { + ^suspendRun Null(null)!! + } + public final suspend fun test(): R|kotlin/Unit| { + lvar e: R|kotlin/Throwable?| = Null(null) + try { + R|/suspendRun|( = suspendRun@fun (): R|kotlin/Unit| { + when () { + Boolean(true) -> { + ^test Unit + } + } + + } + ) + } + finally { + when () { + !=(R|/e|, Null(null)) -> { + throw R|/e| + } + } + + } + + } diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/lambdaInIfInTry.kt b/compiler/fir/analysis-tests/testData/resolve/cfg/lambdaInIfInTry.kt new file mode 100644 index 00000000000..9512e27b1d0 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/cfg/lambdaInIfInTry.kt @@ -0,0 +1,18 @@ +// ISSUE: KT-52934 + +suspend fun suspendRun(block: suspend () -> R): R = null!! + +suspend fun test() { + var e: Throwable? = null + try { + suspendRun { + if (true) { + return + } + } + } finally { + if (e != null) { + throw e + } + } +} diff --git a/compiler/fir/analysis-tests/testData/resolve/checkers/complexConflictingProjections.fir.txt b/compiler/fir/analysis-tests/testData/resolve/checkers/complexConflictingProjections.fir.txt new file mode 100644 index 00000000000..b2fa9d9c40b --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/checkers/complexConflictingProjections.fir.txt @@ -0,0 +1,40 @@ +FILE: complexConflictingProjections.kt + public final class Foo : R|kotlin/Any| { + public constructor(): R|Foo| { + super() + } + + } + public final class Bar : R|kotlin/Any| { + public constructor(): R|Bar| { + super() + } + + } + public final class Baz|> : R|kotlin/Any| { + public constructor|>(): R|Baz| { + super() + } + + } + public final class Qux>|> : R|kotlin/Any| { + public constructor>|>(f: R|T2|): R|Qux| { + super() + } + + public final var f: R|T2| = R|/f| + public get(): R|T2| + public set(value: R|T2|): R|kotlin/Unit| + + } + public final class Quux : R|kotlin/Any| { + public constructor(): R|Quux| { + super() + } + + public final fun test(): R|kotlin/Unit| { + lval x: R|Qux>>| = Null(null)!! + R|/x|.R|SubstitutionOverride (1 parameter has declared variance: out, but argument variance is in)>)|>| = Null(null)!! + } + + } diff --git a/compiler/fir/analysis-tests/testData/resolve/checkers/complexConflictingProjections.kt b/compiler/fir/analysis-tests/testData/resolve/checkers/complexConflictingProjections.kt new file mode 100644 index 00000000000..7479f985095 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/checkers/complexConflictingProjections.kt @@ -0,0 +1,13 @@ +// ISSUE: KT-49024 + +class Foo +class BarFoo, out T2> +class Baz> +class QuxBar>>(var f: T2) + +class Quux { + fun test(): Unit { + val x: QuxBazBarin T>>> = null!! + x.f = null!! + } +} diff --git a/compiler/fir/analysis-tests/testData/resolve/checkers/importAnnotationWithRequiresOptIn.fir.txt b/compiler/fir/analysis-tests/testData/resolve/checkers/importAnnotationWithRequiresOptIn.fir.txt new file mode 100644 index 00000000000..52d7c499b1f --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/checkers/importAnnotationWithRequiresOptIn.fir.txt @@ -0,0 +1,9 @@ +FILE: a.kt + @R|kotlin/RequiresOptIn|() public final annotation class MyOptIn : R|kotlin/Annotation| { + public constructor(): R|MyOptIn| { + super() + } + + } +FILE: b.kt + package vvv diff --git a/compiler/fir/analysis-tests/testData/resolve/checkers/importAnnotationWithRequiresOptIn.kt b/compiler/fir/analysis-tests/testData/resolve/checkers/importAnnotationWithRequiresOptIn.kt new file mode 100644 index 00000000000..fc5f840c3ae --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/checkers/importAnnotationWithRequiresOptIn.kt @@ -0,0 +1,10 @@ +// ISSUE: KT-53671 + +// FILE: a.kt +@RequiresOptIn +annotation class MyOptIn + +// FILE: b.kt +package vvv + +import MyOptIn // OPT_IN_MARKER_CAN_ONLY_BE_USED_AS_ANNOTATION_OR_ARGUMENT_IN_OPT_IN diff --git a/compiler/fir/analysis-tests/testData/resolve/checkers/internalImplicitInvokeFromInlineFun.fir.txt b/compiler/fir/analysis-tests/testData/resolve/checkers/internalImplicitInvokeFromInlineFun.fir.txt new file mode 100644 index 00000000000..f49a96009f3 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/checkers/internalImplicitInvokeFromInlineFun.fir.txt @@ -0,0 +1,17 @@ +FILE: internalImplicitInvokeFromInlineFun.kt + public final class Test : R|kotlin/Any| { + public constructor(): R|Test| { + super() + } + + internal final operator fun invoke(): R|Test| { + ^invoke this@R|/Test| + } + + } + public final inline fun testFunction(): R|Test| { + ^testFunction R|/Test.Test|().R|/Test.invoke|() + } + public final inline fun testOperator(): R|Test| { + ^testOperator R|/Test.Test|().R|/Test.invoke|() + } diff --git a/compiler/fir/analysis-tests/testData/resolve/checkers/internalImplicitInvokeFromInlineFun.kt b/compiler/fir/analysis-tests/testData/resolve/checkers/internalImplicitInvokeFromInlineFun.kt new file mode 100644 index 00000000000..447f46846ab --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/checkers/internalImplicitInvokeFromInlineFun.kt @@ -0,0 +1,8 @@ +// ISSUE: KT-20223 + +class Test { + internal operator fun invoke() = this +} + +inline fun testFunction() = Test().invoke() +inline fun testOperator() = Test()() diff --git a/compiler/fir/analysis-tests/testData/resolve/checkers/internalSuperCallFromInlineFun.fir.txt b/compiler/fir/analysis-tests/testData/resolve/checkers/internalSuperCallFromInlineFun.fir.txt new file mode 100644 index 00000000000..e80599e5497 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/checkers/internalSuperCallFromInlineFun.fir.txt @@ -0,0 +1,26 @@ +FILE: internalSuperCallFromInlineFun.kt + public abstract class C : R|kotlin/Any| { + public constructor(): R|C| { + super() + } + + internal final fun foo(x: R|kotlin/String|): R|kotlin/String| { + ^foo R|/x| + } + + public abstract fun bar(): R|kotlin/String| + + } + public final inline fun baz(crossinline block: R|() -> kotlin/String|): R|C| { + ^baz object : R|C| { + private constructor(): R|| { + super() + } + + public open override fun bar(): R|kotlin/String| { + ^bar this@R|/|.R|/C.foo|(R|/block|.R|SubstitutionOverride|()) + } + + } + + } diff --git a/compiler/fir/analysis-tests/testData/resolve/checkers/internalSuperCallFromInlineFun.kt b/compiler/fir/analysis-tests/testData/resolve/checkers/internalSuperCallFromInlineFun.kt new file mode 100644 index 00000000000..bf2cc39ff1a --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/checkers/internalSuperCallFromInlineFun.kt @@ -0,0 +1,11 @@ +// ISSUE: KT-54518 + +abstract class C { + internal fun foo(x: String) = x + + abstract fun bar(): String +} + +inline fun baz(crossinline block: () -> String) = object : C() { + override fun bar() = foo(block()) +} diff --git a/compiler/fir/analysis-tests/testData/resolve/checkers/invalidLhsOfClassLiteral.fir.txt b/compiler/fir/analysis-tests/testData/resolve/checkers/invalidLhsOfClassLiteral.fir.txt new file mode 100644 index 00000000000..40fb7aa72eb --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/checkers/invalidLhsOfClassLiteral.fir.txt @@ -0,0 +1,4 @@ +FILE: invalidLhsOfClassLiteral.kt + public final fun main(args: R|kotlin/Array|): R|kotlin/Unit| { + (#().#<*>) + } diff --git a/compiler/fir/analysis-tests/testData/resolve/checkers/invalidLhsOfClassLiteral.kt b/compiler/fir/analysis-tests/testData/resolve/checkers/invalidLhsOfClassLiteral.kt new file mode 100644 index 00000000000..89b051cd3ee --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/checkers/invalidLhsOfClassLiteral.kt @@ -0,0 +1,5 @@ +// ISSUE: KT-17817 + +fun main(args: Array) { + foo().Wrapper<*>::class // no errors +} diff --git a/compiler/fir/analysis-tests/testData/resolve/checkers/notUselessCast_1.fir.txt b/compiler/fir/analysis-tests/testData/resolve/checkers/notUselessCast_1.fir.txt new file mode 100644 index 00000000000..bd3329126ba --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/checkers/notUselessCast_1.fir.txt @@ -0,0 +1,33 @@ +FILE: notUselessCast_1.kt + public open class Base : R|kotlin/Any| { + public constructor(): R|Base| { + super() + } + + } + public final class Derived : R|Base| { + public constructor(): R|Derived| { + super() + } + + } + public final fun test_0(d: R|Derived|): R|kotlin/Unit| { + local final fun take(d: R|Derived|): R|kotlin/Unit| { + } + + R|/take|((R|/d| as R|Derived|)) + } + public final fun test_1(): R|kotlin/Unit| { + lval list: R|kotlin/collections/MutableList| = R|kotlin/collections/listOf|().R|kotlin/collections/map|( = map@fun (it: R|kotlin/Any|): R|Base| { + ^ (R|/Derived.Derived|() as R|Base|) + } + ).R|kotlin/collections/toMutableList|() + R|/list|.R|SubstitutionOverride|(R|/Base.Base|()) + } + public final fun test_2(): R|kotlin/Unit| { + lval list: R|kotlin/collections/MutableList| = R|kotlin/collections/listOf|().R|kotlin/collections/map|( = map@fun (it: R|kotlin/Any|): R|Derived| { + ^ R|/Derived.Derived|() + } + ).R|kotlin/collections/toMutableList|() + R|/list|.R|SubstitutionOverride#|(R|/Base.Base|()) + } diff --git a/compiler/fir/analysis-tests/testData/resolve/checkers/notUselessCast_1.kt b/compiler/fir/analysis-tests/testData/resolve/checkers/notUselessCast_1.kt new file mode 100644 index 00000000000..e56cb3cebc8 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/checkers/notUselessCast_1.kt @@ -0,0 +1,20 @@ +// ISSUE: KT-42136 +// WITH_STDLIB + +open class Base +class Derived : Base() + +fun test_0(d: Derived) { + fun take(d: Derived) {} + take(d as Derived) // should be USELESS_CAST +} + +fun test_1() { + val list = listOf().map { Derived() as Base }.toMutableList() // should be no USELESS_CAST + list.add(Base()) +} + +fun test_2() { + val list = listOf().map { Derived() }.toMutableList() + list.add(Base()) // should be an error +} diff --git a/compiler/fir/analysis-tests/testData/resolve/checkers/notUselessCast_2.fir.txt b/compiler/fir/analysis-tests/testData/resolve/checkers/notUselessCast_2.fir.txt new file mode 100644 index 00000000000..dc7a919fea4 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/checkers/notUselessCast_2.fir.txt @@ -0,0 +1,61 @@ +FILE: notUselessCast_2.kt + public final data class Foo : R|kotlin/Any| { + public constructor(foo: R|kotlin/String|): R|Foo| { + super() + } + + public final val foo: R|kotlin/String| = R|/foo| + public get(): R|kotlin/String| + + public final operator fun component1(): R|kotlin/String| + + public final fun copy(foo: R|kotlin/String| = this@R|/Foo|.R|/Foo.foo|): R|Foo| + + } + public final class Bar : R|kotlin/Any| { + public constructor(bar: R|kotlin/String|): R|Bar| { + super() + } + + public final val bar: R|kotlin/String| = R|/bar| + public get(): R|kotlin/String| + + } + public final fun R|Bar|.toFoo(): R|Foo| { + ^toFoo R|/Foo.Foo|(this@R|/toFoo|.R|/Bar.bar|) + } + public final class Wrapper : R|kotlin/Any| { + public constructor(wrapped: R|T|): R|Wrapper| { + super() + } + + public final val wrapped: R|T| = R|/wrapped| + public get(): R|T| + + public final fun map(f: R|(T) -> A|): R|Wrapper| { + ^map R|/Wrapper.Wrapper|(R|/f|.R|SubstitutionOverride|(this@R|/Wrapper|.R|/Wrapper.wrapped|)) + } + + public final fun swapWrappedValue(f: R|(T) -> Wrapper|): R|Wrapper| { + ^swapWrappedValue R|/f|.R|SubstitutionOverride|>|(this@R|/Wrapper|.R|/Wrapper.wrapped|) + } + + } + public final fun test_1(): R|Wrapper| { + ^test_1 R|/Wrapper.Wrapper|(R|/Bar.Bar|(String(bar))).R|SubstitutionOverride|>|( = map@fun (it: R|Bar|): R|Foo?| { + ^ (R|/it|.R|/toFoo|() as R|Foo?|) + } + ).R|SubstitutionOverride|>|( = swapWrappedValue@fun (it: R|Foo?|): R|Wrapper| { + ^ R|/Wrapper.Wrapper|(Null(null)) + } + ) + } + public final fun test_2(): R|Wrapper| { + ^test_2 R|/Wrapper.Wrapper|(R|/Bar.Bar|(String(bar))).R|SubstitutionOverride|>|( = map@fun (it: R|Bar|): R|Foo| { + ^ R|/it|.R|/toFoo|() + } + ).R|SubstitutionOverride|>#|( = swapWrappedValue@fun (it: R|Foo|): R|Wrapper| { + ^ R|/Wrapper.Wrapper#|(Null(null)) + } + ) + } diff --git a/compiler/fir/analysis-tests/testData/resolve/checkers/notUselessCast_2.kt b/compiler/fir/analysis-tests/testData/resolve/checkers/notUselessCast_2.kt new file mode 100644 index 00000000000..1bf2462ebed --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/checkers/notUselessCast_2.kt @@ -0,0 +1,23 @@ +// ISSUE: KT-49045 + +data class Foo(val foo: String) +class Bar(val bar: String) + +fun Bar.toFoo() = Foo(bar) + +class Wrapper(val wrapped: T) { + fun map(f: (T) -> A): Wrapper = Wrapper(f(wrapped)) + fun swapWrappedValue(f: (T) -> Wrapper): Wrapper = f(wrapped) +} + +fun test_1(): Wrapper { + return Wrapper(Bar("bar")) + .map { it.toFoo() as Foo? } + .swapWrappedValue { Wrapper(null) } +} + +fun test_2(): Wrapper { + return Wrapper(Bar("bar")) + .map { it.toFoo() } + .swapWrappedValue { Wrapper(null) } +} diff --git a/compiler/fir/analysis-tests/testData/resolve/checkers/notUselessCast_3.fir.txt b/compiler/fir/analysis-tests/testData/resolve/checkers/notUselessCast_3.fir.txt new file mode 100644 index 00000000000..ccd167341ae --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/checkers/notUselessCast_3.fir.txt @@ -0,0 +1,43 @@ +FILE: notUselessCast_3.kt + public sealed interface Square : R|kotlin/Any| { + } + public final object MARKED : R|Square| { + private constructor(): R|MARKED| { + super() + } + + } + public final object UNMARKED : R|Square| { + private constructor(): R|UNMARKED| { + super() + } + + } + public final fun test_1(): R|kotlin/Unit| { + lval lines: R|kotlin/collections/List| = R|kotlin/collections/listOf|() + lval cards: R|kotlin/collections/List>>| = R|/lines|.R|kotlin/collections/windowed|(Int(6)).R|kotlin/collections/map||, R|kotlin/collections/List>|>( = map@fun (card: R|kotlin/collections/List|): R|kotlin/collections/List>| { + ^ R|/card|.R|kotlin/collections/map||>( = map@fun (line: R|kotlin/String|): R|kotlin/collections/MutableList| { + ^ R|/line|.R|kotlin/text/map|( = map@fun (it: R|kotlin/Char|): R|Square| { + ^ (Q|UNMARKED| as R|Square|) + } + ).R|kotlin/collections/toMutableList|() + } + ) + } + ) + R|/cards|.R|SubstitutionOverride>|>|(Int(0)).R|SubstitutionOverride|>|(Int(0)).R|SubstitutionOverride|(Int(0), Q|MARKED|) + } + public final fun test_2(): R|kotlin/Unit| { + lval lines: R|kotlin/collections/List| = R|kotlin/collections/listOf|() + lval cards: R|kotlin/collections/List>>| = R|/lines|.R|kotlin/collections/windowed|(Int(6)).R|kotlin/collections/map||, R|kotlin/collections/List>|>( = map@fun (card: R|kotlin/collections/List|): R|kotlin/collections/List>| { + ^ R|/card|.R|kotlin/collections/map||>( = map@fun (line: R|kotlin/String|): R|kotlin/collections/MutableList| { + ^ R|/line|.R|kotlin/text/map|( = map@fun (it: R|kotlin/Char|): R|UNMARKED| { + ^ Q|UNMARKED| + } + ).R|kotlin/collections/toMutableList|() + } + ) + } + ) + R|/cards|.R|SubstitutionOverride>|>|(Int(0)).R|SubstitutionOverride|>|(Int(0)).R|SubstitutionOverride#|(Int(0), Q|MARKED|) + } diff --git a/compiler/fir/analysis-tests/testData/resolve/checkers/notUselessCast_3.kt b/compiler/fir/analysis-tests/testData/resolve/checkers/notUselessCast_3.kt new file mode 100644 index 00000000000..f58e8d9fb37 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/checkers/notUselessCast_3.kt @@ -0,0 +1,30 @@ +// ISSUE: KT-50160 +// WITH_STDLIB + +sealed interface Square +object MARKED : Square +object UNMARKED : Square + +fun test_1() { + val lines: List = listOf() + val cards = lines.windowed(6) + .map { card -> + card.map { line: String -> + line.map { UNMARKED as Square } + .toMutableList() + } + } + cards[0][0][0] = MARKED +} + +fun test_2() { + val lines: List = listOf() + val cards = lines.windowed(6) + .map { card -> + card.map { line: String -> + line.map { UNMARKED } + .toMutableList() + } + } + cards[0][0][0] = MARKED +} diff --git a/compiler/fir/analysis-tests/testData/resolve/checkers/recursiveDependencyBetweenReturnTypeAndSupertype.fir.txt b/compiler/fir/analysis-tests/testData/resolve/checkers/recursiveDependencyBetweenReturnTypeAndSupertype.fir.txt new file mode 100644 index 00000000000..11a86233be4 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/checkers/recursiveDependencyBetweenReturnTypeAndSupertype.fir.txt @@ -0,0 +1,19 @@ +FILE: recursiveDependencyBetweenReturnTypeAndSupertype.kt + public abstract interface A : R|Test| { + } + public open class Test : R|kotlin/Any| { + public constructor(): R|Test| { + super() + } + + public final fun result(): R|A| { + ^result object : R|A| { + private constructor(): R|| { + super() + } + + } + + } + + } diff --git a/compiler/fir/analysis-tests/testData/resolve/checkers/recursiveDependencyBetweenReturnTypeAndSupertype.kt b/compiler/fir/analysis-tests/testData/resolve/checkers/recursiveDependencyBetweenReturnTypeAndSupertype.kt new file mode 100644 index 00000000000..de33ad082f7 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/checkers/recursiveDependencyBetweenReturnTypeAndSupertype.kt @@ -0,0 +1,7 @@ +// ISSUE: KT-47815 + +interface A : Test + +open class Test { + fun result() = object : A { } +} diff --git a/compiler/fir/analysis-tests/testData/resolve/checkers/unsuccessfullCastToStartProjectedType.fir.txt b/compiler/fir/analysis-tests/testData/resolve/checkers/unsuccessfullCastToStartProjectedType.fir.txt new file mode 100644 index 00000000000..2fa840bd693 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/checkers/unsuccessfullCastToStartProjectedType.fir.txt @@ -0,0 +1,22 @@ +FILE: unsuccessfullCastToStartProjectedType.kt + public open class Foo : R|kotlin/Any| { + public constructor(): R|Foo| { + super() + } + + } + public final class Foo1 : R|Foo| { + public constructor(): R|Foo1| { + super|>() + } + + } + public final class Foo2 : R|Foo| { + public constructor(): R|Foo2| { + super|>() + } + + } + public final fun process(foo: R|Foo|): R|kotlin/Unit| { + (R|/foo| as R|Foo1<*>|) + } diff --git a/compiler/fir/analysis-tests/testData/resolve/checkers/unsuccessfullCastToStartProjectedType.kt b/compiler/fir/analysis-tests/testData/resolve/checkers/unsuccessfullCastToStartProjectedType.kt new file mode 100644 index 00000000000..23c7c8bb91e --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/checkers/unsuccessfullCastToStartProjectedType.kt @@ -0,0 +1,9 @@ +// ISSUE: KT-42169 + +open class Foo +class Foo1 : Foo() +class Foo2 : Foo() + +fun process(foo: Foo) { + foo as Foo1<*> +} diff --git a/compiler/fir/analysis-tests/testData/resolve/checkers/uselessCastLeadsToRecursiveProblem.fir.txt b/compiler/fir/analysis-tests/testData/resolve/checkers/uselessCastLeadsToRecursiveProblem.fir.txt new file mode 100644 index 00000000000..71d87405263 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/checkers/uselessCastLeadsToRecursiveProblem.fir.txt @@ -0,0 +1,53 @@ +FILE: uselessCastLeadsToRecursiveProblem.kt + public abstract interface A : R|kotlin/Any| { + } + public final class B : R|A| { + public constructor(): R|B| { + super() + } + + } + public open class C : R|A| { + public constructor(): R|C| { + super() + } + + } + public final val R|kotlin/reflect/KClass|.extProp1: R|kotlin/String| + public get(): R|kotlin/String| { + ^ String(I'm C) + } + public final val R|A|.extProp1: R|kotlin/String| + public get(): R|kotlin/String| { + ^ when (this@R|/extProp1|) { + ($subj$ is R|B|) -> { + String(I'm B) + } + ($subj$ is R|C|) -> { + ((this@R|/extProp1| as R|C|)).R|/extProp1| + } + else -> { + String(I don't know who I am..) + } + } + + } + public final val R|kotlin/reflect/KClass|.extProp2: R|kotlin/String| + public get(): R|kotlin/String| { + ^ String(I'm C) + } + public final val R|A|.extProp2: R|kotlin/String| + public get(): R|kotlin/String| { + ^ when (this@R|/extProp2|) { + ($subj$ is R|B|) -> { + String(I'm B) + } + ($subj$ is R|C|) -> { + (this@R|/extProp2|).R|/extProp2| + } + else -> { + String(I don't know who I am..) + } + } + + } diff --git a/compiler/fir/analysis-tests/testData/resolve/checkers/uselessCastLeadsToRecursiveProblem.kt b/compiler/fir/analysis-tests/testData/resolve/checkers/uselessCastLeadsToRecursiveProblem.kt new file mode 100644 index 00000000000..06f74637ab5 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/checkers/uselessCastLeadsToRecursiveProblem.kt @@ -0,0 +1,27 @@ +// ISSUE: KT-43603 + +import kotlin.reflect.KClass + +interface A +class B : A +open class C : A + +val KClass.extProp1 + get() = "I'm C" + +val A.extProp1 + get() = when (this) { + is B -> "I'm B" + is C -> (this as C)::class.extProp1 + else -> "I don't know who I am.." + } + +val KClass.extProp2 + get() = "I'm C" + +val A.extProp2 + get() = when (this) { + is B -> "I'm B" + is C -> this::class.extProp2 + else -> "I don't know who I am.." + } diff --git a/compiler/fir/analysis-tests/testData/resolve/contracts/contractOnInfixFunction.fir.txt b/compiler/fir/analysis-tests/testData/resolve/contracts/contractOnInfixFunction.fir.txt new file mode 100644 index 00000000000..2d9e0c99875 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/contracts/contractOnInfixFunction.fir.txt @@ -0,0 +1,47 @@ +FILE: contractOnInfixFunction.kt + @R|kotlin/OptIn|(markerClass = vararg((Q|kotlin/contracts/ExperimentalContracts|))) public final infix fun R|kotlin/Boolean|.takeRight(cond: R|kotlin/Boolean|): R|kotlin/Boolean| + [R|Contract description] + < + Returns(TRUE) -> cond + > + { + { + R|kotlin/contracts/contract|( = contract@fun R|kotlin/contracts/ContractBuilder|.(): R|kotlin/Unit| { + this@R|special/anonymous|.R|kotlin/contracts/ContractBuilder.returns|(Boolean(true)).R|kotlin/contracts/SimpleEffect.implies|(R|/cond|) + } + ) + } + + ^takeRight R|/cond| + } + @R|kotlin/OptIn|(markerClass = vararg((Q|kotlin/contracts/ExperimentalContracts|))) public final infix fun R|kotlin/Boolean?|.ensureLeft(x: R|kotlin/Any|): R|kotlin/Boolean| + [R|Contract description] + < + Returns(TRUE) -> this != null + > + { + { + R|kotlin/contracts/contract|( = contract@fun R|kotlin/contracts/ContractBuilder|.(): R|kotlin/Unit| { + this@R|special/anonymous|.R|kotlin/contracts/ContractBuilder.returns|(Boolean(true)).R|kotlin/contracts/SimpleEffect.implies|(!=(this@R|/ensureLeft|, Null(null))) + } + ) + } + + ^ensureLeft !=(this@R|/ensureLeft|, Null(null)) + } + public final fun test_1(b: R|kotlin/Boolean|, x: R|kotlin/Any|): R|kotlin/Unit| { + when () { + R|/b|.R|/takeRight|((R|/x| is R|kotlin/String|)) -> { + R|/x|.R|kotlin/String.length| + } + } + + } + public final fun test_2(b: R|kotlin/Boolean?|, x: R|kotlin/Any|): R|kotlin/Unit| { + when () { + R|/b|.R|/ensureLeft|((R|/x| is R|kotlin/String|)) -> { + R|/b|.R|kotlin/Boolean.not|() + } + } + + } diff --git a/compiler/fir/analysis-tests/testData/resolve/contracts/contractOnInfixFunction.kt b/compiler/fir/analysis-tests/testData/resolve/contracts/contractOnInfixFunction.kt new file mode 100644 index 00000000000..3c40fda2abb --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/contracts/contractOnInfixFunction.kt @@ -0,0 +1,28 @@ +// ISSUE: KT-27261 +// WITH_STDLIB + +import kotlin.contracts.* + +@OptIn(ExperimentalContracts::class) +infix fun Boolean.takeRight(cond: Boolean): Boolean { + contract { returns(true) implies cond } + return cond +} + +@OptIn(ExperimentalContracts::class) +infix fun Boolean?.ensureLeft(x: Any): Boolean { + contract { returns(true) implies (this@ensureLeft != null) } + return this != null +} + +fun test_1(b: Boolean, x: Any) { + if (b takeRight (x is String)) { + x.length + } +} + +fun test_2(b: Boolean?, x: Any) { + if (b ensureLeft (x is String)) { + b.not() + } +} diff --git a/compiler/fir/analysis-tests/testData/resolve/contracts/inPlaceAfterVararg.fir.txt b/compiler/fir/analysis-tests/testData/resolve/contracts/inPlaceAfterVararg.fir.txt new file mode 100644 index 00000000000..1f7fecbfcd2 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/contracts/inPlaceAfterVararg.fir.txt @@ -0,0 +1,24 @@ +FILE: inPlaceAfterVararg.kt + @R|kotlin/OptIn|(markerClass = vararg((Q|kotlin/contracts/ExperimentalContracts|))) public final fun example(vararg strings: R|kotlin/Array|, block: R|() -> kotlin/Unit|): R|kotlin/Unit| + [R|Contract description] + < + CallsInPlace(block, EXACTLY_ONCE) + > + { + { + R|kotlin/contracts/contract|( = contract@fun R|kotlin/contracts/ContractBuilder|.(): R|kotlin/Unit| { + this@R|special/anonymous|.R|kotlin/contracts/ContractBuilder.callsInPlace|(R|/block|, Q|kotlin/contracts/InvocationKind|.R|kotlin/contracts/InvocationKind.EXACTLY_ONCE|) + } + ) + } + + R|/block|.R|SubstitutionOverride|() + } + public final fun test(): R|kotlin/Unit| { + lval x: R|kotlin/String| + R|/example|(vararg(String()), = example@fun (): R|kotlin/Unit| { + R|/x| = String() + } + ) + R|/x|.R|kotlin/String.length| + } diff --git a/compiler/fir/analysis-tests/testData/resolve/contracts/inPlaceAfterVararg.kt b/compiler/fir/analysis-tests/testData/resolve/contracts/inPlaceAfterVararg.kt new file mode 100644 index 00000000000..53cdb918c47 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/contracts/inPlaceAfterVararg.kt @@ -0,0 +1,21 @@ +// WITH_STDLIB +// ISSUE: KT-30497 +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract + +@OptIn(ExperimentalContracts::class) +fun example(vararg strings: String, block: () -> Unit) { + contract { + callsInPlace(block, InvocationKind.EXACTLY_ONCE) + } + block() +} + +fun test() { + val x: String + example("") { + x = "" + } + x.length +} diff --git a/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/annotatedBranch.fir.txt b/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/annotatedBranch.fir.txt new file mode 100644 index 00000000000..1e862b636f6 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/annotatedBranch.fir.txt @@ -0,0 +1,29 @@ +FILE: annotatedBranch.kt + public final enum class SomeEnum : R|kotlin/Enum| { + private constructor(): R|SomeEnum| { + super|>() + } + + public final static enum entry A: R|SomeEnum| + public final static enum entry B: R|SomeEnum| + public final static fun values(): R|kotlin/Array| { + } + + public final static fun valueOf(value: R|kotlin/String|): R|SomeEnum| { + } + + public final static val entries: R|kotlin/enums/EnumEntries| + public get(): R|kotlin/enums/EnumEntries| + + } + public final fun test(x: R|SomeEnum|): R|kotlin/Unit| { + when (R|/x|) { + ==($subj$, Q|SomeEnum|.R|/SomeEnum.A|) -> { + Int(1) + } + ==($subj$, @R|kotlin/Suppress|(names = vararg(String(deprecation))) Q|SomeEnum|.R|/SomeEnum.B|) -> { + Int(2) + } + } + .R|kotlin/Int.inc|() + } diff --git a/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/annotatedBranch.kt b/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/annotatedBranch.kt new file mode 100644 index 00000000000..e40b0861f80 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/annotatedBranch.kt @@ -0,0 +1,11 @@ +// ISSUE: KT-50550 + +enum class SomeEnum { A, B} + +fun test(x: SomeEnum) { + when (x) { + SomeEnum.A -> 1 + @Suppress("deprecation") + SomeEnum.B -> 2 + }.inc() +} diff --git a/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/exhaustiveness_smartcastedBoolean.fir.txt b/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/exhaustiveness_smartcastedBoolean.fir.txt new file mode 100644 index 00000000000..896053fc420 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/exhaustiveness_smartcastedBoolean.fir.txt @@ -0,0 +1,52 @@ +FILE: exhaustiveness_smartcastedBoolean.kt + public final fun test_1(b: R|kotlin/Any|): R|kotlin/Unit| { + R|kotlin/require|((R|/b| is R|kotlin/Boolean|)) + lval x: R|kotlin/Unit| = when (R|/b|) { + ==($subj$, Boolean(true)) -> { + Int(1) + } + } + + lval y: R|kotlin/Int| = when (R|/b|) { + ==($subj$, Boolean(true)) -> { + Int(1) + } + ==($subj$, Boolean(false)) -> { + Int(2) + } + } + + lval z: R|kotlin/Int| = when (R|/b|) { + ==($subj$, Boolean(true)) -> { + Int(1) + } + else -> { + Int(2) + } + } + + } + public final fun test_2(b: R|kotlin/Any?|): R|kotlin/Unit| { + R|kotlin/require|((R|/b| is R|kotlin/Boolean?|)) + lval x: R|kotlin/Unit| = when (R|/b|) { + ==($subj$, Boolean(true)) -> { + Int(1) + } + ==($subj$, Boolean(false)) -> { + Int(2) + } + } + + lval y: R|kotlin/Int| = when (R|/b|) { + ==($subj$, Boolean(true)) -> { + Int(1) + } + ==($subj$, Boolean(false)) -> { + Int(2) + } + ==($subj$, Null(null)) -> { + Int(3) + } + } + + } diff --git a/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/exhaustiveness_smartcastedBoolean.kt b/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/exhaustiveness_smartcastedBoolean.kt new file mode 100644 index 00000000000..bb94d72936c --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/exhaustiveness_smartcastedBoolean.kt @@ -0,0 +1,30 @@ +// WITH_STDLIB +// ISSUE: KT-55379 + +fun test_1(b: Any) { + require(b is Boolean) + val x = when (b) { + true -> 1 + } + val y = when (b) { + true -> 1 + false -> 2 + } + val z = when (b) { + true -> 1 + else -> 2 + } +} + +fun test_2(b: Any?) { + require(b is Boolean?) + val x = when (b) { + true -> 1 + false -> 2 + } + val y = when (b) { + true -> 1 + false -> 2 + null -> 3 + } +} diff --git a/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/sameBranchMultipleConditions.fir.txt b/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/sameBranchMultipleConditions.fir.txt new file mode 100644 index 00000000000..3e8f5e844d6 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/sameBranchMultipleConditions.fir.txt @@ -0,0 +1,50 @@ +FILE: sameBranchMultipleConditions.kt + public sealed interface A : R|kotlin/Any| { + } + public sealed interface B : R|kotlin/Any| { + } + public final data class X : R|A|, R|B| { + public constructor(something: R|kotlin/String|): R|X| { + super() + } + + public final val something: R|kotlin/String| = R|/something| + public get(): R|kotlin/String| + + public final operator fun component1(): R|kotlin/String| + + public final fun copy(something: R|kotlin/String| = this@R|/X|.R|/X.something|): R|X| + + } + public final data class Y : R|A|, R|B| { + public constructor(something: R|kotlin/String|): R|Y| { + super() + } + + public final val something: R|kotlin/String| = R|/something| + public get(): R|kotlin/String| + + public final operator fun component1(): R|kotlin/String| + + public final fun copy(something: R|kotlin/String| = this@R|/Y|.R|/Y.something|): R|Y| + + } + public final fun ok(a: R|A|): R|B| { + ^ok when (R|/a|) { + ($subj$ is R|X|) -> { + R|/a| + } + ($subj$ is R|Y|) -> { + R|/a| + } + } + + } + public final fun problem(a: R|A|): R|B| { + ^problem when (R|/a|) { + ($subj$ is R|X|) || ($subj$ is R|Y|) -> { + R|/a| + } + } + + } diff --git a/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/sameBranchMultipleConditions.kt b/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/sameBranchMultipleConditions.kt new file mode 100644 index 00000000000..78ef044df2e --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/sameBranchMultipleConditions.kt @@ -0,0 +1,20 @@ +// ISSUE: KT-46301 + +sealed interface A +sealed interface B + +data class X(val something: String): A, B +data class Y(val something: String): A, B + +fun ok(a: A): B { + return when (a) { + is X -> a + is Y -> a + } +} + +fun problem(a: A): B { + return when (a) { + is X, is Y -> a + } +} diff --git a/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/smartcastToExhaustiveInterface.fir.txt b/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/smartcastToExhaustiveInterface.fir.txt new file mode 100644 index 00000000000..ef7d539c75e --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/smartcastToExhaustiveInterface.fir.txt @@ -0,0 +1,78 @@ +FILE: smartcastToExhaustiveInterface.kt + public sealed interface I1 : R|kotlin/Any| { + public abstract interface B : R|I1| { + } + + public abstract interface C : R|I1| { + } + + } + public sealed interface I2 : R|kotlin/Any| { + public abstract interface B : R|I2| { + } + + public abstract interface C : R|I2| { + } + + } + public final fun test_1(x: R|I1|): R|kotlin/Unit| { + lval a: R|kotlin/Int| = when (R|/x|) { + ($subj$ is R|I1.B|) -> { + Int(1) + } + ($subj$ is R|I1.C|) -> { + Int(1) + } + } + + R|kotlin/require|((R|/x| is R|I2|)) + lval b: R|kotlin/Int| = when (R|/x|) { + ($subj$ is R|I1.B|) -> { + Int(1) + } + ($subj$ is R|I1.C|) -> { + Int(1) + } + } + + lval c: R|kotlin/Int| = when (R|/x|) { + ($subj$ is R|I2.B|) -> { + Int(1) + } + ($subj$ is R|I2.C|) -> { + Int(1) + } + } + + } + public final fun test_2(x: R|kotlin/Any|): R|kotlin/Unit| { + R|kotlin/require|((R|/x| is R|I1|)) + lval a: R|kotlin/Int| = when (R|/x|) { + ($subj$ is R|I1.B|) -> { + Int(1) + } + ($subj$ is R|I1.C|) -> { + Int(1) + } + } + + R|kotlin/require|((R|/x| is R|I2|)) + lval b: R|kotlin/Int| = when (R|/x|) { + ($subj$ is R|I1.B|) -> { + Int(1) + } + ($subj$ is R|I1.C|) -> { + Int(1) + } + } + + lval c: R|kotlin/Int| = when (R|/x|) { + ($subj$ is R|I2.B|) -> { + Int(1) + } + ($subj$ is R|I2.C|) -> { + Int(1) + } + } + + } diff --git a/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/smartcastToExhaustiveInterface.kt b/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/smartcastToExhaustiveInterface.kt new file mode 100644 index 00000000000..b7000cf11d5 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/smartcastToExhaustiveInterface.kt @@ -0,0 +1,46 @@ +// WITH_STDLIB +// ISSUE: KT-47750 + +sealed interface I1 { + interface B : I1 + interface C : I1 +} + +sealed interface I2 { + interface B : I2 + interface C : I2 +} + +fun test_1(x: I1) { + val a = when (x) { + is I1.B -> 1 + is I1.C -> 1 + } + require(x is I2) + val b = when (x) { + is I1.B -> 1 + is I1.C -> 1 + } + + val c = when (x) { + is I2.B -> 1 + is I2.C -> 1 + } +} + +fun test_2(x: Any) { + require(x is I1) + val a = when (x) { + is I1.B -> 1 + is I1.C -> 1 + } + require(x is I2) + val b = when (x) { + is I1.B -> 1 + is I1.C -> 1 + } + val c = when (x) { + is I2.B -> 1 + is I2.C -> 1 + } +} diff --git a/compiler/fir/analysis-tests/testData/resolve/inference/builderInference/ifInBuildMap.fir.txt b/compiler/fir/analysis-tests/testData/resolve/inference/builderInference/ifInBuildMap.fir.txt new file mode 100644 index 00000000000..99a02b2f38a --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/inference/builderInference/ifInBuildMap.fir.txt @@ -0,0 +1,15 @@ +FILE: ifInBuildMap.kt + public final fun main(): R|kotlin/Unit| { + R|kotlin/collections/buildMap|( = buildMap@fun R|kotlin/collections/MutableMap|.(): R|kotlin/Unit| { + when () { + Boolean(true) -> { + R|kotlin/io/println|(String(test)) + } + else -> { + this@R|special/anonymous|.R|SubstitutionOverride|(String(foo), String(bar)) + } + } + + } + ) + } diff --git a/compiler/fir/analysis-tests/testData/resolve/inference/builderInference/ifInBuildMap.kt b/compiler/fir/analysis-tests/testData/resolve/inference/builderInference/ifInBuildMap.kt new file mode 100644 index 00000000000..b8c4ebc2474 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/inference/builderInference/ifInBuildMap.kt @@ -0,0 +1,12 @@ +// WITH_STDLIB +// ISSUE: KT-51143 + +fun main() { + buildMap { + if (true) { + println("test") + } else { + put("foo", "bar") + } + } +} diff --git a/compiler/fir/analysis-tests/testData/resolve/inference/javaCollector.fir.txt b/compiler/fir/analysis-tests/testData/resolve/inference/javaCollector.fir.txt new file mode 100644 index 00000000000..28aa3baf1ea --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/inference/javaCollector.fir.txt @@ -0,0 +1,7 @@ +FILE: javaCollector.kt + public final fun foo(): R|kotlin/Unit| { + R|kotlin/collections/listOf|(String()).R|SubstitutionOverride|>|().R|SubstitutionOverride|>|, kotlin/collections/Map<@EnhancedNullability kotlin/String!, kotlin/Int!>?>|, R|ft|>(Q|java/util/stream/Collectors|.R|java/util/stream/Collectors.groupingBy||, R|kotlin/Int!|>(groupingBy@fun (it: R|@EnhancedNullability kotlin/String!|): R|@EnhancedNullability kotlin/String!| { + ^ R|/it| + } + , Q|java/util/stream/Collectors|.R|java/util/stream/Collectors.collectingAndThen||, R|kotlin/Long!|, R|kotlin/Int!|>(Q|java/util/stream/Collectors|.R|java/util/stream/Collectors.counting|(), Q|kotlin/Long|::R|kotlin/Long.toInt|))) + } diff --git a/compiler/fir/analysis-tests/testData/resolve/inference/javaCollector.kt b/compiler/fir/analysis-tests/testData/resolve/inference/javaCollector.kt new file mode 100644 index 00000000000..742ac2cf01b --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/inference/javaCollector.kt @@ -0,0 +1,17 @@ +// ISSUE: KT-50134 +// WITH_STDLIB +// FULL_JDK + +import java.util.stream.Collectors + +fun foo(){ + listOf("").stream().collect( + Collectors.groupingBy( + { it }, + Collectors.collectingAndThen( + Collectors.counting(), + Long::toInt + ) + ) + ) +} diff --git a/compiler/fir/analysis-tests/testData/resolve/inference/kt53494.fir.txt b/compiler/fir/analysis-tests/testData/resolve/inference/kt53494.fir.txt new file mode 100644 index 00000000000..25893b73a87 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/inference/kt53494.fir.txt @@ -0,0 +1,57 @@ +FILE: kt53494.kt + public open class C : R|kotlin/Any| { + public constructor(): R|C| { + super() + } + + } + public final data class Wrapped : R|C| { + public constructor(value: R|T|): R|Wrapped| { + super|>() + } + + public final val value: R|T| = R|/value| + public get(): R|T| + + public final operator fun component1(): R|T| + + public final fun copy(value: R|T| = this@R|/Wrapped|.R|/Wrapped.value|): R|Wrapped| + + } + public final object Default : R|C| { + private constructor(): R|Default| { + super|>() + } + + } + public final inline fun test_1(t: R|T?|): R|C| { + when () { + !=(R|/t|, Null(null)) -> { + ^test_1 R|/Wrapped.Wrapped|(R|/t|) + } + } + + ^test_1 when () { + (R|/t| is R|T|) -> { + R|/Wrapped.Wrapped|(R|/t|) + } + else -> { + Q|Default| + } + } + + } + public final inline fun test_2(t: R|T?|): R|C| { + ^test_2 when () { + !=(R|/t|, Null(null)) -> { + R|/Wrapped.Wrapped|(R|/t|) + } + (R|/t| is R|T|) -> { + R|/Wrapped.Wrapped|(R|/t|) + } + else -> { + Q|Default| + } + } + + } diff --git a/compiler/fir/analysis-tests/testData/resolve/inference/kt53494.kt b/compiler/fir/analysis-tests/testData/resolve/inference/kt53494.kt new file mode 100644 index 00000000000..7e1249a5094 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/inference/kt53494.kt @@ -0,0 +1,14 @@ +// ISSUE: KT-53494 + +open class C +data class Wrapped(val value: T) : C() +object Default : C() + +inline fun test_1(t: T?): C { + if (t != null) return Wrapped(t) + return if (t is T) Wrapped(t) else Default +} + +inline fun test_2(t: T?): C { + return if (t != null) Wrapped(t) else if (t is T) Wrapped(t) else Default +} diff --git a/compiler/fir/analysis-tests/testData/resolve/inference/kt54990.fir.txt b/compiler/fir/analysis-tests/testData/resolve/inference/kt54990.fir.txt new file mode 100644 index 00000000000..e2a7429dea4 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/inference/kt54990.fir.txt @@ -0,0 +1,26 @@ +FILE: kt54990.kt + public final class A|> : R|kotlin/Any| { + public constructor|>(): R|A| { + super() + } + + } + public final class B : R|kotlin/Any| { + public constructor(): R|B| { + super() + } + + } + public final class C : R|kotlin/Any| { + public constructor(x: R|A>|): R|C| { + super() + } + + public final val x: R|A>| = R|/x| + public get(): R|A>| + + } + public final fun test(): R|kotlin/Unit| { + lval x: R|A>| = R|/A.A||>() + R|/C.C|(R|/x|) + } diff --git a/compiler/fir/analysis-tests/testData/resolve/inference/kt54990.kt b/compiler/fir/analysis-tests/testData/resolve/inference/kt54990.kt new file mode 100644 index 00000000000..0607bfccdcb --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/inference/kt54990.kt @@ -0,0 +1,10 @@ +// ISSUE: KT-54990 + +class A> +class B +class C(val x: A>) + +fun test() { + val x: A> = A() + C(x) +} diff --git a/compiler/fir/analysis-tests/testData/resolve/inference/kt55555.fir.txt b/compiler/fir/analysis-tests/testData/resolve/inference/kt55555.fir.txt new file mode 100644 index 00000000000..9c80a041c25 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/inference/kt55555.fir.txt @@ -0,0 +1,24 @@ +FILE: kt55555.kt + private abstract interface Foo : R|kotlin/Any| { + } + private final class Bar|> : R|kotlin/Any| { + public constructor|>(): R|Bar| { + super() + } + + } + private final fun bar(t: R|T|): R|Bar| { + ^bar Null(null)!! + } + private final fun foo(t: R|T|): R|T| { + lval map: R|Bar| = when () { + (R|/t| is R|Bar<*, *>|) -> { + (R|/t| as R|Bar|) + } + else -> { + R|/bar|(R|/t|) + } + } + + ^foo R|/t| + } diff --git a/compiler/fir/analysis-tests/testData/resolve/inference/kt55555.kt b/compiler/fir/analysis-tests/testData/resolve/inference/kt55555.kt new file mode 100644 index 00000000000..b0e923419e0 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/inference/kt55555.kt @@ -0,0 +1,14 @@ +// ISSUE: KT-55555 + +private interface Foo + +private class Bar> + +private fun bar(t: T): Bar = null!! + +private fun foo(t: T): T { + val map = + if (t is Bar<*, *>) t as Bar + else bar(t) + return t +} diff --git a/compiler/fir/analysis-tests/testData/resolve/inference/recursiveSelfTypes.fir.txt b/compiler/fir/analysis-tests/testData/resolve/inference/recursiveSelfTypes.fir.txt new file mode 100644 index 00000000000..552c8ff6c77 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/inference/recursiveSelfTypes.fir.txt @@ -0,0 +1,25 @@ +FILE: recursiveSelfTypes.kt + public abstract class Child|> : R|Parent, R>| { + public constructor|>(): R|Child| { + super() + } + + public final fun getParent(): R|Child| { + ^getParent (this@R|/Child|.R|SubstitutionOverride, R>|>|() as R|Child|) + } + + } + public abstract interface Parent

|> : R|kotlin/Any| { + public abstract fun self(): R|Parent| + + } + public abstract interface Parameter : R|kotlin/Any| { + } + public final class ChildParameter|> : R|Parameter| { + public constructor|>(): R|ChildParameter| { + super() + } + + } + public abstract interface Recursive|> : R|kotlin/Any| { + } diff --git a/compiler/fir/analysis-tests/testData/resolve/inference/recursiveSelfTypes.kt b/compiler/fir/analysis-tests/testData/resolve/inference/recursiveSelfTypes.kt new file mode 100644 index 00000000000..d8ae737124c --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/inference/recursiveSelfTypes.kt @@ -0,0 +1,15 @@ +// ISSUE: KT-52860 + +abstract class Child> : Parent, R> { + fun getParent(): Child = self() as Child +} + +interface Parent

> { + fun self(): Parent +} + +interface Parameter + +class ChildParameter> : Parameter + +interface Recursive> diff --git a/compiler/fir/analysis-tests/testData/resolve/inference/selfTypeFromJava.fir.txt b/compiler/fir/analysis-tests/testData/resolve/inference/selfTypeFromJava.fir.txt new file mode 100644 index 00000000000..8b0262e1804 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/inference/selfTypeFromJava.fir.txt @@ -0,0 +1,6 @@ +FILE: main.kt + public final fun main(): R|kotlin/Unit| { + lval a: R|ft, Java<*, kotlin/String!>?>| = Q|Java|.R|/Java.factory|(String()) + lval b: R|ft, Java<*, kotlin/String!>?>| = R|/a|.R|SubstitutionOverride|>|() + R|/b|.R|SubstitutionOverride|(String(testing)) + } diff --git a/compiler/fir/analysis-tests/testData/resolve/inference/selfTypeFromJava.kt b/compiler/fir/analysis-tests/testData/resolve/inference/selfTypeFromJava.kt new file mode 100644 index 00000000000..408154cdea9 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/inference/selfTypeFromJava.kt @@ -0,0 +1,22 @@ +// ISSUE: KT-48975 + +// FILE: Java.java +public class Java, ELEMENT> { + public static Java factory(E actual) { + return null; + } + + public SELF produceSelf() { + return null; + } + + public void consumeElement(ELEMENT values) {} +} + +// FILE: main.kt +fun main() { + val a = Java.factory("") + val b = a.produceSelf() + b.consumeElement("testing") +} + diff --git a/compiler/fir/analysis-tests/testData/resolve/problems/classLiteralWithExclExcl.fir.txt b/compiler/fir/analysis-tests/testData/resolve/problems/classLiteralWithExclExcl.fir.txt new file mode 100644 index 00000000000..e9db1241291 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/problems/classLiteralWithExclExcl.fir.txt @@ -0,0 +1,9 @@ +FILE: classLiteralWithExclExcl.kt + public final class B : R|kotlin/Any| { + public constructor(): R|B| { + super() + } + + } + public final val any2: R|kotlin/reflect/KClass| = (Q|B|!!.#<>) + public get(): R|kotlin/reflect/KClass| diff --git a/compiler/fir/analysis-tests/testData/resolve/problems/classLiteralWithExclExcl.kt b/compiler/fir/analysis-tests/testData/resolve/problems/classLiteralWithExclExcl.kt new file mode 100644 index 00000000000..93615fb4981 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/problems/classLiteralWithExclExcl.kt @@ -0,0 +1,4 @@ +// ISSUE: KT-47373 + +class B +val any2 = B!!<T>::class diff --git a/compiler/fir/analysis-tests/testData/resolve/problems/invalidCode.fir.txt b/compiler/fir/analysis-tests/testData/resolve/problems/invalidCode.fir.txt new file mode 100644 index 00000000000..b2214997a62 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/problems/invalidCode.fir.txt @@ -0,0 +1,73 @@ +FILE: a.kt + package a + + @R|kotlin/Suppress|() FILE: b.kt + package b + + public abstract interface I : R|kotlin/Any| { + public open fun f(): { + ^f ERROR_EXPR(The expression cannot be a selector (occur after a dot))String() + } + + public final class C : R|b/I| { + public constructor(): R|b/I.C| { + super() + } + + } + + } +FILE: c.kt + package c + + public abstract interface I : R|kotlin/Any| { + public open fun f(x: R|T?|): R|T| { + ^f R|/x| ?: String(OK).#()?.{ $subj$.#(Char(61334), R|c/C.C|().R|c/I.f#|(Int(-62))) }!! + } + + } + public final class C : R|c/I| { + public constructor(): R|c/C| { + super() + } + + } + public final fun box(): R|kotlin/String| { + ^box R|c/C.C|().R|c/I.f|(Null(null)) + } +FILE: d.kt + package d + + public abstract interface I : R|kotlin/Any| { + public open fun f(): { + ^f R|d/I.C.C#|(ERROR_EXPR(Argument is absent)).R|d/I.f#|<>(ERROR_EXPR(No right operand)) + } + + public final class C : R|d/I| { + public constructor(): R|d/I.C| { + super() + } + + } + + } +FILE: e.kt + package e + + public final class A : R|kotlin/Any| { + public constructor(): R|e/A| { + super() + } + + public final var bar: = R|e/A.EmptyContinuation.EmptyContinuation#|(ERROR_EXPR(Argument is absent)).#(ERROR_EXPR(No right operand)) + public get(): + public set(value: ): R|kotlin/Unit| + + public final class EmptyContinuation : R|e/A| { + public constructor(): R|e/A.EmptyContinuation| { + super|>() + } + + } + + } diff --git a/compiler/fir/analysis-tests/testData/resolve/problems/invalidCode.kt b/compiler/fir/analysis-tests/testData/resolve/problems/invalidCode.kt new file mode 100644 index 00000000000..82ae99940af --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/problems/invalidCode.kt @@ -0,0 +1,50 @@ +// ISSUE: KT-47484, KT-47495 + +// FILE: a.kt +package a + +@ +:Suppress(receiver = iterator + +// FILE: b.kt +package b + +interface I { + fun f = "". + (C().f + class C : I + +// FILE: c.kt +package c + +import kotlin.properties.* +import kotlin.reflect.* +import kotlin.math.* +interface I { + fun String> f(x: T?) = x ?: "OK".strip()?.substringBeforeLast('î¾–', C().f<Long>(-62))!! +} + +class C : I + +fun box() = C().f(null) + +// FILE: d.kt +package d + +interface I { + fun f = C( + .f + class C : I + +// FILE: e.kt +package e + +class A +{ + + var bar = EmptyContinuation( + .bar + + class EmptyContinuation : A< diff --git a/compiler/fir/analysis-tests/testData/resolve/problems/typeArgumentsOnThis.fir.txt b/compiler/fir/analysis-tests/testData/resolve/problems/typeArgumentsOnThis.fir.txt new file mode 100644 index 00000000000..9f7fb484eb4 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/problems/typeArgumentsOnThis.fir.txt @@ -0,0 +1,6 @@ +FILE: typeArgumentsOnThis.kt + public final fun x(): R|kotlin/Unit| { + this#.#<>::# + } + public final val a: = this#.#<>::# + public get(): diff --git a/compiler/fir/analysis-tests/testData/resolve/problems/typeArgumentsOnThis.kt b/compiler/fir/analysis-tests/testData/resolve/problems/typeArgumentsOnThis.kt new file mode 100644 index 00000000000..ce5097e1f97 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/problems/typeArgumentsOnThis.kt @@ -0,0 +1,7 @@ +// ISSUE: KT-24737 + +fun x(){ + this<X>::y +} + +val a = this<X>::y diff --git a/compiler/fir/analysis-tests/testData/resolve/properties/assignToStarProjectedType.fir.txt b/compiler/fir/analysis-tests/testData/resolve/properties/assignToStarProjectedType.fir.txt new file mode 100644 index 00000000000..500c0093dc7 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/properties/assignToStarProjectedType.fir.txt @@ -0,0 +1,44 @@ +FILE: assignToStarProjectedType.kt + public final class Inv : R|kotlin/Any| { + public constructor(): R|Inv| { + super() + } + + } + public final fun invOf(): R|Inv| { + ^invOf R|/Inv.Inv|() + } + public abstract class Base : R|kotlin/Any| { + public constructor(): R|Base| { + super() + } + + public final var foo: R|Inv?| = R|/invOf|() + public get(): R|Inv?| + public set(value: R|Inv?|): R|kotlin/Unit| + + } + public final class Bar : R|Base| { + public constructor(): R|Bar| { + super|>() + } + + } + public final fun test_1(): R|kotlin/Unit| { + lval x: R|Bar| = R|/Bar.Bar|() + R|/x|.R|SubstitutionOverride?|>| = R|/invOf|() + R|/x|.R|SubstitutionOverride?|>| = Null(null) + } + public final fun test_2(x: R|Base<*>|): R|kotlin/Unit| { + R|/x|.R|SubstitutionOverride?|>| = R|/invOf#|<>() + R|/x|.R|SubstitutionOverride?|>| = Null(null) + } + public final fun test_3(x: R|kotlin/Any|): R|kotlin/Unit| { + when () { + (R|/x| is R|Base<*>|) -> { + R|/x|.R|SubstitutionOverride?|>| = R|/invOf#|<>() + R|/x|.R|SubstitutionOverride?|>| = Null(null) + } + } + + } diff --git a/compiler/fir/analysis-tests/testData/resolve/properties/assignToStarProjectedType.kt b/compiler/fir/analysis-tests/testData/resolve/properties/assignToStarProjectedType.kt new file mode 100644 index 00000000000..099a710d64b --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/properties/assignToStarProjectedType.kt @@ -0,0 +1,28 @@ +// ISSUE: KT-51045 + +class Inv +fun invOf(): Inv = Inv() + +abstract class Base { + final var foo: Inv? = invOf() +} + +class Bar : Base() + +fun test_1() { + val x = Bar() + x.foo = invOf() + x.foo = null +} + +fun test_2(x: Base<*>) { + x.foo = invOf() + x.foo = null +} + +fun test_3(x: Any) { + if (x is Base<*>) { + x.foo = invOf() + x.foo = null + } +} diff --git a/compiler/fir/analysis-tests/testData/resolve/references/ambigousParenthesizedReference.fir.txt b/compiler/fir/analysis-tests/testData/resolve/references/ambigousParenthesizedReference.fir.txt new file mode 100644 index 00000000000..00da7334bfa --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/references/ambigousParenthesizedReference.fir.txt @@ -0,0 +1,6 @@ +FILE: ambigousParenthesizedReference.kt + public final fun consume(x: R|kotlin/Any?|): R|kotlin/Unit| { + } + public final fun box(): R|kotlin/Unit| { + ^box R|/consume|(Q|kotlin/Int|::#) + } diff --git a/compiler/fir/analysis-tests/testData/resolve/references/ambigousParenthesizedReference.kt b/compiler/fir/analysis-tests/testData/resolve/references/ambigousParenthesizedReference.kt new file mode 100644 index 00000000000..ab887e10b0d --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/references/ambigousParenthesizedReference.kt @@ -0,0 +1,5 @@ +// ISSUE: KT-36958 + +fun consume(x: Any?) {} + +fun box() = consume((Int::plus)) diff --git a/compiler/fir/analysis-tests/testData/resolve/references/incorrectReferenceOnInnerClassMember.fir.txt b/compiler/fir/analysis-tests/testData/resolve/references/incorrectReferenceOnInnerClassMember.fir.txt new file mode 100644 index 00000000000..bd75a97b793 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/references/incorrectReferenceOnInnerClassMember.fir.txt @@ -0,0 +1,23 @@ +FILE: incorrectReferenceOnInnerClassMember.kt + package foo + + public final class Outer : R|kotlin/Any| { + public constructor(): R|foo/Outer| { + super() + } + + public final inner class Inner : R|kotlin/Any| { + public foo/Outer.constructor(): R|foo/Outer.Inner| { + super() + } + + public final fun method(): R|kotlin/Unit| { + } + + } + + } + public final fun test(): R|kotlin/Unit| { + Q|foo/Outer|.#(Int(42)) + Q|foo/Outer|.#(Int(42))::# + } diff --git a/compiler/fir/analysis-tests/testData/resolve/references/incorrectReferenceOnInnerClassMember.kt b/compiler/fir/analysis-tests/testData/resolve/references/incorrectReferenceOnInnerClassMember.kt new file mode 100644 index 00000000000..19068dc670d --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/references/incorrectReferenceOnInnerClassMember.kt @@ -0,0 +1,14 @@ +// ISSUE: KT-37365 + +package foo + +class Outer { + inner class Inner { + fun method() {} + } +} + +fun test() { + foo.Outer.Inner(42) + foo.Outer.Inner(42)::method +} diff --git a/compiler/fir/analysis-tests/testData/resolve/references/referenceToSyntheticJavaPropertyWithProjection.fir.txt b/compiler/fir/analysis-tests/testData/resolve/references/referenceToSyntheticJavaPropertyWithProjection.fir.txt new file mode 100644 index 00000000000..e9d259ed3e8 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/references/referenceToSyntheticJavaPropertyWithProjection.fir.txt @@ -0,0 +1,14 @@ +FILE: main.kt + public final class KotlinInv : R|kotlin/Any| { + public constructor(): R|KotlinInv| { + super() + } + + public final val stringVal: R|kotlin/String| = String() + public get(): R|kotlin/String| + + } + public final fun test(): R|kotlin/Unit| { + Q|JavaInv|::R|/JavaInv.stringVal| + Q|KotlinInv|::R|SubstitutionOverride| + } diff --git a/compiler/fir/analysis-tests/testData/resolve/references/referenceToSyntheticJavaPropertyWithProjection.kt b/compiler/fir/analysis-tests/testData/resolve/references/referenceToSyntheticJavaPropertyWithProjection.kt new file mode 100644 index 00000000000..d8fd8f5c1ff --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/references/referenceToSyntheticJavaPropertyWithProjection.kt @@ -0,0 +1,17 @@ +// ISSUE: KT-56243 + +// FILE: JavaInv.java +public class JavaInv { + public String getStringVal() { return "OK"; } +} + +// FILE: main.kt + +class KotlinInv { + val stringVal: String = "" +} + +fun test() { + JavaInv::stringVal + KotlinInv::stringVal +} diff --git a/compiler/fir/analysis-tests/testData/resolve/references/unresovledReferenceInFinally.fir.txt b/compiler/fir/analysis-tests/testData/resolve/references/unresovledReferenceInFinally.fir.txt new file mode 100644 index 00000000000..217678b6ea7 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/references/unresovledReferenceInFinally.fir.txt @@ -0,0 +1,12 @@ +FILE: unresovledReferenceInFinally.kt + public final fun test(): R|kotlin/Unit| { + String(1234).R|kotlin/apply|( = apply@fun R|kotlin/String|.(): R|kotlin/Unit| { + try { + } + finally { + ::# + } + + } + ) + } diff --git a/compiler/fir/analysis-tests/testData/resolve/references/unresovledReferenceInFinally.kt b/compiler/fir/analysis-tests/testData/resolve/references/unresovledReferenceInFinally.kt new file mode 100644 index 00000000000..84ff6f2b2b2 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/references/unresovledReferenceInFinally.kt @@ -0,0 +1,10 @@ +// ISSUE: KT-47490 + +fun test() { + "1234".apply { + try { + } finally { + ::fu1 + } + } +} diff --git a/compiler/fir/analysis-tests/testData/resolve/returnFromDelegatedConstuctor.fir.txt b/compiler/fir/analysis-tests/testData/resolve/returnFromDelegatedConstuctor.fir.txt new file mode 100644 index 00000000000..bfd397aab15 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/returnFromDelegatedConstuctor.fir.txt @@ -0,0 +1,38 @@ +FILE: returnFromDelegatedConstuctor.kt + public final data class StringPair : R|kotlin/Any| { + public constructor(a: R|kotlin/String|, b: R|kotlin/String|): R|StringPair| { + super() + } + + public final val a: R|kotlin/String| = R|/a| + public get(): R|kotlin/String| + + public final val b: R|kotlin/String| = R|/b| + public get(): R|kotlin/String| + + public constructor(): R|StringPair| { + this(^ Unit, ^ Unit) + } + + public final operator fun component1(): R|kotlin/String| + + public final operator fun component2(): R|kotlin/String| + + public final fun copy(a: R|kotlin/String| = this@R|/StringPair|.R|/StringPair.a|, b: R|kotlin/String| = this@R|/StringPair|.R|/StringPair.b|): R|StringPair| + + } + public abstract class Abs : R|kotlin/Any| { + public constructor(a: R|kotlin/String|): R|Abs| { + super() + } + + public final val a: R|kotlin/String| = R|/a| + public get(): R|kotlin/String| + + } + public final class Smth : R|Abs| { + public constructor(): R|Smth| { + super(^ Unit) + } + + } diff --git a/compiler/fir/analysis-tests/testData/resolve/returnFromDelegatedConstuctor.kt b/compiler/fir/analysis-tests/testData/resolve/returnFromDelegatedConstuctor.kt new file mode 100644 index 00000000000..660d5974407 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/returnFromDelegatedConstuctor.kt @@ -0,0 +1,10 @@ +// ISSUE: KT-24503 +data class StringPair(val a: String, val b: String) { + constructor() : this(return, return) +} + +abstract class Abs(val a: String) + +class Smth : Abs { + constructor() : super(return) +} diff --git a/compiler/fir/analysis-tests/testData/resolve/samConversions/nothingVararg.fir.txt b/compiler/fir/analysis-tests/testData/resolve/samConversions/nothingVararg.fir.txt new file mode 100644 index 00000000000..4bccc6965b2 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/samConversions/nothingVararg.fir.txt @@ -0,0 +1,7 @@ +FILE: main.kt + public final fun test(x: R|A<*>|): R|kotlin/Unit| { + R|/x|.R|SubstitutionOverride|(vararg(call@fun (y: R|kotlin/Any?|): R|kotlin/Unit| { + Q|kotlin/Unit| + } + )) + } diff --git a/compiler/fir/analysis-tests/testData/resolve/samConversions/nothingVararg.kt b/compiler/fir/analysis-tests/testData/resolve/samConversions/nothingVararg.kt new file mode 100644 index 00000000000..cf89ea1d76c --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/samConversions/nothingVararg.kt @@ -0,0 +1,16 @@ +// ISSUE: KT-41721 + +// FILE: SAM.java +public interface SAM { + void apply(T x); +} + +// FILE: A.java +public class A { + public void call(SAM... block) { block[0].apply(null); } +} + +// FILE: main.kt +fun test(x: A<*>) { + x.call({ y: Any? -> Unit }) +} diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/assignToBoundSmartcastedVariable.fir.txt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/assignToBoundSmartcastedVariable.fir.txt new file mode 100644 index 00000000000..b91c7e8d0b7 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/assignToBoundSmartcastedVariable.fir.txt @@ -0,0 +1,23 @@ +FILE: assignToBoundSmartcastedVariable.kt + public abstract interface A : R|kotlin/Any| { + } + public abstract interface B : R|kotlin/Any| { + public abstract fun fooB(x: R|kotlin/Int|): R|kotlin/String| + + } + public final class Foo : R|kotlin/Any| { + public constructor(): R|Foo| { + super() + } + + } + public final fun test(ab: R|A|): R|kotlin/Unit| { + when () { + (R|/ab| is R|B|) -> { + lvar z: R|it(B & A)| = R|/id|(R|/ab|) + R|/z| = R|/Foo.Foo#|() + R|/z|.R|/B.fooB|(Int(1)) + } + } + + } diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/assignToBoundSmartcastedVariable.kt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/assignToBoundSmartcastedVariable.kt new file mode 100644 index 00000000000..95ace7db607 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/assignToBoundSmartcastedVariable.kt @@ -0,0 +1,17 @@ +// ISSUE: KT-53752 +// INFERENCE_HELPERS + +interface A +interface B { + fun fooB(x: Int): String +} + +class Foo + +fun test(ab: A) { + if (ab is B) { + var z = id(ab) // materialize smartcast + z = Foo() // unsafe assignment + z.fooB(1) + } +} diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/boundSmartcastWithProjection.fir.txt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/boundSmartcastWithProjection.fir.txt new file mode 100644 index 00000000000..522f519dfa2 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/boundSmartcastWithProjection.fir.txt @@ -0,0 +1,28 @@ +FILE: boundSmartcastWithProjection.kt + public final class Inv : R|kotlin/Any| { + public constructor(data: R|T|): R|Inv| { + super() + } + + public final val data: R|T| = R|/data| + public get(): R|T| + + } + public final fun test1(x: R|Inv|): R|kotlin/Unit| { + lval y: R|kotlin/String?| = R|/x|.R|SubstitutionOverride| + when (R|/y|) { + ($subj$ is R|kotlin/String|) -> { + R|/x|.R|SubstitutionOverride|.R|kotlin/String.length| + } + } + + } + public final fun test2(x: R|Inv|): R|kotlin/Unit| { + lval y: R|kotlin/Any?| = R|/x|.R|SubstitutionOverride| + when (R|/y|) { + ($subj$ is R|kotlin/String|) -> { + R|/x|.R|SubstitutionOverride|.R|kotlin/String.length| + } + } + + } diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/boundSmartcastWithProjection.kt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/boundSmartcastWithProjection.kt new file mode 100644 index 00000000000..b8f970c322b --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/boundSmartcastWithProjection.kt @@ -0,0 +1,17 @@ +// ISSUE: KT-24779 + +class Inv(val data: T) + +fun test1(x: Inv) { + val y = x.data + when (y) { + is String -> x.data.length // Smart cast: x.data is String + } +} + +fun test2(x: Inv) { + val y = x.data + when (y) { + is String -> x.data.length // No smart cast, UNRESOLVED_REFERENCE: length + } +} diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/contractSafeCall.fir.txt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/contractSafeCall.fir.txt new file mode 100644 index 00000000000..7346d265e1c --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/contractSafeCall.fir.txt @@ -0,0 +1,10 @@ +FILE: contractSafeCall.kt + public final fun test(list: R|kotlin/collections/List?|): R|kotlin/Unit| { + when () { + ==(R|/list|?.{ $subj$.R|kotlin/collections/isNullOrEmpty|() }, Boolean(true)) -> { + ^test Unit + } + } + + R|/list|.R|SubstitutionOverride#| + } diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/contractSafeCall.kt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/contractSafeCall.kt new file mode 100644 index 00000000000..38a025dd274 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/contractSafeCall.kt @@ -0,0 +1,9 @@ +// ISSUE: KT-51796 +// WITH_STDLIB + +fun test(list: List?) { + if (list?.isNullOrEmpty() == true) { + return + } + list.size // should be unsafe call +} diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures/earlyReturnInNonExhaustiveWhen.fir.txt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures/earlyReturnInNonExhaustiveWhen.fir.txt new file mode 100644 index 00000000000..09cfa5a4bd1 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures/earlyReturnInNonExhaustiveWhen.fir.txt @@ -0,0 +1,16 @@ +FILE: earlyReturnInNonExhaustiveWhen.kt + public final fun foo(str: R|kotlin/String?|): R|kotlin/Int| { + when () { + ==(R|/str|, Null(null)) -> { + ^foo Int(-1) + } + } + + when () { + ==(R|/str|.R|kotlin/String.length|, Int(123)) -> { + ^foo Int(123) + } + } + + ^foo Int(321) + } diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures/earlyReturnInNonExhaustiveWhen.kt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures/earlyReturnInNonExhaustiveWhen.kt new file mode 100644 index 00000000000..c1f320caa07 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures/earlyReturnInNonExhaustiveWhen.kt @@ -0,0 +1,10 @@ +// ISSUE: KT-24901 + +fun foo(str: String?): Int { + when { + str == null -> return -1 + } + if (str.length == 123) + return 123 + return 321 +} diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures/returnFromWhen.fir.txt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures/returnFromWhen.fir.txt new file mode 100644 index 00000000000..cb439d138c4 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures/returnFromWhen.fir.txt @@ -0,0 +1,19 @@ +FILE: returnFromWhen.kt + public final fun test_1(name: R|kotlin/String?|): R|kotlin/Unit| { + when (R|/name|) { + ==($subj$, Null(null)) -> { + ^test_1 Unit + } + } + + R|/name|.R|kotlin/String.length| + } + public final fun test_2(name: R|kotlin/String?|): R|kotlin/Unit| { + when (lval s: R|kotlin/String?| = R|/name|) { + ==($subj$, Null(null)) -> { + ^test_2 Unit + } + } + + R|/name|.R|kotlin/String.length| + } diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures/returnFromWhen.kt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures/returnFromWhen.kt new file mode 100644 index 00000000000..c40f226caf5 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures/returnFromWhen.kt @@ -0,0 +1,15 @@ +// ISSUE: KT-52262 + +fun test_1(name: String?) { + when (name) { + null -> return + } + name.length +} + +fun test_2(name: String?) { + when (val s = name) { + null -> return + } + name.length +} diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/loops/elvisAtTheEndOfLoop.fir.txt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/loops/elvisAtTheEndOfLoop.fir.txt new file mode 100644 index 00000000000..6d383205445 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/loops/elvisAtTheEndOfLoop.fir.txt @@ -0,0 +1,68 @@ +FILE: elvisAtTheEndOfLoop.kt + public final fun condition(): R|kotlin/Boolean| { + ^condition Boolean(true) + } + public final fun test_1(x: R|kotlin/String?|): R|kotlin/Unit| { + do { + R|/x| ?: ^test_1 Unit + } + while(R|/condition|()) + R|/x|.R|kotlin/String.length| + } + public final fun test_2(x: R|kotlin/String?|): R|kotlin/Unit| { + do { + R|/x| ?: R|/x|!! + } + while(R|/condition|()) + R|/x|.R|kotlin/String.length| + } + public final fun test_3(): R|kotlin/Unit| { + lvar a: R|kotlin/String?| = Null(null) + while(R|/condition|()) { + R|/a| ?: ^test_3 Unit + } + + R|/a|.R|kotlin/String.length#| + } + public final fun test_4(): R|kotlin/Unit| { + lvar a: R|kotlin/String?| = Null(null) + while(Boolean(true)) { + R|/a| ?: ^test_4 Unit + } + + R|/a|.R|kotlin/String.length#| + } + public final fun test_5(x: R|kotlin/String?|): R|kotlin/Unit| { + do { + R|/x| ?: ^test_5 Unit + Q|kotlin/Unit| + } + while(R|/condition|()) + R|/x|.R|kotlin/String.length| + } + public final fun test_6(x: R|kotlin/String?|): R|kotlin/Unit| { + do { + R|/x| ?: R|/x|!! + Q|kotlin/Unit| + } + while(R|/condition|()) + R|/x|.R|kotlin/String.length| + } + public final fun test_7(): R|kotlin/Unit| { + lvar a: R|kotlin/String?| = Null(null) + while(R|/condition|()) { + R|/a| ?: ^test_7 Unit + R|/a| + } + + R|/a|.R|kotlin/String.length#| + } + public final fun test_8(): R|kotlin/Unit| { + lvar a: R|kotlin/String?| = Null(null) + while(Boolean(true)) { + R|/a| ?: ^test_8 Unit + R|/a| + } + + R|/a|.R|kotlin/String.length#| + } diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/loops/elvisAtTheEndOfLoop.kt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/loops/elvisAtTheEndOfLoop.kt new file mode 100644 index 00000000000..6ca801c7658 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/loops/elvisAtTheEndOfLoop.kt @@ -0,0 +1,79 @@ +// ISSUE: KT-30756 + +fun condition(): Boolean = true + +fun test_1(x: String?) { + do { + x ?: return + } while(condition()) + + x.length +} + +fun test_2(x: String?) { + do { + x ?: x!! + } while(condition()) + + x.length +} + +fun test_3() { + var a: String? = null + + while (condition()) { + a ?: return + } + + a.length +} + +fun test_4() { + var a: String? = null + + while (true) { + a ?: return + } + + a.length +} + +fun test_5(x: String?) { + do { + x ?: return + Unit + } while(condition()) + + x.length +} + +fun test_6(x: String?) { + do { + x ?: x!! + Unit + } while(condition()) + + x.length +} + +fun test_7() { + var a: String? = null + + while (condition()) { + a ?: return + a + } + + a.length +} + +fun test_8() { + var a: String? = null + + while (true) { + a ?: return + a + } + + a.length +} diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/problems/noSmartcastToNullableNothing.fir.txt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/problems/noSmartcastToNullableNothing.fir.txt new file mode 100644 index 00000000000..6a0820d22b5 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/problems/noSmartcastToNullableNothing.fir.txt @@ -0,0 +1,19 @@ +FILE: noSmartcastToNullableNothing.kt + public abstract interface A : R|kotlin/Any| { + } + public final fun foo(testFun: R|((kotlin/Int) -> kotlin/Unit)?|, anyInterface: R|A?|): R|kotlin/Unit| { + } + public final fun test(x: R|kotlin/Int?|): R|kotlin/Unit| { + R|/foo#|(when () { + !=(R|/x|, Null(null)) -> { + foo@fun (it: R|kotlin/Int|): R|kotlin/Unit| { + Int(0) + } + + } + else -> { + Null(null) + } + } + , R|/x|) + } diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/problems/noSmartcastToNullableNothing.kt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/problems/noSmartcastToNullableNothing.kt new file mode 100644 index 00000000000..3bd5a82fb5d --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/problems/noSmartcastToNullableNothing.kt @@ -0,0 +1,12 @@ +// ISSUE: KT-52424 + +interface A + +fun foo(testFun: ((Int) -> Unit)?, anyInterface: A?) {} + +fun test(x: Int?) { + foo( + if (x != null) { { 0 } } else null, + x // should be no smartcast to Nothing? + ) +} diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastOnFunctionalType.fir.txt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastOnFunctionalType.fir.txt new file mode 100644 index 00000000000..ea652f7d839 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastOnFunctionalType.fir.txt @@ -0,0 +1,52 @@ +FILE: smartcastOnFunctionalType.kt + public final class MyClass : R|kotlin/Any| { + public constructor(provider: R|(() -> kotlin/String)?|): R|MyClass| { + super() + } + + public final val provider: R|(() -> kotlin/String)?| = R|/provider| + public get(): R|(() -> kotlin/String)?| + + public final fun foo(): R|kotlin/Unit| { + when () { + !=(this@R|/MyClass|.R|/MyClass.provider|, Null(null)) -> { + this@R|/MyClass|.R|/MyClass.bar|(this@R|/MyClass|.R|/MyClass.provider|.R|SubstitutionOverride|()) + } + } + + } + + public final fun bar(s: R|kotlin/String|): R|kotlin/Unit| { + } + + } + public final class Test : R|kotlin/Any| { + public constructor(): R|Test| { + super() + } + + public final val nullableCheckBox: R|B?| = Null(null) + public get(): R|B?| + + public final fun fail(): R|kotlin/Unit| { + when () { + !=(this@R|/Test|.R|/Test.nullableCheckBox|, Null(null)) -> { + this@R|/Test|.R|kotlin/run|( = run@fun R|Test|.(): R|kotlin/Unit| { + this@R|/Test|.R|/Test.nullableCheckBox|.R|/invoke|() + } + ) + } + } + + } + + } + public final class B : R|kotlin/Any| { + public constructor(): R|B| { + super() + } + + } + public final operator fun R|B|.invoke(): R|kotlin/Unit| { + ^invoke R|kotlin/TODO|() + } diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastOnFunctionalType.kt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastOnFunctionalType.kt new file mode 100644 index 00000000000..28f42e0191f --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastOnFunctionalType.kt @@ -0,0 +1,24 @@ +// ISSUE: KT-4113 + +class MyClass(val provider: (() -> String)?) { + fun foo() { + if (provider != null) + // NI: [UNSAFE_CALL] Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type (() -> String)? + // OI: [UNSAFE_IMPLICIT_INVOKE_CALL] Reference has a nullable type '(() -> String)?', use explicit '?.invoke()' to make a function-like call instead + bar(provider()) + } + + fun bar(s: String) { + } +} + +class Test { + val nullableCheckBox: B? = null + fun fail() { + if (nullableCheckBox != null) { + run { nullableCheckBox() } + } + } +} +class B +operator fun B.invoke(): Unit = TODO() diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToStarProjectedType.fir.txt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToStarProjectedType.fir.txt new file mode 100644 index 00000000000..5bd613074f8 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToStarProjectedType.fir.txt @@ -0,0 +1,101 @@ +FILE: smartcastToStarProjectedType.kt + public final data class NodePropertyDescriptor : R|kotlin/Any| { + public constructor(description: R|kotlin/String|, propertyRef: R|NodePropertyRef|): R|NodePropertyDescriptor| { + super() + } + + public final val description: R|kotlin/String| = R|/description| + public get(): R|kotlin/String| + + public final val propertyRef: R|NodePropertyRef| = R|/propertyRef| + public get(): R|NodePropertyRef| + + public final fun test_1(other: R|kotlin/Any?|): R|kotlin/Boolean| { + when () { + (R|/other| !is R|NodePropertyDescriptor<*, *, *>|) -> { + ^test_1 Boolean(false) + } + } + + when () { + !=(this@R|/NodePropertyDescriptor|.R|/NodePropertyDescriptor.description|, R|/other|.R|SubstitutionOverride|) -> { + ^test_1 Boolean(false) + } + } + + when () { + !=(this@R|/NodePropertyDescriptor|.R|/NodePropertyDescriptor.propertyRef|, R|/other|.R|SubstitutionOverride|>|) -> { + ^test_1 Boolean(false) + } + } + + ^test_1 Boolean(true) + } + + public final fun test_2(other: R|kotlin/Any?|): R|kotlin/Boolean| { + when () { + (R|/other| !is R|NodePropertyDescriptor<*, *, *>|) -> { + ^test_2 Boolean(false) + } + } + + when () { + (R|/other| is R|NodePropertyDescriptor<*, *, *>|) -> { + when () { + !=(this@R|/NodePropertyDescriptor|.R|/NodePropertyDescriptor.description|, R|/other|.R|SubstitutionOverride|) -> { + ^test_2 Boolean(false) + } + } + + when () { + !=(this@R|/NodePropertyDescriptor|.R|/NodePropertyDescriptor.propertyRef|, R|/other|.R|SubstitutionOverride|>|) -> { + ^test_2 Boolean(false) + } + } + + } + } + + ^test_2 Boolean(true) + } + + public final fun test_3(other: R|kotlin/Any?|): R|kotlin/Boolean| { + when () { + (R|/other| is R|NodePropertyDescriptor<*, *, *>|) -> { + when () { + !=(this@R|/NodePropertyDescriptor|.R|/NodePropertyDescriptor.description|, R|/other|.R|SubstitutionOverride|) -> { + ^test_3 Boolean(false) + } + } + + when () { + !=(this@R|/NodePropertyDescriptor|.R|/NodePropertyDescriptor.propertyRef|, R|/other|.R|SubstitutionOverride|>|) -> { + ^test_3 Boolean(false) + } + } + + } + } + + ^test_3 Boolean(true) + } + + public final operator fun component1(): R|kotlin/String| + + public final operator fun component2(): R|NodePropertyRef| + + public final fun copy(description: R|kotlin/String| = this@R|/NodePropertyDescriptor|.R|/NodePropertyDescriptor.description|, propertyRef: R|NodePropertyRef| = this@R|/NodePropertyDescriptor|.R|/NodePropertyDescriptor.propertyRef|): R|NodePropertyDescriptor| + + } + public final class NodePropertyRef : R|kotlin/Any| { + public constructor(): R|NodePropertyRef| { + super() + } + + } + public open class Node : R|kotlin/Any| { + public constructor(): R|Node| { + super() + } + + } diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToStarProjectedType.kt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToStarProjectedType.kt new file mode 100644 index 00000000000..074e8fa6861 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToStarProjectedType.kt @@ -0,0 +1,35 @@ +// ISSUE: KT-42449 + +data class NodePropertyDescriptor( + val description: String, + val propertyRef: NodePropertyRef, +) { + fun test_1(other: Any?): Boolean { + if (other !is NodePropertyDescriptor<*, *, *>) return false + if (description != other.description) return false + if (propertyRef != other.propertyRef) return false + return true + } + + fun test_2(other: Any?): Boolean { + if (other !is NodePropertyDescriptor<*, *, *>) return false + if (other is NodePropertyDescriptor<*, *, *>) { + if (description != other.description) return false + if (propertyRef != other.propertyRef) return false + } + return true + } + + fun test_3(other: Any?): Boolean { + if (other is NodePropertyDescriptor<*, *, *>) { + if (description != other.description) return false + if (propertyRef != other.propertyRef) return false + } + return true + } + +} + +class NodePropertyRef + +open class Node diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/typeOfLambdaWithSmartcast.fir.txt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/typeOfLambdaWithSmartcast.fir.txt new file mode 100644 index 00000000000..60126228c32 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/typeOfLambdaWithSmartcast.fir.txt @@ -0,0 +1,29 @@ +FILE: typeOfLambdaWithSmartcast.kt + public final fun test_1(): R|kotlin/Unit| { + lval f: R|(kotlin/String?) -> kotlin/String| = l@fun (it: R|kotlin/String?|): R|kotlin/String| { + when () { + !=(R|/it|, Null(null)) -> { + ^@l R|/it| + } + } + + ^ String() + } + + R|/f|.R|SubstitutionOverride|(String()).R|kotlin/String.length| + } + public final fun test_2(): R|kotlin/Unit| { + lval f: R|(kotlin/String?) -> kotlin/String| = l@fun (it: R|kotlin/String?|): R|kotlin/String| { + ^ when () { + !=(R|/it|, Null(null)) -> { + R|/it| + } + else -> { + String() + } + } + + } + + R|/f|.R|SubstitutionOverride|(String()).R|kotlin/String.length| + } diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/typeOfLambdaWithSmartcast.kt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/typeOfLambdaWithSmartcast.kt new file mode 100644 index 00000000000..ce29ffaf42c --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/typeOfLambdaWithSmartcast.kt @@ -0,0 +1,18 @@ +// ISSUE: KT-6822 + +fun test_1() { + val f = l@{ it: String? -> + if (it != null) return@l it + "" + } + + f("").length +} + +fun test_2() { + val f = l@ { it: String? -> + if (it != null) it + else "" + } + f("").length +} diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/valCapturedInLambda.fir.txt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/valCapturedInLambda.fir.txt new file mode 100644 index 00000000000..6b5cea060a0 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/valCapturedInLambda.fir.txt @@ -0,0 +1,27 @@ +FILE: valCapturedInLambda.kt + public final fun test_1(x: R|kotlin/Any|): R|kotlin/String| { + when () { + (R|/x| is R|kotlin/String|) -> { + lval thunk: R|() -> kotlin/String| = fun (): R|kotlin/String| { + ^ R|/x| + } + + ^test_1 R|/thunk|.R|SubstitutionOverride|() + } + } + + ^test_1 String(str) + } + public final fun test_2(x: R|kotlin/Any|): R|kotlin/String| { + when () { + (R|/x| is R|kotlin/String|) -> { + lval thunk: R|() -> kotlin/String| = fun (): R|kotlin/String| { + ^ R|/x|.R|kotlin/String.plus|(String(a)) + } + + ^test_2 R|/thunk|.R|SubstitutionOverride|() + } + } + + ^test_2 String(str) + } diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/valCapturedInLambda.kt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/valCapturedInLambda.kt new file mode 100644 index 00000000000..7f43fe9fb09 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/valCapturedInLambda.kt @@ -0,0 +1,17 @@ +// ISSUE: KT-43846 + +fun test_1(x: Any): String { + if (x is String) { + val thunk = { x } + return thunk() + } + return "str" +} + +fun test_2(x: Any): String { + if (x is String) { + val thunk = { x + "a" } + return thunk() + } + return "str" +} diff --git a/compiler/fir/analysis-tests/testData/resolve/typeParameters/kt38288.fir.txt b/compiler/fir/analysis-tests/testData/resolve/typeParameters/kt38288.fir.txt new file mode 100644 index 00000000000..be09e78c479 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/typeParameters/kt38288.fir.txt @@ -0,0 +1,20 @@ +FILE: kt38288.kt + public open class A : R|kotlin/Any| { + public constructor(): R|A| { + super() + } + + } + public final class G : R|A>| { + public constructor(): R|G| { + super>|>() + } + + public final class Key : R|kotlin/Any| { + public constructor(): R|G.Key| { + super() + } + + } + + } diff --git a/compiler/fir/analysis-tests/testData/resolve/typeParameters/kt38288.kt b/compiler/fir/analysis-tests/testData/resolve/typeParameters/kt38288.kt new file mode 100644 index 00000000000..5938091c31c --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/typeParameters/kt38288.kt @@ -0,0 +1,7 @@ +// ISSUE: KT-38288 + +open class A + +class G : A>() { + class Key {} +} diff --git a/compiler/fir/analysis-tests/testData/resolve/typeParameters/starProjectionForMultipleBounds.fir.txt b/compiler/fir/analysis-tests/testData/resolve/typeParameters/starProjectionForMultipleBounds.fir.txt new file mode 100644 index 00000000000..b4677b22e85 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/typeParameters/starProjectionForMultipleBounds.fir.txt @@ -0,0 +1,22 @@ +FILE: starProjectionForMultipleBounds.kt + public final class Inv : R|kotlin/Any| { + public constructor(value: R|T|): R|Inv| { + super() + } + + public final val value: R|T| = R|/value| + public get(): R|T| + + } + public abstract interface A : R|kotlin/Any| { + public abstract fun doA(): R|kotlin/Unit| + + } + public abstract interface B : R|kotlin/Any| { + public abstract fun doB(): R|kotlin/Unit| + + } + public final fun process(c: R|Inv<*>|): R|kotlin/Unit| { + R|/c|.R|SubstitutionOverride|.R|/A.doA|() + R|/c|.R|SubstitutionOverride|.R|/B.doB|() + } diff --git a/compiler/fir/analysis-tests/testData/resolve/typeParameters/starProjectionForMultipleBounds.kt b/compiler/fir/analysis-tests/testData/resolve/typeParameters/starProjectionForMultipleBounds.kt new file mode 100644 index 00000000000..b1e5b4c0608 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/typeParameters/starProjectionForMultipleBounds.kt @@ -0,0 +1,16 @@ +// ISSUE: KT-7389 + +class Inv (val value: T) where T: A, T: B + +interface A { + fun doA() +} + +interface B { + fun doB() +} + +fun process(c: Inv<*>) { + c.value.doA() + c.value.doB() +} diff --git a/compiler/fir/analysis-tests/testData/resolve/visibility/protectedAnnotationClassFromJava.fir.txt b/compiler/fir/analysis-tests/testData/resolve/visibility/protectedAnnotationClassFromJava.fir.txt new file mode 100644 index 00000000000..1781c234e09 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/visibility/protectedAnnotationClassFromJava.fir.txt @@ -0,0 +1,24 @@ +FILE: samePackage.kt + package example + + public final class KotlinChildOfJavaSuper : R|example/JavaSuper| { + public constructor(): R|example/KotlinChildOfJavaSuper| { + super() + } + + @R|example/JavaSuper.Foo|(value = String(should work)) public final fun usesFoo(): R|kotlin/String| { + ^usesFoo String() + } + + } +FILE: otherPackage.kt + public final class KotlinChildOfJavaSuper : R|example/JavaSuper| { + public constructor(): R|KotlinChildOfJavaSuper| { + super() + } + + @R|example/JavaSuper.Foo|(value = String(should work)) public final fun usesFoo(): R|kotlin/String| { + ^usesFoo String() + } + + } diff --git a/compiler/fir/analysis-tests/testData/resolve/visibility/protectedAnnotationClassFromJava.kt b/compiler/fir/analysis-tests/testData/resolve/visibility/protectedAnnotationClassFromJava.kt new file mode 100644 index 00000000000..aad4b5783c7 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/visibility/protectedAnnotationClassFromJava.kt @@ -0,0 +1,26 @@ +// ISSUE: KT-47870 + +// FILE: example/JavaSuper.java +package example; + +public abstract class JavaSuper { + protected @interface Foo { + String value() default ""; + } +} + +// FILE: samePackage.kt +package example + +class KotlinChildOfJavaSuper : JavaSuper() { + @Foo("should work") + fun usesFoo() = "" +} + +// FILE: otherPackage.kt +import example.JavaSuper + +class KotlinChildOfJavaSuper : JavaSuper() { + @Foo("should work") + fun usesFoo() = "" +} 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 a524ed72071..9e99792b9b9 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 @@ -536,6 +536,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { runTest("compiler/fir/analysis-tests/testData/resolve/reifiedTypeOverload.kt"); } + @Test + @TestMetadata("returnFromDelegatedConstuctor.kt") + public void testReturnFromDelegatedConstuctor() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/returnFromDelegatedConstuctor.kt"); + } + @Test @TestMetadata("sealedClass.kt") public void testSealedClass() throws Exception { @@ -719,6 +725,18 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/annotations"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } + @Test + @TestMetadata("kt43936.kt") + public void testKt43936() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/annotations/kt43936.kt"); + } + + @Test + @TestMetadata("kt54478.kt") + public void testKt54478() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/annotations/kt54478.kt"); + } + @Test @TestMetadata("kt55286.kt") public void testKt55286() throws Exception { @@ -879,6 +897,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { runTest("compiler/fir/analysis-tests/testData/resolve/arguments/noParameterForName.kt"); } + @Test + @TestMetadata("nullForDifferentProjections.kt") + public void testNullForDifferentProjections() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/arguments/nullForDifferentProjections.kt"); + } + @Test @TestMetadata("operatorsOverLiterals.kt") public void testOperatorsOverLiterals() throws Exception { @@ -999,6 +1023,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/arraySetWithPlusAssign.kt"); } + @Test + @TestMetadata("chooseOverloadByShapeOfLambda.kt") + public void testChooseOverloadByShapeOfLambda() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/chooseOverloadByShapeOfLambda.kt"); + } + @Test @TestMetadata("companionInvoke.kt") public void testCompanionInvoke() throws Exception { @@ -1083,6 +1113,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/overloadsWithGenericAndGenericLambda.kt"); } + @Test + @TestMetadata("referenceToNestedClass.kt") + public void testReferenceToNestedClass() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/referenceToNestedClass.kt"); + } + @Test @TestMetadata("safeCallOnTypeAlias.kt") public void testSafeCallOnTypeAlias() throws Exception { @@ -1095,6 +1131,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/superAny.kt"); } + @Test + @TestMetadata("suspendCOnversionForReceiver.kt") + public void testSuspendCOnversionForReceiver() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/suspendCOnversionForReceiver.kt"); + } + @Test @TestMetadata("syntheticPropertiesWrongImplicitReceiver.kt") public void testSyntheticPropertiesWrongImplicitReceiver() throws Exception { @@ -1135,6 +1177,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { runTest("compiler/fir/analysis-tests/testData/resolve/cfa/initializationInTry.kt"); } + @Test + @TestMetadata("kt53819.kt") + public void testKt53819() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/cfa/kt53819.kt"); + } + @Test @TestMetadata("reassignOfNonLocalProperty_initializedProperties.kt") public void testReassignOfNonLocalProperty_initializedProperties() throws Exception { @@ -1265,6 +1313,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { runTest("compiler/fir/analysis-tests/testData/resolve/cfg/lambdaAsReturnOfLambda.kt"); } + @Test + @TestMetadata("lambdaInIfInTry.kt") + public void testLambdaInIfInTry() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/cfg/lambdaInIfInTry.kt"); + } + @Test @TestMetadata("lambdaReturningObject.kt") public void testLambdaReturningObject() throws Exception { @@ -1359,11 +1413,77 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/checkers"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } + @Test + @TestMetadata("complexConflictingProjections.kt") + public void testComplexConflictingProjections() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/complexConflictingProjections.kt"); + } + + @Test + @TestMetadata("importAnnotationWithRequiresOptIn.kt") + public void testImportAnnotationWithRequiresOptIn() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/importAnnotationWithRequiresOptIn.kt"); + } + + @Test + @TestMetadata("internalImplicitInvokeFromInlineFun.kt") + public void testInternalImplicitInvokeFromInlineFun() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/internalImplicitInvokeFromInlineFun.kt"); + } + + @Test + @TestMetadata("internalSuperCallFromInlineFun.kt") + public void testInternalSuperCallFromInlineFun() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/internalSuperCallFromInlineFun.kt"); + } + + @Test + @TestMetadata("invalidLhsOfClassLiteral.kt") + public void testInvalidLhsOfClassLiteral() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/invalidLhsOfClassLiteral.kt"); + } + + @Test + @TestMetadata("notUselessCast_1.kt") + public void testNotUselessCast_1() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/notUselessCast_1.kt"); + } + + @Test + @TestMetadata("notUselessCast_2.kt") + public void testNotUselessCast_2() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/notUselessCast_2.kt"); + } + + @Test + @TestMetadata("notUselessCast_3.kt") + public void testNotUselessCast_3() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/notUselessCast_3.kt"); + } + + @Test + @TestMetadata("recursiveDependencyBetweenReturnTypeAndSupertype.kt") + public void testRecursiveDependencyBetweenReturnTypeAndSupertype() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/recursiveDependencyBetweenReturnTypeAndSupertype.kt"); + } + @Test @TestMetadata("redundantNullCheckOnAsCast.kt") public void testRedundantNullCheckOnAsCast() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/checkers/redundantNullCheckOnAsCast.kt"); } + + @Test + @TestMetadata("unsuccessfullCastToStartProjectedType.kt") + public void testUnsuccessfullCastToStartProjectedType() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/unsuccessfullCastToStartProjectedType.kt"); + } + + @Test + @TestMetadata("uselessCastLeadsToRecursiveProblem.kt") + public void testUselessCastLeadsToRecursiveProblem() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/uselessCastLeadsToRecursiveProblem.kt"); + } } @Nested @@ -1443,6 +1563,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { runTest("compiler/fir/analysis-tests/testData/resolve/contracts/contractFromOtherModule_samePackage.kt"); } + @Test + @TestMetadata("contractOnInfixFunction.kt") + public void testContractOnInfixFunction() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/contracts/contractOnInfixFunction.kt"); + } + @Test @TestMetadata("disabledFeature.kt") public void testDisabledFeature() throws Exception { @@ -1454,6 +1580,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { public void testGenericContract() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/contracts/genericContract.kt"); } + + @Test + @TestMetadata("inPlaceAfterVararg.kt") + public void testInPlaceAfterVararg() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/contracts/inPlaceAfterVararg.kt"); + } } @Nested @@ -1910,6 +2042,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } + @Test + @TestMetadata("annotatedBranch.kt") + public void testAnnotatedBranch() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/annotatedBranch.kt"); + } + @Test @TestMetadata("exhaustiveWhenAndDNNType.kt") public void testExhaustiveWhenAndDNNType() throws Exception { @@ -1958,6 +2096,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/exhaustiveness_sealedSubClass.kt"); } + @Test + @TestMetadata("exhaustiveness_smartcastedBoolean.kt") + public void testExhaustiveness_smartcastedBoolean() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/exhaustiveness_smartcastedBoolean.kt"); + } + @Test @TestMetadata("nestedIfInLambda.kt") public void testNestedIfInLambda() throws Exception { @@ -1969,6 +2113,18 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { public void testNonExhaustiveWhenWithCoercionToUnit() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/nonExhaustiveWhenWithCoercionToUnit.kt"); } + + @Test + @TestMetadata("sameBranchMultipleConditions.kt") + public void testSameBranchMultipleConditions() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/sameBranchMultipleConditions.kt"); + } + + @Test + @TestMetadata("smartcastToExhaustiveInterface.kt") + public void testSmartcastToExhaustiveInterface() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/smartcastToExhaustiveInterface.kt"); + } } } @@ -3117,6 +3273,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { runTest("compiler/fir/analysis-tests/testData/resolve/inference/intersectionTypesInConstraints.kt"); } + @Test + @TestMetadata("javaCollector.kt") + public void testJavaCollector() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/inference/javaCollector.kt"); + } + @Test @TestMetadata("kt40131.kt") public void testKt40131() throws Exception { @@ -3129,6 +3291,24 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { runTest("compiler/fir/analysis-tests/testData/resolve/inference/kt41989.kt"); } + @Test + @TestMetadata("kt53494.kt") + public void testKt53494() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/inference/kt53494.kt"); + } + + @Test + @TestMetadata("kt54990.kt") + public void testKt54990() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/inference/kt54990.kt"); + } + + @Test + @TestMetadata("kt55555.kt") + public void testKt55555() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/inference/kt55555.kt"); + } + @Test @TestMetadata("lambdaAsReturnStatementOfLambda.kt") public void testLambdaAsReturnStatementOfLambda() throws Exception { @@ -3183,6 +3363,18 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { runTest("compiler/fir/analysis-tests/testData/resolve/inference/receiverWithCapturedType.kt"); } + @Test + @TestMetadata("recursiveSelfTypes.kt") + public void testRecursiveSelfTypes() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/inference/recursiveSelfTypes.kt"); + } + + @Test + @TestMetadata("selfTypeFromJava.kt") + public void testSelfTypeFromJava() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/inference/selfTypeFromJava.kt"); + } + @Test @TestMetadata("simpleCapturedTypes.kt") public void testSimpleCapturedTypes() throws Exception { @@ -3200,6 +3392,22 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { public void testUnitUpperBound() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/inference/unitUpperBound.kt"); } + + @Nested + @TestMetadata("compiler/fir/analysis-tests/testData/resolve/inference/builderInference") + @TestDataPath("$PROJECT_ROOT") + public class BuilderInference { + @Test + public void testAllFilesPresentInBuilderInference() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/inference/builderInference"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @Test + @TestMetadata("ifInBuildMap.kt") + public void testIfInBuildMap() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/inference/builderInference/ifInBuildMap.kt"); + } + } } @Nested @@ -3459,6 +3667,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/problems"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } + @Test + @TestMetadata("classLiteralWithExclExcl.kt") + public void testClassLiteralWithExclExcl() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/problems/classLiteralWithExclExcl.kt"); + } + @Test @TestMetadata("compilerPhase.kt") public void testCompilerPhase() throws Exception { @@ -3537,6 +3751,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { runTest("compiler/fir/analysis-tests/testData/resolve/problems/innerClassHierarchy.kt"); } + @Test + @TestMetadata("invalidCode.kt") + public void testInvalidCode() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/problems/invalidCode.kt"); + } + @Test @TestMetadata("javaClassWithEmptyAnnotationName.kt") public void testJavaClassWithEmptyAnnotationName() throws Exception { @@ -3602,6 +3822,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { public void testTransform() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/problems/transform.kt"); } + + @Test + @TestMetadata("typeArgumentsOnThis.kt") + public void testTypeArgumentsOnThis() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/problems/typeArgumentsOnThis.kt"); + } } @Nested @@ -3613,6 +3839,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/properties"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } + @Test + @TestMetadata("assignToStarProjectedType.kt") + public void testAssignToStarProjectedType() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/properties/assignToStarProjectedType.kt"); + } + @Test @TestMetadata("getterWithEarlyReturn.kt") public void testGetterWithEarlyReturn() throws Exception { @@ -3705,6 +3937,18 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/references"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } + @Test + @TestMetadata("ambigousParenthesizedReference.kt") + public void testAmbigousParenthesizedReference() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/references/ambigousParenthesizedReference.kt"); + } + + @Test + @TestMetadata("incorrectReferenceOnInnerClassMember.kt") + public void testIncorrectReferenceOnInnerClassMember() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/references/incorrectReferenceOnInnerClassMember.kt"); + } + @Test @TestMetadata("integerLiteralInLhs.kt") public void testIntegerLiteralInLhs() throws Exception { @@ -3729,6 +3973,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { runTest("compiler/fir/analysis-tests/testData/resolve/references/referenceToField.kt"); } + @Test + @TestMetadata("referenceToSyntheticJavaPropertyWithProjection.kt") + public void testReferenceToSyntheticJavaPropertyWithProjection() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/references/referenceToSyntheticJavaPropertyWithProjection.kt"); + } + @Test @TestMetadata("simple.kt") public void testSimple() throws Exception { @@ -3740,6 +3990,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { public void testSuperMember() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/references/superMember.kt"); } + + @Test + @TestMetadata("unresovledReferenceInFinally.kt") + public void testUnresovledReferenceInFinally() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/references/unresovledReferenceInFinally.kt"); + } } @Nested @@ -3821,6 +4077,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { runTest("compiler/fir/analysis-tests/testData/resolve/samConversions/notSamBecauseOfSupertype.kt"); } + @Test + @TestMetadata("nothingVararg.kt") + public void testNothingVararg() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/samConversions/nothingVararg.kt"); + } + @Test @TestMetadata("runnable.kt") public void testRunnable() throws Exception { @@ -3979,6 +4241,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/casts.kt"); } + @Test + @TestMetadata("contractSafeCall.kt") + public void testContractSafeCall() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/contractSafeCall.kt"); + } + @Test @TestMetadata("equalsAndIdentity.kt") public void testEqualsAndIdentity() throws Exception { @@ -4063,6 +4331,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastInByClause.kt"); } + @Test + @TestMetadata("smartcastOnFunctionalType.kt") + public void testSmartcastOnFunctionalType() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastOnFunctionalType.kt"); + } + @Test @TestMetadata("smartcastOnImplicitReceiverOfCallableReference.kt") public void testSmartcastOnImplicitReceiverOfCallableReference() throws Exception { @@ -4075,6 +4349,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToNothing.kt"); } + @Test + @TestMetadata("smartcastToStarProjectedType.kt") + public void testSmartcastToStarProjectedType() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToStarProjectedType.kt"); + } + @Test @TestMetadata("smartcastToTypeParameter.kt") public void testSmartcastToTypeParameter() throws Exception { @@ -4093,12 +4373,24 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastsFromEquals_sameModule.kt"); } + @Test + @TestMetadata("typeOfLambdaWithSmartcast.kt") + public void testTypeOfLambdaWithSmartcast() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/typeOfLambdaWithSmartcast.kt"); + } + @Test @TestMetadata("unstableSmartcastAndAmbiguity.kt") public void testUnstableSmartcastAndAmbiguity() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/unstableSmartcastAndAmbiguity.kt"); } + @Test + @TestMetadata("valCapturedInLambda.kt") + public void testValCapturedInLambda() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/valCapturedInLambda.kt"); + } + @Nested @TestMetadata("compiler/fir/analysis-tests/testData/resolve/smartcasts/booleans") @TestDataPath("$PROJECT_ROOT") @@ -4142,6 +4434,18 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } + @Test + @TestMetadata("assignToBoundSmartcastedVariable.kt") + public void testAssignToBoundSmartcastedVariable() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/assignToBoundSmartcastedVariable.kt"); + } + + @Test + @TestMetadata("boundSmartcastWithProjection.kt") + public void testBoundSmartcastWithProjection() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/boundSmartcastWithProjection.kt"); + } + @Test @TestMetadata("boundSmartcasts.kt") public void testBoundSmartcasts() throws Exception { @@ -4176,12 +4480,24 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } + @Test + @TestMetadata("earlyReturnInNonExhaustiveWhen.kt") + public void testEarlyReturnInNonExhaustiveWhen() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures/earlyReturnInNonExhaustiveWhen.kt"); + } + @Test @TestMetadata("elvis.kt") public void testElvis() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures/elvis.kt"); } + @Test + @TestMetadata("returnFromWhen.kt") + public void testReturnFromWhen() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures/returnFromWhen.kt"); + } + @Test @TestMetadata("returns.kt") public void testReturns() throws Exception { @@ -4256,6 +4572,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/loops/dataFlowInfoFromWhileCondition.kt"); } + @Test + @TestMetadata("elvisAtTheEndOfLoop.kt") + public void testElvisAtTheEndOfLoop() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/loops/elvisAtTheEndOfLoop.kt"); + } + @Test @TestMetadata("endlessLoops.kt") public void testEndlessLoops() throws Exception { @@ -4277,6 +4599,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { public void testInvoke() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/problems/invoke.kt"); } + + @Test + @TestMetadata("noSmartcastToNullableNothing.kt") + public void testNoSmartcastToNullableNothing() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/problems/noSmartcastToNullableNothing.kt"); + } } @Nested @@ -4476,6 +4804,28 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { } } + @Nested + @TestMetadata("compiler/fir/analysis-tests/testData/resolve/typeParameters") + @TestDataPath("$PROJECT_ROOT") + public class TypeParameters { + @Test + public void testAllFilesPresentInTypeParameters() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/typeParameters"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @Test + @TestMetadata("kt38288.kt") + public void testKt38288() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/typeParameters/kt38288.kt"); + } + + @Test + @TestMetadata("starProjectionForMultipleBounds.kt") + public void testStarProjectionForMultipleBounds() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/typeParameters/starProjectionForMultipleBounds.kt"); + } + } + @Nested @TestMetadata("compiler/fir/analysis-tests/testData/resolve/types") @TestDataPath("$PROJECT_ROOT") @@ -4631,6 +4981,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { runTest("compiler/fir/analysis-tests/testData/resolve/visibility/privateAliasInSamePackage.kt"); } + @Test + @TestMetadata("protectedAnnotationClassFromJava.kt") + public void testProtectedAnnotationClassFromJava() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/visibility/protectedAnnotationClassFromJava.kt"); + } + @Test @TestMetadata("protectedInCompanion.kt") public void testProtectedInCompanion() throws Exception { 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 fa28ca7a523..0ffa9e6023e 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 @@ -536,6 +536,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/reifiedTypeOverload.kt"); } + @Test + @TestMetadata("returnFromDelegatedConstuctor.kt") + public void testReturnFromDelegatedConstuctor() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/returnFromDelegatedConstuctor.kt"); + } + @Test @TestMetadata("sealedClass.kt") public void testSealedClass() throws Exception { @@ -719,6 +725,18 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/annotations"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } + @Test + @TestMetadata("kt43936.kt") + public void testKt43936() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/annotations/kt43936.kt"); + } + + @Test + @TestMetadata("kt54478.kt") + public void testKt54478() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/annotations/kt54478.kt"); + } + @Test @TestMetadata("kt55286.kt") public void testKt55286() throws Exception { @@ -879,6 +897,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/arguments/noParameterForName.kt"); } + @Test + @TestMetadata("nullForDifferentProjections.kt") + public void testNullForDifferentProjections() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/arguments/nullForDifferentProjections.kt"); + } + @Test @TestMetadata("operatorsOverLiterals.kt") public void testOperatorsOverLiterals() throws Exception { @@ -999,6 +1023,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/arraySetWithPlusAssign.kt"); } + @Test + @TestMetadata("chooseOverloadByShapeOfLambda.kt") + public void testChooseOverloadByShapeOfLambda() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/chooseOverloadByShapeOfLambda.kt"); + } + @Test @TestMetadata("companionInvoke.kt") public void testCompanionInvoke() throws Exception { @@ -1083,6 +1113,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/overloadsWithGenericAndGenericLambda.kt"); } + @Test + @TestMetadata("referenceToNestedClass.kt") + public void testReferenceToNestedClass() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/referenceToNestedClass.kt"); + } + @Test @TestMetadata("safeCallOnTypeAlias.kt") public void testSafeCallOnTypeAlias() throws Exception { @@ -1095,6 +1131,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/superAny.kt"); } + @Test + @TestMetadata("suspendCOnversionForReceiver.kt") + public void testSuspendCOnversionForReceiver() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/suspendCOnversionForReceiver.kt"); + } + @Test @TestMetadata("syntheticPropertiesWrongImplicitReceiver.kt") public void testSyntheticPropertiesWrongImplicitReceiver() throws Exception { @@ -1135,6 +1177,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/cfa/initializationInTry.kt"); } + @Test + @TestMetadata("kt53819.kt") + public void testKt53819() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/cfa/kt53819.kt"); + } + @Test @TestMetadata("reassignOfNonLocalProperty_initializedProperties.kt") public void testReassignOfNonLocalProperty_initializedProperties() throws Exception { @@ -1265,6 +1313,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/cfg/lambdaAsReturnOfLambda.kt"); } + @Test + @TestMetadata("lambdaInIfInTry.kt") + public void testLambdaInIfInTry() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/cfg/lambdaInIfInTry.kt"); + } + @Test @TestMetadata("lambdaReturningObject.kt") public void testLambdaReturningObject() throws Exception { @@ -1359,11 +1413,77 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/checkers"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } + @Test + @TestMetadata("complexConflictingProjections.kt") + public void testComplexConflictingProjections() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/complexConflictingProjections.kt"); + } + + @Test + @TestMetadata("importAnnotationWithRequiresOptIn.kt") + public void testImportAnnotationWithRequiresOptIn() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/importAnnotationWithRequiresOptIn.kt"); + } + + @Test + @TestMetadata("internalImplicitInvokeFromInlineFun.kt") + public void testInternalImplicitInvokeFromInlineFun() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/internalImplicitInvokeFromInlineFun.kt"); + } + + @Test + @TestMetadata("internalSuperCallFromInlineFun.kt") + public void testInternalSuperCallFromInlineFun() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/internalSuperCallFromInlineFun.kt"); + } + + @Test + @TestMetadata("invalidLhsOfClassLiteral.kt") + public void testInvalidLhsOfClassLiteral() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/invalidLhsOfClassLiteral.kt"); + } + + @Test + @TestMetadata("notUselessCast_1.kt") + public void testNotUselessCast_1() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/notUselessCast_1.kt"); + } + + @Test + @TestMetadata("notUselessCast_2.kt") + public void testNotUselessCast_2() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/notUselessCast_2.kt"); + } + + @Test + @TestMetadata("notUselessCast_3.kt") + public void testNotUselessCast_3() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/notUselessCast_3.kt"); + } + + @Test + @TestMetadata("recursiveDependencyBetweenReturnTypeAndSupertype.kt") + public void testRecursiveDependencyBetweenReturnTypeAndSupertype() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/recursiveDependencyBetweenReturnTypeAndSupertype.kt"); + } + @Test @TestMetadata("redundantNullCheckOnAsCast.kt") public void testRedundantNullCheckOnAsCast() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/checkers/redundantNullCheckOnAsCast.kt"); } + + @Test + @TestMetadata("unsuccessfullCastToStartProjectedType.kt") + public void testUnsuccessfullCastToStartProjectedType() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/unsuccessfullCastToStartProjectedType.kt"); + } + + @Test + @TestMetadata("uselessCastLeadsToRecursiveProblem.kt") + public void testUselessCastLeadsToRecursiveProblem() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/checkers/uselessCastLeadsToRecursiveProblem.kt"); + } } @Nested @@ -1443,6 +1563,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/contracts/contractFromOtherModule_samePackage.kt"); } + @Test + @TestMetadata("contractOnInfixFunction.kt") + public void testContractOnInfixFunction() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/contracts/contractOnInfixFunction.kt"); + } + @Test @TestMetadata("disabledFeature.kt") public void testDisabledFeature() throws Exception { @@ -1454,6 +1580,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos public void testGenericContract() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/contracts/genericContract.kt"); } + + @Test + @TestMetadata("inPlaceAfterVararg.kt") + public void testInPlaceAfterVararg() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/contracts/inPlaceAfterVararg.kt"); + } } @Nested @@ -1910,6 +2042,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } + @Test + @TestMetadata("annotatedBranch.kt") + public void testAnnotatedBranch() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/annotatedBranch.kt"); + } + @Test @TestMetadata("exhaustiveWhenAndDNNType.kt") public void testExhaustiveWhenAndDNNType() throws Exception { @@ -1958,6 +2096,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/exhaustiveness_sealedSubClass.kt"); } + @Test + @TestMetadata("exhaustiveness_smartcastedBoolean.kt") + public void testExhaustiveness_smartcastedBoolean() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/exhaustiveness_smartcastedBoolean.kt"); + } + @Test @TestMetadata("nestedIfInLambda.kt") public void testNestedIfInLambda() throws Exception { @@ -1969,6 +2113,18 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos public void testNonExhaustiveWhenWithCoercionToUnit() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/nonExhaustiveWhenWithCoercionToUnit.kt"); } + + @Test + @TestMetadata("sameBranchMultipleConditions.kt") + public void testSameBranchMultipleConditions() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/sameBranchMultipleConditions.kt"); + } + + @Test + @TestMetadata("smartcastToExhaustiveInterface.kt") + public void testSmartcastToExhaustiveInterface() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/smartcastToExhaustiveInterface.kt"); + } } } @@ -3117,6 +3273,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/inference/intersectionTypesInConstraints.kt"); } + @Test + @TestMetadata("javaCollector.kt") + public void testJavaCollector() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/inference/javaCollector.kt"); + } + @Test @TestMetadata("kt40131.kt") public void testKt40131() throws Exception { @@ -3129,6 +3291,24 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/inference/kt41989.kt"); } + @Test + @TestMetadata("kt53494.kt") + public void testKt53494() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/inference/kt53494.kt"); + } + + @Test + @TestMetadata("kt54990.kt") + public void testKt54990() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/inference/kt54990.kt"); + } + + @Test + @TestMetadata("kt55555.kt") + public void testKt55555() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/inference/kt55555.kt"); + } + @Test @TestMetadata("lambdaAsReturnStatementOfLambda.kt") public void testLambdaAsReturnStatementOfLambda() throws Exception { @@ -3183,6 +3363,18 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/inference/receiverWithCapturedType.kt"); } + @Test + @TestMetadata("recursiveSelfTypes.kt") + public void testRecursiveSelfTypes() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/inference/recursiveSelfTypes.kt"); + } + + @Test + @TestMetadata("selfTypeFromJava.kt") + public void testSelfTypeFromJava() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/inference/selfTypeFromJava.kt"); + } + @Test @TestMetadata("simpleCapturedTypes.kt") public void testSimpleCapturedTypes() throws Exception { @@ -3200,6 +3392,22 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos public void testUnitUpperBound() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/inference/unitUpperBound.kt"); } + + @Nested + @TestMetadata("compiler/fir/analysis-tests/testData/resolve/inference/builderInference") + @TestDataPath("$PROJECT_ROOT") + public class BuilderInference { + @Test + public void testAllFilesPresentInBuilderInference() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/inference/builderInference"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @Test + @TestMetadata("ifInBuildMap.kt") + public void testIfInBuildMap() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/inference/builderInference/ifInBuildMap.kt"); + } + } } @Nested @@ -3459,6 +3667,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/problems"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } + @Test + @TestMetadata("classLiteralWithExclExcl.kt") + public void testClassLiteralWithExclExcl() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/problems/classLiteralWithExclExcl.kt"); + } + @Test @TestMetadata("compilerPhase.kt") public void testCompilerPhase() throws Exception { @@ -3537,6 +3751,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/problems/innerClassHierarchy.kt"); } + @Test + @TestMetadata("invalidCode.kt") + public void testInvalidCode() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/problems/invalidCode.kt"); + } + @Test @TestMetadata("javaClassWithEmptyAnnotationName.kt") public void testJavaClassWithEmptyAnnotationName() throws Exception { @@ -3602,6 +3822,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos public void testTransform() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/problems/transform.kt"); } + + @Test + @TestMetadata("typeArgumentsOnThis.kt") + public void testTypeArgumentsOnThis() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/problems/typeArgumentsOnThis.kt"); + } } @Nested @@ -3613,6 +3839,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/properties"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } + @Test + @TestMetadata("assignToStarProjectedType.kt") + public void testAssignToStarProjectedType() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/properties/assignToStarProjectedType.kt"); + } + @Test @TestMetadata("getterWithEarlyReturn.kt") public void testGetterWithEarlyReturn() throws Exception { @@ -3705,6 +3937,18 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/references"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } + @Test + @TestMetadata("ambigousParenthesizedReference.kt") + public void testAmbigousParenthesizedReference() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/references/ambigousParenthesizedReference.kt"); + } + + @Test + @TestMetadata("incorrectReferenceOnInnerClassMember.kt") + public void testIncorrectReferenceOnInnerClassMember() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/references/incorrectReferenceOnInnerClassMember.kt"); + } + @Test @TestMetadata("integerLiteralInLhs.kt") public void testIntegerLiteralInLhs() throws Exception { @@ -3729,6 +3973,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/references/referenceToField.kt"); } + @Test + @TestMetadata("referenceToSyntheticJavaPropertyWithProjection.kt") + public void testReferenceToSyntheticJavaPropertyWithProjection() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/references/referenceToSyntheticJavaPropertyWithProjection.kt"); + } + @Test @TestMetadata("simple.kt") public void testSimple() throws Exception { @@ -3740,6 +3990,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos public void testSuperMember() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/references/superMember.kt"); } + + @Test + @TestMetadata("unresovledReferenceInFinally.kt") + public void testUnresovledReferenceInFinally() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/references/unresovledReferenceInFinally.kt"); + } } @Nested @@ -3821,6 +4077,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/samConversions/notSamBecauseOfSupertype.kt"); } + @Test + @TestMetadata("nothingVararg.kt") + public void testNothingVararg() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/samConversions/nothingVararg.kt"); + } + @Test @TestMetadata("runnable.kt") public void testRunnable() throws Exception { @@ -3979,6 +4241,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/casts.kt"); } + @Test + @TestMetadata("contractSafeCall.kt") + public void testContractSafeCall() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/contractSafeCall.kt"); + } + @Test @TestMetadata("equalsAndIdentity.kt") public void testEqualsAndIdentity() throws Exception { @@ -4063,6 +4331,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastInByClause.kt"); } + @Test + @TestMetadata("smartcastOnFunctionalType.kt") + public void testSmartcastOnFunctionalType() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastOnFunctionalType.kt"); + } + @Test @TestMetadata("smartcastOnImplicitReceiverOfCallableReference.kt") public void testSmartcastOnImplicitReceiverOfCallableReference() throws Exception { @@ -4075,6 +4349,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToNothing.kt"); } + @Test + @TestMetadata("smartcastToStarProjectedType.kt") + public void testSmartcastToStarProjectedType() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToStarProjectedType.kt"); + } + @Test @TestMetadata("smartcastToTypeParameter.kt") public void testSmartcastToTypeParameter() throws Exception { @@ -4093,12 +4373,24 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastsFromEquals_sameModule.kt"); } + @Test + @TestMetadata("typeOfLambdaWithSmartcast.kt") + public void testTypeOfLambdaWithSmartcast() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/typeOfLambdaWithSmartcast.kt"); + } + @Test @TestMetadata("unstableSmartcastAndAmbiguity.kt") public void testUnstableSmartcastAndAmbiguity() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/unstableSmartcastAndAmbiguity.kt"); } + @Test + @TestMetadata("valCapturedInLambda.kt") + public void testValCapturedInLambda() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/valCapturedInLambda.kt"); + } + @Nested @TestMetadata("compiler/fir/analysis-tests/testData/resolve/smartcasts/booleans") @TestDataPath("$PROJECT_ROOT") @@ -4142,6 +4434,18 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } + @Test + @TestMetadata("assignToBoundSmartcastedVariable.kt") + public void testAssignToBoundSmartcastedVariable() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/assignToBoundSmartcastedVariable.kt"); + } + + @Test + @TestMetadata("boundSmartcastWithProjection.kt") + public void testBoundSmartcastWithProjection() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/boundSmartcastWithProjection.kt"); + } + @Test @TestMetadata("boundSmartcasts.kt") public void testBoundSmartcasts() throws Exception { @@ -4176,12 +4480,24 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } + @Test + @TestMetadata("earlyReturnInNonExhaustiveWhen.kt") + public void testEarlyReturnInNonExhaustiveWhen() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures/earlyReturnInNonExhaustiveWhen.kt"); + } + @Test @TestMetadata("elvis.kt") public void testElvis() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures/elvis.kt"); } + @Test + @TestMetadata("returnFromWhen.kt") + public void testReturnFromWhen() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures/returnFromWhen.kt"); + } + @Test @TestMetadata("returns.kt") public void testReturns() throws Exception { @@ -4256,6 +4572,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/loops/dataFlowInfoFromWhileCondition.kt"); } + @Test + @TestMetadata("elvisAtTheEndOfLoop.kt") + public void testElvisAtTheEndOfLoop() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/loops/elvisAtTheEndOfLoop.kt"); + } + @Test @TestMetadata("endlessLoops.kt") public void testEndlessLoops() throws Exception { @@ -4277,6 +4599,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos public void testInvoke() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/problems/invoke.kt"); } + + @Test + @TestMetadata("noSmartcastToNullableNothing.kt") + public void testNoSmartcastToNullableNothing() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/problems/noSmartcastToNullableNothing.kt"); + } } @Nested @@ -4476,6 +4804,28 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos } } + @Nested + @TestMetadata("compiler/fir/analysis-tests/testData/resolve/typeParameters") + @TestDataPath("$PROJECT_ROOT") + public class TypeParameters { + @Test + public void testAllFilesPresentInTypeParameters() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/typeParameters"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @Test + @TestMetadata("kt38288.kt") + public void testKt38288() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/typeParameters/kt38288.kt"); + } + + @Test + @TestMetadata("starProjectionForMultipleBounds.kt") + public void testStarProjectionForMultipleBounds() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/typeParameters/starProjectionForMultipleBounds.kt"); + } + } + @Nested @TestMetadata("compiler/fir/analysis-tests/testData/resolve/types") @TestDataPath("$PROJECT_ROOT") @@ -4631,6 +4981,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/visibility/privateAliasInSamePackage.kt"); } + @Test + @TestMetadata("protectedAnnotationClassFromJava.kt") + public void testProtectedAnnotationClassFromJava() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/visibility/protectedAnnotationClassFromJava.kt"); + } + @Test @TestMetadata("protectedInCompanion.kt") public void testProtectedInCompanion() throws Exception { 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 71a3df46a9b..4b153670533 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 @@ -12200,6 +12200,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti runTest("compiler/testData/diagnostics/tests/generics/anonymousObjectSupertypeWithTypeParameterFromFunction.kt"); } + @Test + @TestMetadata("approximationOfInProjection.kt") + public void testApproximationOfInProjection() throws Exception { + runTest("compiler/testData/diagnostics/tests/generics/approximationOfInProjection.kt"); + } + @Test @TestMetadata("argumentsForT.kt") public void testArgumentsForT() throws Exception { 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 69b4dd8f523..9bfa04eec36 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 @@ -12194,6 +12194,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac runTest("compiler/testData/diagnostics/tests/generics/anonymousObjectSupertypeWithTypeParameterFromFunction.kt"); } + @Test + @TestMetadata("approximationOfInProjection.kt") + public void testApproximationOfInProjection() throws Exception { + runTest("compiler/testData/diagnostics/tests/generics/approximationOfInProjection.kt"); + } + @Test @TestMetadata("argumentsForT.kt") public void testArgumentsForT() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 2cb97e057a2..f0315e755ec 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -516,6 +516,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/annotations/instances/inInlineFunction.kt"); } + @Test + @TestMetadata("innerAnnotationInstantiation.kt") + public void testInnerAnnotationInstantiation() throws Exception { + runTest("compiler/testData/codegen/box/annotations/instances/innerAnnotationInstantiation.kt"); + } + @Test @TestMetadata("javaAnnotation.kt") public void testJavaAnnotation() throws Exception { @@ -654,6 +660,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/annotations/typeAnnotations"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("annotationWithTypeParameterOnReturnType.kt") + public void testAnnotationWithTypeParameterOnReturnType() throws Exception { + runTest("compiler/testData/codegen/box/annotations/typeAnnotations/annotationWithTypeParameterOnReturnType.kt"); + } + @Test @TestMetadata("checkingNotincorporatedInputTypes.kt") public void testCheckingNotincorporatedInputTypes() throws Exception { @@ -3213,6 +3225,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/callableReference/kt52270.kt"); } + @Test + @TestMetadata("kt55138.kt") + public void testKt55138() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/kt55138.kt"); + } + @Test @TestMetadata("nested.kt") public void testNested() throws Exception { @@ -6138,6 +6156,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/classes/inner/extensionWithOuter.kt"); } + @Test + @TestMetadata("innerClassDerivedFromOuterClass.kt") + public void testInnerClassDerivedFromOuterClass() throws Exception { + runTest("compiler/testData/codegen/box/classes/inner/innerClassDerivedFromOuterClass.kt"); + } + @Test @TestMetadata("instantiateInDerived.kt") public void testInstantiateInDerived() throws Exception { @@ -47371,6 +47395,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/sam/recordSubstitutedTypeForCallableSamParameter.kt"); } + @Test + @TestMetadata("samAsIndexInArrayAssignment.kt") + public void testSamAsIndexInArrayAssignment() throws Exception { + runTest("compiler/testData/codegen/box/sam/samAsIndexInArrayAssignment.kt"); + } + @Test @TestMetadata("samConstructorGenericSignature.kt") public void testSamConstructorGenericSignature() throws Exception { diff --git a/compiler/testData/codegen/box/annotations/instances/innerAnnotationInstantiation.kt b/compiler/testData/codegen/box/annotations/instances/innerAnnotationInstantiation.kt new file mode 100644 index 00000000000..f3f0c1299fa --- /dev/null +++ b/compiler/testData/codegen/box/annotations/instances/innerAnnotationInstantiation.kt @@ -0,0 +1,15 @@ +// TARGET_BACKEND: JVM_IR +// IGNORE_BACKEND_K1: JVM_IR +// ISSUE: KT-54931 + +class Container { + annotation class ExampleMapKey( + val stringValue: String, + ) +} + +object Container_ExampleMapKeyCreator { + fun createExampleMapKey(stringValue: String) = Container.ExampleMapKey(stringValue) // Error is here +} + +fun box() = Container_ExampleMapKeyCreator.createExampleMapKey("OK").stringValue diff --git a/compiler/testData/codegen/box/annotations/typeAnnotations/annotationWithTypeParameterOnReturnType.kt b/compiler/testData/codegen/box/annotations/typeAnnotations/annotationWithTypeParameterOnReturnType.kt new file mode 100644 index 00000000000..b70ff294130 --- /dev/null +++ b/compiler/testData/codegen/box/annotations/typeAnnotations/annotationWithTypeParameterOnReturnType.kt @@ -0,0 +1,10 @@ +// TARGET_BACKEND: JVM_IR +// IGNORE_BACKEND_K1: JVM_IR +// ISSUE: KT-43553 + +@Target(AnnotationTarget.TYPE) +annotation class Qualifier + +fun func(param: String): @Qualifier String = param + +fun box(): String = func("OK") diff --git a/compiler/testData/codegen/box/callableReference/kt55138.kt b/compiler/testData/codegen/box/callableReference/kt55138.kt new file mode 100644 index 00000000000..627cc8c7434 --- /dev/null +++ b/compiler/testData/codegen/box/callableReference/kt55138.kt @@ -0,0 +1,44 @@ +// TARGET_BACKEND: JVM_IR +// IGNORE_BACKEND_K1: JVM_IR +// WITH_STDLIB +// ISSUE: KT-55138 + +interface Operation { + fun exec(input: Long): Long +} + +class Add(private val addValue: Long) : Operation { + override fun exec(input: Long): Long { + return input + addValue + } +} + +class Squared : Operation { + override fun exec(input: Long): Long { + return input * input + } +} + +fun test(op: String, x: Long): Long { + var result = 0L + listOf(1L).forEach { + val operation2 = when (op) { + "*" -> { + Squared()::exec + } + "+" -> { + Add(42)::exec + } + else -> { + throw IllegalArgumentException("Unexpected op: $op") + } + } + result = operation2(x) + } + return result +} + +fun box(): String { + val result = test("+", 4L) + return if (result == 46L) "OK" else "Error: $result" +} diff --git a/compiler/testData/codegen/box/classes/inner/innerClassDerivedFromOuterClass.kt b/compiler/testData/codegen/box/classes/inner/innerClassDerivedFromOuterClass.kt new file mode 100644 index 00000000000..5a19fa86ad9 --- /dev/null +++ b/compiler/testData/codegen/box/classes/inner/innerClassDerivedFromOuterClass.kt @@ -0,0 +1,19 @@ +// TARGET_BACKEND: JVM_IR +// IGNORE_BACKEND_K1: JVM_IR +// ISSUE: KT-53086 + +open class P1 { + inner class P2(i : String): P1() { + var value = "Fail" + + init { + value = i + } + + constructor() : this("OK") {} + } + + fun createP2(): P2 = P2() +} + +fun box() = P1().createP2().value diff --git a/compiler/testData/codegen/box/sam/samAsIndexInArrayAssignment.kt b/compiler/testData/codegen/box/sam/samAsIndexInArrayAssignment.kt new file mode 100644 index 00000000000..fff2c7ffc7e --- /dev/null +++ b/compiler/testData/codegen/box/sam/samAsIndexInArrayAssignment.kt @@ -0,0 +1,36 @@ +// TARGET_BACKEND: JVM_IR +// IGNORE_BACKEND_K1: JVM_IR +// ISSUE: KT-28668 + +// FILE: ZipZap.java +package test; + +public class ZipZap { + public static String result = ""; + + public interface Zipper { + int zip(); + } + + public interface Zapper { + int zap(); + } + + public int get(Zipper zipper) { + return zipper.zip(); + } + + public void set(Zapper zapper, int x) { + result = result + "zap: " + zapper.zap() + "|"; + result = result + "x: " + x; + } +} + +// FILE: main.kt +package test + +fun box(): String { + ZipZap()[{ 42 }]++ + val result = ZipZap.result + return if (result == "zap: 42|x: 43") "OK" else "Fail: $result" +} diff --git a/compiler/testData/diagnostics/tests/generics/approximationOfInProjection.fir.kt b/compiler/testData/diagnostics/tests/generics/approximationOfInProjection.fir.kt new file mode 100644 index 00000000000..50df2e7848f --- /dev/null +++ b/compiler/testData/diagnostics/tests/generics/approximationOfInProjection.fir.kt @@ -0,0 +1,14 @@ +// ISSUE: KT-21463 +// SKIP_TXT + +class Bound(val value: T) + +fun test_1() { + val b: Bound = Bound(1) + val vl: Number = b.value +} + +fun test_2() { + val b: Bound<*> = Bound(1) + val vl: Number = b.value +} diff --git a/compiler/testData/diagnostics/tests/generics/approximationOfInProjection.kt b/compiler/testData/diagnostics/tests/generics/approximationOfInProjection.kt new file mode 100644 index 00000000000..801208dfa90 --- /dev/null +++ b/compiler/testData/diagnostics/tests/generics/approximationOfInProjection.kt @@ -0,0 +1,14 @@ +// ISSUE: KT-21463 +// SKIP_TXT + +class Bound(val value: T) + +fun test_1() { + val b: Bound = Bound(1) + val vl: Number = b.value +} + +fun test_2() { + val b: Bound<*> = Bound(1) + val vl: Number = b.value +} 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 01c43569fa4..fef52dba6c6 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 @@ -12200,6 +12200,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/generics/anonymousObjectSupertypeWithTypeParameterFromFunction.kt"); } + @Test + @TestMetadata("approximationOfInProjection.kt") + public void testApproximationOfInProjection() throws Exception { + runTest("compiler/testData/diagnostics/tests/generics/approximationOfInProjection.kt"); + } + @Test @TestMetadata("argumentsForT.kt") public void testArgumentsForT() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 62be27e5b50..fddd3139813 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -516,6 +516,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/annotations/instances/inInlineFunction.kt"); } + @Test + @TestMetadata("innerAnnotationInstantiation.kt") + public void testInnerAnnotationInstantiation() throws Exception { + runTest("compiler/testData/codegen/box/annotations/instances/innerAnnotationInstantiation.kt"); + } + @Test @TestMetadata("javaAnnotation.kt") public void testJavaAnnotation() throws Exception { @@ -654,6 +660,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/annotations/typeAnnotations"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("annotationWithTypeParameterOnReturnType.kt") + public void testAnnotationWithTypeParameterOnReturnType() throws Exception { + runTest("compiler/testData/codegen/box/annotations/typeAnnotations/annotationWithTypeParameterOnReturnType.kt"); + } + @Test @TestMetadata("checkingNotincorporatedInputTypes.kt") public void testCheckingNotincorporatedInputTypes() throws Exception { @@ -3213,6 +3225,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/callableReference/kt52270.kt"); } + @Test + @TestMetadata("kt55138.kt") + public void testKt55138() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/kt55138.kt"); + } + @Test @TestMetadata("nested.kt") public void testNested() throws Exception { @@ -6138,6 +6156,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/classes/inner/extensionWithOuter.kt"); } + @Test + @TestMetadata("innerClassDerivedFromOuterClass.kt") + public void testInnerClassDerivedFromOuterClass() throws Exception { + runTest("compiler/testData/codegen/box/classes/inner/innerClassDerivedFromOuterClass.kt"); + } + @Test @TestMetadata("instantiateInDerived.kt") public void testInstantiateInDerived() throws Exception { @@ -47371,6 +47395,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/sam/recordSubstitutedTypeForCallableSamParameter.kt"); } + @Test + @TestMetadata("samAsIndexInArrayAssignment.kt") + public void testSamAsIndexInArrayAssignment() throws Exception { + runTest("compiler/testData/codegen/box/sam/samAsIndexInArrayAssignment.kt"); + } + @Test @TestMetadata("samConstructorGenericSignature.kt") public void testSamConstructorGenericSignature() throws Exception {