From f38c0cf348a978e549357aa50a6675f79580cb83 Mon Sep 17 00:00:00 2001 From: Tianyu Geng Date: Tue, 16 Mar 2021 16:55:07 -0700 Subject: [PATCH] FIR IDE: run FIR highlighting test on all test data Similarly to FIR diagnostic tests. This commit enable all available test data and check the reported error messages by FIR. This helps identify some issues in formatting of FIR diagnostics. The changes on the test file are mechanically generated. Failed tests are disabled with `// IGNORE_FIR` and are re-enabled in the second commit. --- .../kotlin/generators/tests/GenerateTests.kt | 31 +- .../AbstractFirKotlinHighlightingPassTest.kt | 13 +- ...irKotlinHighlightingPassTestGenerated.java | 12 +- .../kotlin/test/uitls/IgnoreTests.kt | 50 +++- idea/testData/checker/Abstract.fir.kt | 174 +++++++++++ idea/testData/checker/AnnotationOnFile.fir.kt | 25 ++ .../checker/AnnotationSupressing.fir.kt | 32 ++ .../checker/AnonymousInitializers.fir.kt | 27 ++ .../BinaryCallsOnNullableValues.fir.kt | 31 ++ idea/testData/checker/Bounds.fir.kt | 10 + idea/testData/checker/Bounds2.fir.kt | 13 + .../checker/BoundsWithSubstitutors.fir.kt | 15 + idea/testData/checker/BreakContinue.fir.kt | 28 ++ idea/testData/checker/Builders.fir.kt | 117 ++++++++ idea/testData/checker/Casts.kt | 2 +- idea/testData/checker/ClassObjectInEnum.kt | 2 +- idea/testData/checker/ClassObjects.fir.kt | 31 ++ idea/testData/checker/Constants.fir.kt | 10 + idea/testData/checker/Constructors.fir.kt | 39 +++ idea/testData/checker/CyclicHierarchy.fir.kt | 30 ++ .../checker/ExposedContainerType.fir.kt | 17 ++ .../checker/ExposedInferredType.fir.kt | 19 ++ .../checker/ExtensionFunctions.fir.kt | 70 +++++ .../checker/ForRangeConventions.fir.kt | 82 +++++ .../FunctionOnlyOneTypeParametersList.kt | 4 +- .../checker/FunctionReturnTypes.fir.kt | 162 ++++++++++ .../checker/GenericArgumentConsistency.fir.kt | 42 +++ idea/testData/checker/IncDec.fir.kt | 46 +++ idea/testData/checker/IsExpressions.fir.kt | 7 + .../checker/JvmStaticUsagesRuntime.fir.kt | 56 ++++ idea/testData/checker/LocalObjects.kt | 5 +- .../checker/MainWithWarningOnUnusedParam.kt | 4 +- .../MainWithoutWarningOnUnusedParam.kt | 4 +- idea/testData/checker/MultipleBounds.fir.kt | 65 ++++ idea/testData/checker/MultipleModality.fir.kt | 9 + idea/testData/checker/NestedObjects.fir.kt | 28 ++ .../checker/NotFinishedGenericDeclaration.kt | 4 +- .../checker/NullAsAnnotationArgument.fir.kt | 10 + idea/testData/checker/Nullability.kt | 2 +- .../checker/ObjectLiteralInDelegate.fir.kt | 18 ++ idea/testData/checker/Objects.fir.kt | 28 ++ idea/testData/checker/Override.fir.kt | 40 +++ .../checker/OverridesAndGenerics.fir.kt | 35 +++ idea/testData/checker/PackageQualified.kt | 4 +- idea/testData/checker/PrimaryConstructors.kt | 2 +- .../checker/ProjectionsInSupertypes.fir.kt | 6 + idea/testData/checker/Properties.fir.kt | 25 ++ .../checker/QualifiedExpressions.fir.kt | 15 + idea/testData/checker/QualifiedThis.fir.kt | 22 ++ .../checker/QualifiedThisInClosures.fir.kt | 18 ++ idea/testData/checker/Redeclaration.fir.kt | 29 ++ idea/testData/checker/Redeclaration.kt | 1 - idea/testData/checker/Redeclarations.fir.kt | 12 + idea/testData/checker/Redeclarations.kt | 2 - idea/testData/checker/ResolveToJava.fir.kt | 48 +++ ...olveTypeInAnnotationArgumentRuntime.fir.kt | 6 + .../ReturnTypeMismatchOnOverride.fir.kt | 13 + .../checker/ReturnTypeMismatchOnOverride.kt | 4 +- idea/testData/checker/SafeInvoke.fir.kt | 10 + idea/testData/checker/Shadowing.fir.kt | 19 ++ idea/testData/checker/StringTemplates.fir.kt | 23 ++ .../checker/SupertypeListChecks.fir.kt | 49 +++ idea/testData/checker/SupertypeListChecks.kt | 2 - .../checker/TraitSupertypeList.fir.kt | 10 + idea/testData/checker/TraitSupertypeList.kt | 2 - .../checker/TypeArgumentsNotAllowed.fir.kt | 9 + .../checker/TypeArgumentsNotAllowed.kt | 2 + .../checker/TypeParameterBounds.fir.kt | 11 + idea/testData/checker/UnreachableCode.fir.kt | 161 ++++++++++ idea/testData/checker/Unresolved.fir.kt | 43 +++ idea/testData/checker/Unresolved.kt | 2 + idea/testData/checker/Unused.kt | 3 +- idea/testData/checker/Variance.fir.kt | 40 +++ idea/testData/checker/When.fir.kt | 45 +++ .../checker/WhenInEnumInExtensionProperty.kt | 5 +- .../testData/checker/WhenNonExhaustive.fir.kt | 65 ++++ .../fullPackageFQNameOnVisiblityError.fir.kt | 6 + .../incompleteTypeArgumentList.fir.kt | 5 + .../incompleteTypeArgumentList.kt | 4 +- ...ntiationOfInnerClassInQualifiedForm.fir.kt | 7 + .../lateinitOfATypeWithNullableUpperBound.kt | 4 +- .../nArgumentsExpectedMessage.fir.kt | 9 + .../nArgumentsExpectedMessage.kt | 4 +- .../noSubstitutedTypeParameter.fir.kt | 6 + ...operatorCallDiagnosticsOnInOperator.fir.kt | 8 + .../infos/CapturedConstructorParameter.kt | 2 +- .../checker/infos/CapturedInInlinedClosure.kt | 4 +- .../infos/PropertiesWithBackingFields.kt | 2 +- idea/testData/checker/infos/SmartCastOnIf.kt | 2 +- .../testData/checker/infos/SmartCastOnWhen.kt | 2 +- .../testData/checker/infos/SmartCastTarget.kt | 4 +- .../testData/checker/infos/SmartCastToEnum.kt | 2 +- idea/testData/checker/infos/SmartCasts.fir.kt | 282 ++++++++++++++++++ .../checker/infos/SmartCastsWithSafeAccess.kt | 2 +- idea/testData/checker/infos/Typos.fir.kt | 10 + .../infos/TyposInOverrideParams.fir.kt | 14 + idea/testData/checker/infos/WrapIntoRef.kt | 2 +- .../checker/infos/multipleResolvedCalls.kt | 2 +- .../checker/infos/smartCastOnElvis.kt | 4 +- .../checker/infos/threeImplicitReceivers.kt | 2 +- .../checker/infos/twoImplicitReceivers.kt | 2 +- ...32189returnTypeWithTypealiasSubtitution.kt | 2 +- .../checker/recovery/namelessMembers.fir.kt | 15 + .../checker/recovery/namelessMembers.kt | 4 +- .../namelessToplevelDeclarations.fir.kt | 24 ++ .../recovery/namelessToplevelDeclarations.kt | 4 +- .../recovery/returnInFileAnnotation.fir.kt | 1 + .../AmbiguityOnLazyTypeComputation.kt | 2 +- ...ationOnNamedParameterOfFunctionType.fir.kt | 3 + ...AnnotationOnParameterOfFunctionType.fir.kt | 5 + .../regression/AssignmentsUnderOperators.kt | 4 +- .../regression/BadParseForClass.fir.kt | 5 + .../ClassDeclarationAfterDot.fir.kt | 5 + .../regression/ClassDeclarationAfterDot2.kt | 2 +- .../ClassDeclarationAsExpression.fir.kt | 5 + .../ClassDeclarationAsExpression2.fir.kt | 1 + .../ClassDeclarationAsExpression3.fir.kt | 7 + .../checker/regression/CoercionToUnit.fir.kt | 9 + .../DescructuringDeclarationInForLoop.fir.kt | 3 + .../DestructuringDeclarationInLambda.kt | 4 +- .../checker/regression/DollarsInName.kt | 4 +- .../checker/regression/DoubleDefine.fir.kt | 66 ++++ .../regression/FunDeclarationAfterDot.fir.kt | 7 + .../FunctionLiteralInsideAnnotation.kt | 4 +- .../checker/regression/FunctionTypes.kt | 4 +- .../IncompleteClassDelegation.fir.kt | 15 + .../regression/InitializerInInterface.fir.kt | 6 + .../InterfaceDeclarationAsExpression.fir.kt | 5 + idea/testData/checker/regression/Jet11.fir.kt | 4 + idea/testData/checker/regression/Jet121.kt | 2 +- idea/testData/checker/regression/Jet124.kt | 2 +- idea/testData/checker/regression/Jet169.kt | 2 +- idea/testData/checker/regression/Jet183-1.kt | 4 +- idea/testData/checker/regression/Jet183.kt | 2 +- idea/testData/checker/regression/Jet53.kt | 2 +- idea/testData/checker/regression/Jet67.kt | 2 +- idea/testData/checker/regression/Jet68.kt | 4 +- idea/testData/checker/regression/Jet69.kt | 2 +- idea/testData/checker/regression/Jet72.kt | 2 +- .../checker/regression/OverrideResolution.kt | 2 +- .../PropertyDeclarationAsExpression.kt | 2 +- .../ScopeForSecondaryConstructors.kt | 3 +- .../regression/SpecififcityByReceiver.kt | 4 +- .../WrongTraceInCallResolver.fir.kt | 9 + ...ariableAsFunctionWithAnonymousObjectArg.kt | 4 +- ...callVariableAsFunctionWithLambdaArg.fir.kt | 5 + .../checker/regression/createInnerInstance.kt | 2 +- .../extensionMemberInClassObject.kt | 4 +- ...leClassLiteralInAnnotationArguments.fir.kt | 6 + idea/testData/checker/regression/kt251.fir.kt | 33 ++ idea/testData/checker/regression/kt303.fir.kt | 11 + .../testData/checker/regression/kt9887.fir.kt | 7 + idea/testData/checker/regression/kt9887.kt | 4 +- .../objectLiteralInSupertypeList.kt | 4 +- .../rendering/TypeInferenceError.fir.kt | 13 + .../checker/trivialHierarchyLoop.fir.kt | 3 + .../KotlinHighlightWolfPassTestGenerated.java | 2 +- .../KotlinHighlightingPassTestGenerated.java | 22 +- 158 files changed, 2802 insertions(+), 130 deletions(-) create mode 100644 idea/testData/checker/Abstract.fir.kt create mode 100644 idea/testData/checker/AnnotationOnFile.fir.kt create mode 100644 idea/testData/checker/AnnotationSupressing.fir.kt create mode 100644 idea/testData/checker/AnonymousInitializers.fir.kt create mode 100644 idea/testData/checker/BinaryCallsOnNullableValues.fir.kt create mode 100644 idea/testData/checker/Bounds.fir.kt create mode 100644 idea/testData/checker/Bounds2.fir.kt create mode 100644 idea/testData/checker/BoundsWithSubstitutors.fir.kt create mode 100644 idea/testData/checker/BreakContinue.fir.kt create mode 100644 idea/testData/checker/Builders.fir.kt create mode 100644 idea/testData/checker/ClassObjects.fir.kt create mode 100644 idea/testData/checker/Constants.fir.kt create mode 100644 idea/testData/checker/Constructors.fir.kt create mode 100644 idea/testData/checker/CyclicHierarchy.fir.kt create mode 100644 idea/testData/checker/ExposedContainerType.fir.kt create mode 100644 idea/testData/checker/ExposedInferredType.fir.kt create mode 100644 idea/testData/checker/ExtensionFunctions.fir.kt create mode 100644 idea/testData/checker/ForRangeConventions.fir.kt create mode 100644 idea/testData/checker/FunctionReturnTypes.fir.kt create mode 100644 idea/testData/checker/GenericArgumentConsistency.fir.kt create mode 100644 idea/testData/checker/IncDec.fir.kt create mode 100644 idea/testData/checker/IsExpressions.fir.kt create mode 100644 idea/testData/checker/JvmStaticUsagesRuntime.fir.kt create mode 100644 idea/testData/checker/MultipleBounds.fir.kt create mode 100644 idea/testData/checker/MultipleModality.fir.kt create mode 100644 idea/testData/checker/NestedObjects.fir.kt create mode 100644 idea/testData/checker/NullAsAnnotationArgument.fir.kt create mode 100644 idea/testData/checker/ObjectLiteralInDelegate.fir.kt create mode 100644 idea/testData/checker/Objects.fir.kt create mode 100644 idea/testData/checker/Override.fir.kt create mode 100644 idea/testData/checker/OverridesAndGenerics.fir.kt create mode 100644 idea/testData/checker/ProjectionsInSupertypes.fir.kt create mode 100644 idea/testData/checker/Properties.fir.kt create mode 100644 idea/testData/checker/QualifiedExpressions.fir.kt create mode 100644 idea/testData/checker/QualifiedThis.fir.kt create mode 100644 idea/testData/checker/QualifiedThisInClosures.fir.kt create mode 100644 idea/testData/checker/Redeclaration.fir.kt create mode 100644 idea/testData/checker/Redeclarations.fir.kt create mode 100644 idea/testData/checker/ResolveToJava.fir.kt create mode 100644 idea/testData/checker/ResolveTypeInAnnotationArgumentRuntime.fir.kt create mode 100644 idea/testData/checker/ReturnTypeMismatchOnOverride.fir.kt create mode 100644 idea/testData/checker/SafeInvoke.fir.kt create mode 100644 idea/testData/checker/Shadowing.fir.kt create mode 100644 idea/testData/checker/StringTemplates.fir.kt create mode 100644 idea/testData/checker/SupertypeListChecks.fir.kt create mode 100644 idea/testData/checker/TraitSupertypeList.fir.kt create mode 100644 idea/testData/checker/TypeArgumentsNotAllowed.fir.kt create mode 100644 idea/testData/checker/TypeParameterBounds.fir.kt create mode 100644 idea/testData/checker/UnreachableCode.fir.kt create mode 100644 idea/testData/checker/Unresolved.fir.kt create mode 100644 idea/testData/checker/Variance.fir.kt create mode 100644 idea/testData/checker/When.fir.kt create mode 100644 idea/testData/checker/WhenNonExhaustive.fir.kt create mode 100644 idea/testData/checker/diagnosticsMessage/fullPackageFQNameOnVisiblityError.fir.kt create mode 100644 idea/testData/checker/diagnosticsMessage/incompleteTypeArgumentList.fir.kt create mode 100644 idea/testData/checker/diagnosticsMessage/instantiationOfInnerClassInQualifiedForm.fir.kt create mode 100644 idea/testData/checker/diagnosticsMessage/nArgumentsExpectedMessage.fir.kt create mode 100644 idea/testData/checker/diagnosticsMessage/noSubstitutedTypeParameter.fir.kt create mode 100644 idea/testData/checker/diagnosticsMessage/operatorCallDiagnosticsOnInOperator.fir.kt create mode 100644 idea/testData/checker/infos/SmartCasts.fir.kt create mode 100644 idea/testData/checker/infos/Typos.fir.kt create mode 100644 idea/testData/checker/infos/TyposInOverrideParams.fir.kt create mode 100644 idea/testData/checker/recovery/namelessMembers.fir.kt create mode 100644 idea/testData/checker/recovery/namelessToplevelDeclarations.fir.kt create mode 100644 idea/testData/checker/recovery/returnInFileAnnotation.fir.kt create mode 100644 idea/testData/checker/regression/AnnotationOnNamedParameterOfFunctionType.fir.kt create mode 100644 idea/testData/checker/regression/AnnotationOnParameterOfFunctionType.fir.kt create mode 100644 idea/testData/checker/regression/BadParseForClass.fir.kt create mode 100644 idea/testData/checker/regression/ClassDeclarationAfterDot.fir.kt create mode 100644 idea/testData/checker/regression/ClassDeclarationAsExpression.fir.kt create mode 100644 idea/testData/checker/regression/ClassDeclarationAsExpression2.fir.kt create mode 100644 idea/testData/checker/regression/ClassDeclarationAsExpression3.fir.kt create mode 100644 idea/testData/checker/regression/CoercionToUnit.fir.kt create mode 100644 idea/testData/checker/regression/DescructuringDeclarationInForLoop.fir.kt create mode 100644 idea/testData/checker/regression/DoubleDefine.fir.kt create mode 100644 idea/testData/checker/regression/FunDeclarationAfterDot.fir.kt create mode 100644 idea/testData/checker/regression/IncompleteClassDelegation.fir.kt create mode 100644 idea/testData/checker/regression/InitializerInInterface.fir.kt create mode 100644 idea/testData/checker/regression/InterfaceDeclarationAsExpression.fir.kt create mode 100644 idea/testData/checker/regression/Jet11.fir.kt create mode 100644 idea/testData/checker/regression/WrongTraceInCallResolver.fir.kt create mode 100644 idea/testData/checker/regression/callVariableAsFunctionWithLambdaArg.fir.kt create mode 100644 idea/testData/checker/regression/javaStyleClassLiteralInAnnotationArguments.fir.kt create mode 100644 idea/testData/checker/regression/kt251.fir.kt create mode 100644 idea/testData/checker/regression/kt303.fir.kt create mode 100644 idea/testData/checker/regression/kt9887.fir.kt create mode 100644 idea/testData/checker/rendering/TypeInferenceError.fir.kt create mode 100644 idea/testData/checker/trivialHierarchyLoop.fir.kt diff --git a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt index 953d110f52f..05db9ff3f56 100644 --- a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt +++ b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt @@ -204,6 +204,7 @@ import org.jetbrains.kotlinx.serialization.idea.AbstractSerializationQuickFixTes fun main(args: Array) { System.setProperty("java.awt.headless", "true") generateTestGroupSuite(args) { + val excludedFirTestdataPattern = "^(.+)\\.fir\\.kts?\$" testGroup("idea/jvm-debugger/jvm-debugger-test/test", "idea/jvm-debugger/jvm-debugger-test/testData") { testClass { model( @@ -323,18 +324,18 @@ fun main(args: Array) { } testClass { - model("checker", recursive = false) - model("checker/regression") - model("checker/recovery") - model("checker/rendering") - model("checker/scripts", extension = "kts") - model("checker/duplicateJvmSignature") - model("checker/infos", testMethod = "doTestWithInfos") - model("checker/diagnosticsMessage") + model("checker", recursive = false, excludedPattern = excludedFirTestdataPattern) + model("checker/regression", excludedPattern = excludedFirTestdataPattern) + model("checker/recovery", excludedPattern = excludedFirTestdataPattern) + model("checker/rendering", excludedPattern = excludedFirTestdataPattern) + model("checker/scripts", extension = "kts", excludedPattern = excludedFirTestdataPattern) + model("checker/duplicateJvmSignature", excludedPattern = excludedFirTestdataPattern) + model("checker/infos", testMethod = "doTestWithInfos", excludedPattern = excludedFirTestdataPattern) + model("checker/diagnosticsMessage", excludedPattern = excludedFirTestdataPattern) } testClass { - model("checker/wolf") + model("checker/wolf", excludedPattern = excludedFirTestdataPattern) } testClass { @@ -1126,12 +1127,12 @@ fun main(args: Array) { } testClass { - model("checker", recursive = false) - model("checker/regression") - model("checker/recovery") - model("checker/rendering") - model("checker/infos") - model("checker/diagnosticsMessage") + model("checker", recursive = false, excludedPattern = excludedFirTestdataPattern) + model("checker/regression", excludedPattern = excludedFirTestdataPattern) + model("checker/recovery", excludedPattern = excludedFirTestdataPattern) + model("checker/rendering", excludedPattern = excludedFirTestdataPattern) + model("checker/infos", excludedPattern = excludedFirTestdataPattern) + model("checker/diagnosticsMessage", excludedPattern = excludedFirTestdataPattern) } diff --git a/idea/idea-fir/tests/org/jetbrains/kotlin/checkers/AbstractFirKotlinHighlightingPassTest.kt b/idea/idea-fir/tests/org/jetbrains/kotlin/checkers/AbstractFirKotlinHighlightingPassTest.kt index c58d50a881c..485c2a5f502 100644 --- a/idea/idea-fir/tests/org/jetbrains/kotlin/checkers/AbstractFirKotlinHighlightingPassTest.kt +++ b/idea/idea-fir/tests/org/jetbrains/kotlin/checkers/AbstractFirKotlinHighlightingPassTest.kt @@ -11,17 +11,26 @@ import org.jetbrains.kotlin.idea.test.withCustomCompilerOptions import org.jetbrains.kotlin.idea.withPossiblyDisabledDuplicatedFirSourceElementsException import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.test.uitls.IgnoreTests +import org.jetbrains.kotlin.test.uitls.IgnoreTests.DIRECTIVES +import org.jetbrains.kotlin.test.uitls.IgnoreTests.cleanUpIdenticalFirTestFile +import org.jetbrains.kotlin.test.uitls.IgnoreTests.getFirTestFile import java.io.File abstract class AbstractFirKotlinHighlightingPassTest : AbstractKotlinHighlightingPassTest() { + override val captureExceptions: Boolean = false override fun isFirPlugin(): Boolean = true + override fun fileName(): String = getFirTestFile(originalTestFile()).name + + private fun originalTestFile(): File = testDataFile(super.fileName()) + override fun doTest(filePath: String) { - IgnoreTests.runTestIfEnabledByFileDirective(testDataFilePath(), IgnoreTests.DIRECTIVES.FIR_COMPARISON) { + IgnoreTests.runTestIfNotDisabledByFileDirective(originalTestFile().toPath(), DIRECTIVES.IGNORE_FIR) { myFixture.configureByFile(fileName()) checkHighlighting(checkWarnings = false, checkInfos = false, checkWeakWarnings = false) + cleanUpIdenticalFirTestFile(originalTestFile()) } } @@ -46,4 +55,4 @@ abstract class AbstractFirKotlinHighlightingPassTest : AbstractKotlinHighlightin } } } -} \ No newline at end of file +} diff --git a/idea/idea-fir/tests/org/jetbrains/kotlin/checkers/FirKotlinHighlightingPassTestGenerated.java b/idea/idea-fir/tests/org/jetbrains/kotlin/checkers/FirKotlinHighlightingPassTestGenerated.java index 6b27c7511c8..c85c7b94d27 100644 --- a/idea/idea-fir/tests/org/jetbrains/kotlin/checkers/FirKotlinHighlightingPassTestGenerated.java +++ b/idea/idea-fir/tests/org/jetbrains/kotlin/checkers/FirKotlinHighlightingPassTestGenerated.java @@ -33,7 +33,7 @@ public class FirKotlinHighlightingPassTestGenerated extends AbstractFirKotlinHig } public void testAllFilesPresentInChecker() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/checker"), Pattern.compile("^(.+)\\.kt$"), null, false); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/checker"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), false); } @TestMetadata("AnnotationOnFile.kt") @@ -376,7 +376,7 @@ public class FirKotlinHighlightingPassTestGenerated extends AbstractFirKotlinHig } public void testAllFilesPresentInRegression() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/checker/regression"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/checker/regression"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); } @TestMetadata("AmbiguityOnLazyTypeComputation.kt") @@ -619,7 +619,7 @@ public class FirKotlinHighlightingPassTestGenerated extends AbstractFirKotlinHig } public void testAllFilesPresentInRecovery() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/checker/recovery"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/checker/recovery"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); } @TestMetadata("namelessMembers.kt") @@ -647,7 +647,7 @@ public class FirKotlinHighlightingPassTestGenerated extends AbstractFirKotlinHig } public void testAllFilesPresentInRendering() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/checker/rendering"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/checker/rendering"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); } @TestMetadata("TypeInferenceError.kt") @@ -665,7 +665,7 @@ public class FirKotlinHighlightingPassTestGenerated extends AbstractFirKotlinHig } public void testAllFilesPresentInInfos() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/checker/infos"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/checker/infos"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); } @TestMetadata("CapturedConstructorParameter.kt") @@ -758,7 +758,7 @@ public class FirKotlinHighlightingPassTestGenerated extends AbstractFirKotlinHig } public void testAllFilesPresentInDiagnosticsMessage() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/checker/diagnosticsMessage"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/checker/diagnosticsMessage"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); } @TestMetadata("fullPackageFQNameOnVisiblityError.kt") diff --git a/idea/idea-frontend-independent/tests/org/jetbrains/kotlin/test/uitls/IgnoreTests.kt b/idea/idea-frontend-independent/tests/org/jetbrains/kotlin/test/uitls/IgnoreTests.kt index b0efb028c1e..398624fa5be 100644 --- a/idea/idea-frontend-independent/tests/org/jetbrains/kotlin/test/uitls/IgnoreTests.kt +++ b/idea/idea-frontend-independent/tests/org/jetbrains/kotlin/test/uitls/IgnoreTests.kt @@ -5,10 +5,14 @@ package org.jetbrains.kotlin.test.uitls +import com.intellij.openapi.util.io.FileUtil +import org.jetbrains.kotlin.test.KtAssert +import java.io.File import java.nio.file.Files import java.nio.file.Path object IgnoreTests { + private val isTeamCityBuild: Boolean = System.getProperty("TEAMCITY_VERSION") != null private const val INSERT_DIRECTIVE_AUTOMATICALLY = false // TODO use environment variable instead private const val ALWAYS_CONSIDER_TEST_AS_PASSING = false // TODO use environment variable instead @@ -173,9 +177,53 @@ object IgnoreTests { const val FIR_COMPARISON_MULTILINE_COMMENT = "/* FIR_COMPARISON */" const val IGNORE_FIR = "// IGNORE_FIR" const val FIX_ME = "// FIX_ME: " + const val FIR_IDENTICAL = "// FIR_IDENTICAL" } enum class DirectivePosition { FIRST_LINE_IN_FILE, LAST_LINE_IN_FILE } -} \ No newline at end of file + + fun getFirTestFile(originalTestFile: File): File { + if (originalTestFile.readText().startsWith(DIRECTIVES.FIR_IDENTICAL)) { + return originalTestFile + } + val firTestFile = deriveFirTestFile(originalTestFile) + if (!firTestFile.exists()) { + FileUtil.copy(originalTestFile, firTestFile) + } + return firTestFile + } + + + fun cleanUpIdenticalFirTestFile(originalTestFile: File) { + val firTestFile = deriveFirTestFile(originalTestFile) + if (firTestFile.exists() && firTestFile.readText().trim() == originalTestFile.readText().trim()) { + val message = if (isTeamCityBuild) { + "Please remove .fir.kt dump and add // FIR_IDENTICAL to test source" + } else { + // The FIR test file is identical with the original file. We should remove the FIR file and mark "FIR_IDENTICAL" in the + // original file + firTestFile.delete() + val content = originalTestFile.readText() + originalTestFile.writer().use { + it.appendLine(DIRECTIVES.FIR_IDENTICAL) + it.append(content) + } + + "Deleted .fir.kt dump, added // FIR_IDENTICAL to test source" + } + KtAssert.fail( + """ + Dumps via FIR & via old FE are the same. + $message + Please re-run the test now + """.trimIndent() + ) + } + } + + private fun deriveFirTestFile(originalTestFile: File) = + originalTestFile.parentFile.resolve(originalTestFile.name.removeSuffix(".kt") + ".fir.kt") + +} diff --git a/idea/testData/checker/Abstract.fir.kt b/idea/testData/checker/Abstract.fir.kt new file mode 100644 index 00000000000..5d6d1afe539 --- /dev/null +++ b/idea/testData/checker/Abstract.fir.kt @@ -0,0 +1,174 @@ +package abstract + +class MyClass() { + //properties + + val a: Int + val a1: Int = 1 + abstract val a2: Int + abstract val a3: Int = 1 + + var b: Int private set + var b1: Int = 0; private set + abstract var b2: Int private set + abstract var b3: Int = 0; private set + + var c: Int set(v: Int) { field = v } + var c1: Int = 0; set(v: Int) { field = v } + abstract var c2: Int set(v: Int) { field = v } + abstract var c3: Int = 0; set(v: Int) { field = v } + + val e: Int get() = a + val e1: Int = 0; get() = a + abstract val e2: Int get() = a + abstract val e3: Int = 0; get() = a + + //methods + + fun f() + fun g() {} + abstract fun h() + abstract fun j() {} +} + +abstract class MyAbstractClass() { + //properties + + val a: Int + val a1: Int = 1 + abstract val a2: Int + abstract val a3: Int = 1 + + var b: Int private set + var b1: Int = 0; private set + abstract var b2: Int private set + abstract var b3: Int = 0; private set + + var c: Int set(v: Int) { field = v } + var c1: Int = 0; set(v: Int) { field = v } + abstract var c2: Int set(v: Int) { field = v } + abstract var c3: Int = 0; set(v: Int) { field = v } + + val e: Int get() = a + val e1: Int = 0; get() = a + abstract val e2: Int get() = a + abstract val e3: Int = 0; get() = a + + //methods + + fun f() + fun g() {} + abstract fun h() + abstract fun j() {} +} + +interface MyTrait { + //properties + + val a: Int + val a1: Int = 1 + abstract val a2: Int + abstract val a3: Int = 1 + + var b: Int private set + var b1: Int = 0; private set + abstract var b2: Int private set + abstract var b3: Int = 0; private set + + var c: Int set(v: Int) { field = v } + var c1: Int = 0; set(v: Int) { field = v } + abstract var c2: Int set(v: Int) { field = v } + abstract var c3: Int = 0; set(v: Int) { field = v } + + val e: Int get() = a + val e1: Int = 0; get() = a + abstract val e2: Int get() = a + abstract val e3: Int = 0; get() = a + + //methods + + fun f() + fun g() {} + abstract fun h() + abstract fun j() {} +} + +enum class MyEnum() { + ; + //properties + + val a: Int + val a1: Int = 1 + abstract val a2: Int + abstract val a3: Int = 1 + + var b: Int private set + var b1: Int = 0; private set + abstract var b2: Int private set + abstract var b3: Int = 0; private set + + var c: Int set(v: Int) { field = v } + var c1: Int = 0; set(v: Int) { field = v } + abstract var c2: Int set(v: Int) { field = v } + abstract var c3: Int = 0; set(v: Int) { field = v } + + val e: Int get() = a + val e1: Int = 0; get() = a + abstract val e2: Int get() = a + abstract val e3: Int = 0; get() = a + + //methods + + fun f() + fun g() {} + abstract fun h() + abstract fun j() {} +} + +abstract enum class MyAbstractEnum() {} + +//properties + +val a: Int +val a1: Int = 1 +abstract val a2: Int +abstract val a3: Int = 1 + +var b: Int private set +var b1: Int = 0; private set +abstract var b2: Int private set +abstract var b3: Int = 0; private set + +var c: Int set(v: Int) { field = v } +var c1: Int = 0; set(v: Int) { field = v } +abstract var c2: Int set(v: Int) { field = v } +abstract var c3: Int = 0; set(v: Int) { field = v } + +val e: Int get() = a +val e1: Int = 0; get() = a +abstract val e2: Int get() = a +abstract val e3: Int = 0; get() = a + +//methods + +fun f() +fun g() {} +abstract fun h() +abstract fun j() {} + +//creating an instance +abstract class B1( + val i: Int, + val s: String +) { +} + +class B2() : B1(1, "r") {} + +abstract class B3(i: Int) { +} + +fun foo(a: B3) { + val a = B3(1) + val b = B1(2, "s") +} diff --git a/idea/testData/checker/AnnotationOnFile.fir.kt b/idea/testData/checker/AnnotationOnFile.fir.kt new file mode 100644 index 00000000000..313cdd269d9 --- /dev/null +++ b/idea/testData/checker/AnnotationOnFile.fir.kt @@ -0,0 +1,25 @@ +@file:kotlin.Deprecated("message") +@file:Suppress(BAR) +@file:Suppress(BAZ) + +@kotlin.Deprecated("message") +@Suppress(BAR) +@Suppress(BAZ) + +@file:myAnnotation(1, "string") +@file:boo.myAnnotation(1, BAR) +@file:myAnnotation(N, BAZ) + +@myAnnotation(1, "string") +@boo.myAnnotation(1, "string") +@myAnnotation(N, BAZ) + +package boo + +const val BAZ = "baz" +const val N = 0 + +@Target(AnnotationTarget.FILE) +@Retention(AnnotationRetention.SOURCE) +@Repeatable +annotation class myAnnotation(val i: Int, val s: String) diff --git a/idea/testData/checker/AnnotationSupressing.fir.kt b/idea/testData/checker/AnnotationSupressing.fir.kt new file mode 100644 index 00000000000..46037a0394f --- /dev/null +++ b/idea/testData/checker/AnnotationSupressing.fir.kt @@ -0,0 +1,32 @@ +annotation class A(val i: Int) +annotation class Z(val i: Int) + +@Z("BAD") @Suppress("TYPE_MISMATCH") +fun some0() {} + +@Z("BAD") @Z("BAD") @Suppress("TYPE_MISMATCH") +fun some01() {} + +@Suppress("TYPE_MISMATCH") @Z("BAD") +fun some1() { +} + +@Suppress("TYPE_MISMATCH") @Z("BAD") @Z("BAD") +fun some11() { +} + +@A("BAD") @Suppress("TYPE_MISMATCH") +fun some2() { +} + +@Suppress("TYPE_MISMATCH") @A("BAD") +fun some3() { +} + +@A("BAD") @A("BAD") +fun some4() { +} + +@Z("BAD") +fun someN() { +} diff --git a/idea/testData/checker/AnonymousInitializers.fir.kt b/idea/testData/checker/AnonymousInitializers.fir.kt new file mode 100644 index 00000000000..170a1ea0db0 --- /dev/null +++ b/idea/testData/checker/AnonymousInitializers.fir.kt @@ -0,0 +1,27 @@ +interface NoC { + init { + + } + + val a : Int get() = 1 + + init { + + } +} + +class WithC() { + val x : Int = 42 + init { + val b = x + + } + + val a : Int get() = 1 + + init { + val z = b + val zz = x + } + +} diff --git a/idea/testData/checker/BinaryCallsOnNullableValues.fir.kt b/idea/testData/checker/BinaryCallsOnNullableValues.fir.kt new file mode 100644 index 00000000000..d21cde0b76d --- /dev/null +++ b/idea/testData/checker/BinaryCallsOnNullableValues.fir.kt @@ -0,0 +1,31 @@ +class A() { + override fun equals(a : Any?) : Boolean = false +} + +fun f(): Unit { + var x: Int? = 1 + x = 1 + x + 1 + x.plus(1) + x < 1 + x += 1 + + x == 1 + x != 1 + + A() == 1 + + x === "1" + x !== "1" + + x === 1 + x !== 1 + + x..2 + x in 1..2 + + val y : Boolean? = true + false || y + y && true + y && 1 +} diff --git a/idea/testData/checker/Bounds.fir.kt b/idea/testData/checker/Bounds.fir.kt new file mode 100644 index 00000000000..e6b2b1508c8 --- /dev/null +++ b/idea/testData/checker/Bounds.fir.kt @@ -0,0 +1,10 @@ + open class A {} + open class B() + + class Pair + + abstract class C, X : (B) -> Pair, B>>() : B() { // 2 errors + val a = B() // error + + abstract val x : (B) -> B + } diff --git a/idea/testData/checker/Bounds2.fir.kt b/idea/testData/checker/Bounds2.fir.kt new file mode 100644 index 00000000000..c1f8aa0b20a --- /dev/null +++ b/idea/testData/checker/Bounds2.fir.kt @@ -0,0 +1,13 @@ +fun test() { + foo() + foo() + bar() + bar() + bar() + bar() + 1.buzz() +} + +fun foo() {} +fun bar() {} +fun Int.buzz() : Unit {} diff --git a/idea/testData/checker/BoundsWithSubstitutors.fir.kt b/idea/testData/checker/BoundsWithSubstitutors.fir.kt new file mode 100644 index 00000000000..bb18fd0b503 --- /dev/null +++ b/idea/testData/checker/BoundsWithSubstitutors.fir.kt @@ -0,0 +1,15 @@ +// COMPILER_ARGUMENTS: -XXLanguage:-NewInference + + open class A + class B>() + + class C : A() + + val a = B() + val a1 = B() + + class X() + + val b = X, C>>() + val b0 = X() + val b1 = X, String>>() diff --git a/idea/testData/checker/BreakContinue.fir.kt b/idea/testData/checker/BreakContinue.fir.kt new file mode 100644 index 00000000000..d41befbded7 --- /dev/null +++ b/idea/testData/checker/BreakContinue.fir.kt @@ -0,0 +1,28 @@ +class C { + + fun f (a : Boolean, b : Boolean) { + b@ (while (true) + a@ { + break@f + break + break@b + break@a + }) + + continue + + b@ (while (true) + a@ { + continue@f + continue + continue@b + continue@a + }) + + break + + continue@f + break@f + } + +} diff --git a/idea/testData/checker/Builders.fir.kt b/idea/testData/checker/Builders.fir.kt new file mode 100644 index 00000000000..fa639fe2640 --- /dev/null +++ b/idea/testData/checker/Builders.fir.kt @@ -0,0 +1,117 @@ +package html + +import java.util.* + + interface Factory { + fun create() : T + } + + interface Element + + class TextElement(val text : String) : Element + + abstract class Tag(val name : String) : Element { + val children = ArrayList() + val attributes = HashMap() + + protected fun initTag(init : T.() -> Unit) : T + { + val tag = T.create() + tag.init() + children.add(tag) + return tag + } + } + + abstract class TagWithText(name : String) : Tag(name) { + operator fun String.unaryPlus() { + children.add(TextElement(this)) + } + } + + class HTML() : TagWithText("html") { + companion object : Factory { + override fun create() = HTML() + } + + fun head(init : Head.() -> Unit) = initTag(init) + + fun body(init : Body.() -> Unit) = initTag(init) + } + + class Head() : TagWithText("head") { + companion object : Factory { + override fun create() = Head() + } + + fun title(init : Title.() -> Unit) = initTag(init) + } + + class Title() : TagWithText("title") + + abstract class BodyTag(name : String) : TagWithText(name) { + } + + class Body() : BodyTag("body") { + companion object : Factory<Body> { + override fun create() = Body() + } + + fun b(init : B.() -> Unit) = initTag<B>(init) + fun p(init : P.() -> Unit) = initTag<P>(init) + fun h1(init : H1.() -> Unit) = initTag<H1>(init) + fun a(href : String, init : A.() -> Unit) { + val a = initTag<A>(init) + a.href = href + } + } + + class B() : BodyTag("b") + class P() : BodyTag("p") + class H1() : BodyTag("h1") + class A() : BodyTag("a") { + var href : String? + get() = attributes["href"] + set(value) { + if (value != null) + attributes["href"] = value + } + } + + operator fun MutableMap<String, String>.set(key : String, value : String) = this.put(key, value) + + fun html(init : HTML.() -> Unit) : HTML { + val html = HTML() + html.init() + return html + } + +fun result(args : Array<String>) = + html { + head { + title {+"XML encoding with Groovy"} + } + body { + h1 {+"XML encoding with Groovy"} + p {+"this format can be used as an alternative markup to XML"} + + // an element with attributes and text content + a(href = "https://groovy.codehaus.org") {+"Groovy"} + + // mixed content + p { + +"This is some" + b {+"mixed"} + +"text. For more see the" + a(href = "https://groovy.codehaus.org") {+"Groovy"} + +"project" + } + p {+"some text"} + + // content generated by + p { + for (arg in args) + +arg + } + } + } diff --git a/idea/testData/checker/Casts.kt b/idea/testData/checker/Casts.kt index b5ad02fc9c9..db6aac6896c 100644 --- a/idea/testData/checker/Casts.kt +++ b/idea/testData/checker/Casts.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IDENTICAL fun <T> checkSubtype(t: T) = t diff --git a/idea/testData/checker/ClassObjectInEnum.kt b/idea/testData/checker/ClassObjectInEnum.kt index 3bd384bcbcd..a014556cf66 100644 --- a/idea/testData/checker/ClassObjectInEnum.kt +++ b/idea/testData/checker/ClassObjectInEnum.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IDENTICAL enum class E { ENTRY; diff --git a/idea/testData/checker/ClassObjects.fir.kt b/idea/testData/checker/ClassObjects.fir.kt new file mode 100644 index 00000000000..ddc70b8f920 --- /dev/null +++ b/idea/testData/checker/ClassObjects.fir.kt @@ -0,0 +1,31 @@ +package Jet86 + +class A { + companion object { + val x = 1 + } + <error descr="[MANY_COMPANION_OBJECTS] Only one companion object is allowed per class">companion</error> object Another { // error + val x = 1 + } +} + +class B() { + val x = 12 +} + +object b { + companion object { + val x = 1 + } + // error +} + +val a = A.x +val c = B.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: x">x</error> +val d = b.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: x">x</error> + +val s = System // error +fun test() { + System.out.println() + java.lang.System.out.println() +} diff --git a/idea/testData/checker/Constants.fir.kt b/idea/testData/checker/Constants.fir.kt new file mode 100644 index 00000000000..c7b35013476 --- /dev/null +++ b/idea/testData/checker/Constants.fir.kt @@ -0,0 +1,10 @@ +fun <T> checkSubtype(t: T) = t + +fun test() { + checkSubtype<Byte>(1) + checkSubtype<Int>(1) + <error descr="[INAPPLICABLE_CANDIDATE] Inapplicable candidate(s): /checkSubtype">checkSubtype</error><Double>(1) + 1 as Byte + 1 as Int + 1 as Double +} diff --git a/idea/testData/checker/Constructors.fir.kt b/idea/testData/checker/Constructors.fir.kt new file mode 100644 index 00000000000..d09dcc748c5 --- /dev/null +++ b/idea/testData/checker/Constructors.fir.kt @@ -0,0 +1,39 @@ + +open class NoC +class NoC1 : NoC() + +class WithC0() : NoC() +open class WithC1() : NoC() +class NoC2 : <error descr="[SUPERTYPE_NOT_INITIALIZED] This type has a constructor, and thus must be initialized here">WithC1</error> +class NoC3 : WithC1() +class WithC2() : <error descr="[SUPERTYPE_NOT_INITIALIZED] This type has a constructor, and thus must be initialized here">WithC1</error> + +class NoPC { +} + +class WithPC0() { +} + +class WithPC1(a : Int) { +} + + +class Foo() : WithPC0(), <error descr="Type expected"><error descr="[SYNTAX] Syntax error">this</error></error>() { + +} + +class WithCPI_Dup(x : Int) { + <error descr="[MUST_BE_INITIALIZED_OR_BE_ABSTRACT] Property must be initialized or be abstract">var x : Int</error> +} + +class WithCPI(x : Int) { + val a = 1 + val xy : Int = x +} + +class NoCPI { + val a = 1 + var ab = <error descr="[PROPERTY_INITIALIZER_NO_BACKING_FIELD] Initializer is not allowed here because this property has no backing field">1</error> + get() = 1 + set(v) {} +} diff --git a/idea/testData/checker/CyclicHierarchy.fir.kt b/idea/testData/checker/CyclicHierarchy.fir.kt new file mode 100644 index 00000000000..90756e11de4 --- /dev/null +++ b/idea/testData/checker/CyclicHierarchy.fir.kt @@ -0,0 +1,30 @@ +interface A { + fun foo() {} +} +interface B : A, E {} +interface C : <error descr="[OTHER_ERROR] Unknown (other) error">B</error> {} +interface D : <error descr="[OTHER_ERROR] Unknown (other) error">B</error> {} +interface E : F {} +interface F : D, C {} +interface G : F {} +interface H : F {} + +val a : A? = null +val b : B? = null +val c : C? = null +val d : D? = null +val e : E? = null +val f : F? = null +val g : G? = null +val h : H? = null + +fun test() { + a?.foo() + b?.foo() + c?.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: foo">foo</error>() + d?.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: foo">foo</error>() + e?.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: foo">foo</error>() + f?.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: foo">foo</error>() + g?.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: foo">foo</error>() + h?.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: foo">foo</error>() +} diff --git a/idea/testData/checker/ExposedContainerType.fir.kt b/idea/testData/checker/ExposedContainerType.fir.kt new file mode 100644 index 00000000000..b545630cc34 --- /dev/null +++ b/idea/testData/checker/ExposedContainerType.fir.kt @@ -0,0 +1,17 @@ +class A { + internal companion object { + class B { + class C + interface D + companion object {} + } + } +} + +fun <error descr="[EXPOSED_RECEIVER_TYPE] public member exposes its internal receiver type 'C'">A.Companion.B.C</error>.foo() {} + +interface E : <error descr="[EXPOSED_SUPER_INTERFACE] public sub-interface exposes its internal supertype 'D'">A.Companion.B.D</error> + +val <error descr="[EXPOSED_PROPERTY_TYPE] public property exposes its internal type 'Companion'">x</error> = A.Companion.B + +class F<T : <error descr="[EXPOSED_TYPE_PARAMETER_BOUND] public generic exposes its internal parameter bound type 'B'">A.Companion.B</error>>(val x: T) diff --git a/idea/testData/checker/ExposedInferredType.fir.kt b/idea/testData/checker/ExposedInferredType.fir.kt new file mode 100644 index 00000000000..1609795fe2b --- /dev/null +++ b/idea/testData/checker/ExposedInferredType.fir.kt @@ -0,0 +1,19 @@ +private class A + +open class B<T>(val x: T) + +class C(<error descr="[EXPOSED_PARAMETER_TYPE] public function exposes its private parameter type 'A'">x: A</error>): <error descr="[EXPOSED_SUPER_CLASS] public subclass exposes its private supertype 'A'">B<A></error>(x) + +private class D { + class E +} + +fun <error descr="[EXPOSED_FUNCTION_RETURN_TYPE] public function exposes its private return type 'A'">create</error>() = A() + +fun <error descr="[EXPOSED_FUNCTION_RETURN_TYPE] public function exposes its private return type 'A'">create</error>(<error descr="[EXPOSED_PARAMETER_TYPE] public function exposes its private parameter type 'A'">a: A</error>) = B(a) + +val <error descr="[EXPOSED_PROPERTY_TYPE] public property exposes its private type 'A'">x</error> = create() + +val <error descr="[EXPOSED_PROPERTY_TYPE] public property exposes its private type 'A'">y</error> = create(x) + +val <error descr="[EXPOSED_PROPERTY_TYPE] public property exposes its private type 'E'">z</error>: B<D.E>? = null diff --git a/idea/testData/checker/ExtensionFunctions.fir.kt b/idea/testData/checker/ExtensionFunctions.fir.kt new file mode 100644 index 00000000000..2d2e0481e90 --- /dev/null +++ b/idea/testData/checker/ExtensionFunctions.fir.kt @@ -0,0 +1,70 @@ +fun Int?.optint() : Unit {} +val Int?.optval : Unit get() = Unit + +fun <T: Any, E> T.foo(x : E, y : A) : T { + y.plus(1) + y plus 1 + y + 1.0 + + this?.minus<T>(this) + + return this +} + +class A + +infix operator fun A.plus(a : Any) { + + 1.foo() + true.<error descr="[INAPPLICABLE_CANDIDATE] Inapplicable candidate(s): /foo">foo</error>() + + 1 +} + +infix operator fun A.plus(a : Int) { + 1 +} + +fun <T> T.minus(t : T) : Int = 1 + +fun test() { + val y = 1.abs +} +val Int.abs : Int + get() = if (this > 0) this else -this; + +<error descr="[EXTENSION_PROPERTY_MUST_HAVE_ACCESSORS_OR_BE_ABSTRACT] Extension property must have accessors or be abstract">val <T> T.foo : T</error> + +fun Int.foo() = this + +// FILE: b.kt +//package null_safety + + fun parse(cmd: String): Command? { return null } + class Command() { + // fun equals(other : Any?) : Boolean + val foo : Int = 0 + } + + operator fun Any.equals(other : Any?) : Boolean = true + fun Any?.equals1(other : Any?) : Boolean = true + fun Any.equals2(other : Any?) : Boolean = true + + fun main(args: Array<String>) { + + System.out.print(1) + + val command = parse("") + + command.foo + + command<error descr="[UNSAFE_CALL] Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type Command?">.</error>equals(null) + command?.equals(null) + command.equals1(null) + command?.equals1(null) + + val c = Command() + c?.equals2(null) + + if (command == null) 1 + } diff --git a/idea/testData/checker/ForRangeConventions.fir.kt b/idea/testData/checker/ForRangeConventions.fir.kt new file mode 100644 index 00000000000..0869b6f6708 --- /dev/null +++ b/idea/testData/checker/ForRangeConventions.fir.kt @@ -0,0 +1,82 @@ +import java.util.*; + +fun <T> checkSubtype(t: T) = t + +class NotRange1() { + +} + +abstract class NotRange2() { + abstract operator fun iterator() : Unit +} + +abstract class ImproperIterator1 { + abstract operator fun hasNext() : Boolean +} + +abstract class NotRange3() { + abstract operator fun iterator() : ImproperIterator1 +} + +abstract class ImproperIterator2 { + abstract operator fun next() : Boolean +} + +abstract class NotRange4() { + abstract operator fun iterator() : ImproperIterator2 +} + +abstract class ImproperIterator3 { + abstract operator fun hasNext() : Int + abstract operator fun next() : Int +} + +abstract class NotRange5() { + abstract operator fun iterator() : ImproperIterator3 +} + +abstract class AmbiguousHasNextIterator { + abstract operator fun hasNext() : Boolean + val hasNext : Boolean get() = false + abstract operator fun next() : Int +} + +abstract class NotRange6() { + abstract operator fun iterator() : AmbiguousHasNextIterator +} + +abstract class ImproperIterator4 { + val hasNext : Int get() = 1 + abstract operator fun next() : Int +} + +abstract class NotRange7() { + abstract operator fun iterator() : ImproperIterator3 +} + +abstract class GoodIterator { + abstract operator fun hasNext() : Boolean + abstract operator fun next() : Int +} + +abstract class Range0() { + abstract operator fun iterator() : GoodIterator +} + +abstract class Range1() { + abstract operator fun iterator() : Iterator<Int> +} + +fun test(notRange1: NotRange1, notRange2: NotRange2, notRange3: NotRange3, notRange4: NotRange4, notRange5: NotRange5, notRange6: NotRange6, notRange7: NotRange7, range0: Range0, range1: Range1) { + <error descr="[UNRESOLVED_REFERENCE] Unresolved reference: hasNext"><error descr="[UNRESOLVED_REFERENCE] Unresolved reference: iterator"><error descr="[UNRESOLVED_REFERENCE] Unresolved reference: next">for (i in notRange1)</error></error></error>; + <error descr="[UNRESOLVED_REFERENCE] Unresolved reference: hasNext"><error descr="[UNRESOLVED_REFERENCE] Unresolved reference: next">for (i in notRange2)</error></error>; + <error descr="[UNRESOLVED_REFERENCE] Unresolved reference: next">for (i in notRange3)</error>; + <error descr="[UNRESOLVED_REFERENCE] Unresolved reference: hasNext">for (i in notRange4)</error>; + for (i in notRange5); + for (i in notRange6); + for (i in notRange7); + for (i in range0); + for (i in range1); + + for (i in (checkSubtype<List<Int>>(ArrayList<Int>()))); +} diff --git a/idea/testData/checker/FunctionOnlyOneTypeParametersList.kt b/idea/testData/checker/FunctionOnlyOneTypeParametersList.kt index 87391bc18b0..c22a5d71466 100644 --- a/idea/testData/checker/FunctionOnlyOneTypeParametersList.kt +++ b/idea/testData/checker/FunctionOnlyOneTypeParametersList.kt @@ -1,3 +1,3 @@ -// FIR_COMPARISON +// FIR_IDENTICAL -fun <T> foo<error><SOME_TYPE></error> () {} \ No newline at end of file +fun <T> foo<error><SOME_TYPE></error> () {} diff --git a/idea/testData/checker/FunctionReturnTypes.fir.kt b/idea/testData/checker/FunctionReturnTypes.fir.kt new file mode 100644 index 00000000000..7e6ecc8c2f2 --- /dev/null +++ b/idea/testData/checker/FunctionReturnTypes.fir.kt @@ -0,0 +1,162 @@ +// COMPILER_ARGUMENTS: -XXLanguage:-NewInference +// RUNTIME + +fun none() {} + +fun unitEmptyInfer() {} +fun unitEmpty() : Unit {} +fun unitEmptyReturn() : Unit {return} +fun unitIntReturn() : Unit {return 1} +fun unitUnitReturn() : Unit {return Unit} +fun test1() : Any = { return } +fun test2() : Any = a@ {return@a 1} +fun test3() : Any { return } + +fun bbb() { + return 1 +} + +fun foo(expr: StringBuilder): Int { + val c = 'a' + when(c) { + 0.toChar() -> throw Exception("zero") + else -> throw Exception("nonzero" + c) + } +} + + +fun unitShort() : Unit = Unit +fun unitShortConv() : Unit = 1 +fun unitShortNull() : Unit = null + +fun intEmpty() : Int {} +fun intShortInfer() = 1 +fun intShort() : Int = 1 +//fun intBlockInfer() {1} +fun intBlock() : Int {return 1} +fun intBlock1() : Int {1} + +fun intString(): Int = "s" +fun intFunctionLiteral(): Int = { 10 } + +fun blockReturnUnitMismatch() : Int {return} +fun blockReturnValueTypeMismatch() : Int {return 3.4} +fun blockReturnValueTypeMatch() : Int {return 1} +fun blockReturnValueTypeMismatchUnit() : Int {return Unit} + +fun blockAndAndMismatch() : Int { + true && false +} +fun blockAndAndMismatch1() : Int { + return true && false +} +fun blockAndAndMismatch2() : Int { + (return true) && (return false) +} + +fun blockAndAndMismatch3() : Int { + true || false +} +fun blockAndAndMismatch4() : Int { + return true || false +} +fun blockAndAndMismatch5() : Int { + (return true) || (return false) +} +fun blockReturnValueTypeMatch1() : Int { + return if (1 > 2) 1.0 else 2.0 +} +fun blockReturnValueTypeMatch2() : Int { + return <error descr="[INVALID_IF_AS_EXPRESSION] 'if' must have both main and 'else' branches if used as an expression">if</error> (1 > 2) 1 +} +fun blockReturnValueTypeMatch3() : Int { + return if (1 > 2) else 1 +} +fun blockReturnValueTypeMatch4() : Int { + if (1 > 2) + return 1.0 + else return 2.0 +} +fun blockReturnValueTypeMatch5() : Int { + if (1 > 2) + return 1.0 + return 2.0 +} +fun blockReturnValueTypeMatch6() : Int { + if (1 > 2) + else return 1.0 + return 2.0 +} +fun blockReturnValueTypeMatch7() : Int { + if (1 > 2) + 1.0 + else 2.0 +} +fun blockReturnValueTypeMatch8() : Int { + if (1 > 2) + 1.0 + else 2.0 + return 1 +} +fun blockReturnValueTypeMatch9() : Int { + if (1 > 2) + 1.0 +} +fun blockReturnValueTypeMatch10() : Int { + return <error descr="[INVALID_IF_AS_EXPRESSION] 'if' must have both main and 'else' branches if used as an expression">if</error> (1 > 2) 1 +} +fun blockReturnValueTypeMatch11() : Int { + if (1 > 2) + else 1.0 +} +fun blockReturnValueTypeMatch12() : Int { + if (1 > 2) + return 1 + else return 1.0 +} +fun blockNoReturnIfValDeclaration(): Int { + val x = 1 +} +fun blockNoReturnIfEmptyIf(): Int { + if (1 < 2) {} else {} +} +fun blockNoReturnIfUnitInOneBranch(): Int { + if (1 < 2) { + return 1 + } else { + if (3 < 4) { + } else { + return 2 + } + } +} +fun nonBlockReturnIfEmptyIf(): Int = if (1 < 2) {} else {} +fun nonBlockNoReturnIfUnitInOneBranch(): Int = if (1 < 2) {} else 2 + +val a = return 1 + +class A() { +} +fun illegalConstantBody(): Int = "s" +fun illegalConstantBlock(): String { + return 1 +} +fun illegalIfBody(): Int = + if (1 < 2) 'a' else { 1.0 } +fun illegalIfBlock(): Boolean { + if (1 < 2) + return false + else { return 1 } +} +fun illegalReturnIf(): Char { + return if (1 < 2) 'a' else { 1 } +} + +fun returnNothing(): Nothing { + throw 1 +} +fun f(): Int { + if (1 < 2) { return 1 } else returnNothing() +} + +fun f1(): Int = if (1 < 2) 1 else returnNothing() diff --git a/idea/testData/checker/GenericArgumentConsistency.fir.kt b/idea/testData/checker/GenericArgumentConsistency.fir.kt new file mode 100644 index 00000000000..2658e33e8c8 --- /dev/null +++ b/idea/testData/checker/GenericArgumentConsistency.fir.kt @@ -0,0 +1,42 @@ +interface A<in T> {} +interface B<T> : A<Int> {} +interface C<T> : B<T>, A<T> {} +interface C1<T> : B<T>, A<Any> {} +interface D : C<Boolean>, B<Double>{} + +interface A1<out T> {} +interface B1 : A1<Int> {} +interface B2 : A1<Any>, B1 {} + +interface BA1<T> {} +interface BB1 : BA1<Int> {} +interface BB2 : BA1<Any>, BB1 {} + + +//package x { + interface xAA1<out T> {} + interface xAB1 : xAA1<Int> {} + interface xAB3 : xAA1<Comparable<Int>> {} + interface xAB2 : xAA1<Number>, xAB1, xAB3 {} +//} + +//package x2 { + interface x2AA1<out T> {} + interface x2AB1 : x2AA1<Any> {} + interface x2AB3 : x2AA1<Comparable<Int>> {} + interface x2AB2 : x2AA1<Number>, x2AB1, x2AB3 {} +//} + +//package x3 { + interface x3AA1<in T> {} + interface x3AB1 : x3AA1<Any> {} + interface x3AB3 : x3AA1<Comparable<Int>> {} + interface x3AB2 : x3AA1<Number>, x3AB1, x3AB3 {} +//} + +//package sx2 { + interface sx2AA1<in T> {} + interface sx2AB1 : sx2AA1<Int> {} + interface sx2AB3 : sx2AA1<Comparable<Int>> {} + interface sx2AB2 : sx2AA1<Number>, sx2AB1, sx2AB3 {} +//} diff --git a/idea/testData/checker/IncDec.fir.kt b/idea/testData/checker/IncDec.fir.kt new file mode 100644 index 00000000000..aae0f0cc705 --- /dev/null +++ b/idea/testData/checker/IncDec.fir.kt @@ -0,0 +1,46 @@ +class IncDec() { + operator fun inc() : IncDec = this + operator fun dec() : IncDec = this +} + +fun testIncDec() { + var x = IncDec() + x++ + ++x + x-- + --x + x = x++ + x = x-- + x = ++x + x = --x +} + +class WrongIncDec() { + operator fun inc() : Int = 1 + operator fun dec() : Int = 1 +} + +fun testWrongIncDec() { + var x = WrongIncDec() + x++ + ++x + x-- + --x +} + +class UnitIncDec() { + operator fun inc() : Unit {} + operator fun dec() : Unit {} +} + +fun testUnitIncDec() { + var x = UnitIncDec() + x++ + ++x + x-- + --x + x = x++ + x = x-- + x = ++x + x = --x +} diff --git a/idea/testData/checker/IsExpressions.fir.kt b/idea/testData/checker/IsExpressions.fir.kt new file mode 100644 index 00000000000..673343c8496 --- /dev/null +++ b/idea/testData/checker/IsExpressions.fir.kt @@ -0,0 +1,7 @@ +fun test() { + if (1 is Int) { + if (1 is Boolean) { + + } + } +} diff --git a/idea/testData/checker/JvmStaticUsagesRuntime.fir.kt b/idea/testData/checker/JvmStaticUsagesRuntime.fir.kt new file mode 100644 index 00000000000..374ca45864b --- /dev/null +++ b/idea/testData/checker/JvmStaticUsagesRuntime.fir.kt @@ -0,0 +1,56 @@ +// RUNTIME +@JvmStatic +class A { + @JvmStatic + companion object { + @JvmStatic fun a1() { + + } + } + + @JvmStatic + object A { + @JvmStatic fun a2() { + + } + } + + fun test() { + val s = object { + @JvmStatic fun a3() { + + } + } + } + + @JvmStatic fun a4() { + + } +} + +@JvmStatic +interface B { + companion object { + @JvmStatic fun a1() { + + } + } + + object A { + @JvmStatic fun a2() { + + } + } + + fun test() { + val s = object { + @JvmStatic fun a3() { + + } + } + } + + @JvmStatic fun a4() { + + } +} diff --git a/idea/testData/checker/LocalObjects.kt b/idea/testData/checker/LocalObjects.kt index 2170599362c..5ef4a7a617f 100644 --- a/idea/testData/checker/LocalObjects.kt +++ b/idea/testData/checker/LocalObjects.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // FIR_COMPARISON object A { val x : Int = 0 @@ -13,10 +14,10 @@ } b.foo() - <error>object B</error> { + <error descr="[LOCAL_OBJECT_NOT_ALLOWED] Named object 'B' is a singleton and cannot be local. Try to use anonymous object instead">object B</error> { fun foo() {} } B.foo() } - val bb = <error>B</error>.<error>foo</error>() + val bb = <error descr="[UNRESOLVED_REFERENCE] Unresolved reference: B">B</error>.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: foo">foo</error>() diff --git a/idea/testData/checker/MainWithWarningOnUnusedParam.kt b/idea/testData/checker/MainWithWarningOnUnusedParam.kt index 07f402a7eba..207d9d1208c 100644 --- a/idea/testData/checker/MainWithWarningOnUnusedParam.kt +++ b/idea/testData/checker/MainWithWarningOnUnusedParam.kt @@ -1,7 +1,7 @@ -// FIR_COMPARISON +// FIR_IDENTICAL // LANGUAGE_VERSION: 1.4 fun main(<warning descr="[UNUSED_PARAMETER] Parameter 'args' is never used">args</warning>: Array<String>) { -} \ No newline at end of file +} diff --git a/idea/testData/checker/MainWithoutWarningOnUnusedParam.kt b/idea/testData/checker/MainWithoutWarningOnUnusedParam.kt index 7fb0c29fbfe..236fc16cfc9 100644 --- a/idea/testData/checker/MainWithoutWarningOnUnusedParam.kt +++ b/idea/testData/checker/MainWithoutWarningOnUnusedParam.kt @@ -1,7 +1,7 @@ -// FIR_COMPARISON +// FIR_IDENTICAL // LANGUAGE_VERSION: 1.3 fun main(args: Array<String>) { -} \ No newline at end of file +} diff --git a/idea/testData/checker/MultipleBounds.fir.kt b/idea/testData/checker/MultipleBounds.fir.kt new file mode 100644 index 00000000000..3e7642616bb --- /dev/null +++ b/idea/testData/checker/MultipleBounds.fir.kt @@ -0,0 +1,65 @@ +package Jet87 + +open class A() { + fun foo() : Int = 1 +} + +interface B { + fun bar() : Double = 1.0; +} + +class C() : A(), B + +class D() { + companion object : A(), B {} +} + +class Test1<T>() + where + T : A, + T : B, + B : T // error + { + + fun test(t : T) { + T.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: foo">foo</error>() + T.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: bar">bar</error>() + t.foo() + t.bar() + } +} + +fun test() { + Test1<B>() + Test1<A>() + Test1<C>() +} + +class Foo() {} + +class Bar<T : Foo> + +class Buzz<T> where T : Bar<Int>, T : <error descr="[UNRESOLVED_REFERENCE] Unresolved reference: nioho">nioho</error> + +class X<T : Foo> +class Y<T> where T : Foo, T : Bar<Foo> + +fun <T> test2(t : T) + where + T : A, + T : B, + B : T +{ + T.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: foo">foo</error>() + T.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: bar">bar</error>() + t.foo() + t.bar() +} + +val t1 = <error descr="[INAPPLICABLE_CANDIDATE] Inapplicable candidate(s): Jet87/test2">test2</error><A>(A()) +val t2 = <error descr="[INAPPLICABLE_CANDIDATE] Inapplicable candidate(s): Jet87/test2">test2</error><B>(C()) +val t3 = test2<C>(C()) + +val <T, B: T> Pair<T, B>.x : Int get() = 0 + +class Pair<A, B>() diff --git a/idea/testData/checker/MultipleModality.fir.kt b/idea/testData/checker/MultipleModality.fir.kt new file mode 100644 index 00000000000..98e0426919d --- /dev/null +++ b/idea/testData/checker/MultipleModality.fir.kt @@ -0,0 +1,9 @@ +sealed <error descr="[REDUNDANT_MODIFIER] Modifier 'abstract' is redundant because 'sealed' is present">abstract</error> class First + +<error descr="[REDUNDANT_MODIFIER] Modifier 'abstract' is redundant because 'sealed' is present">abstract</error> sealed class Second + +abstract class Base { + abstract <error descr="[REDUNDANT_MODIFIER] Modifier 'open' is redundant because 'abstract' is present">open</error> fun foo() + + <error descr="[REDUNDANT_MODIFIER] Modifier 'open' is redundant because 'abstract' is present">open</error> abstract val name: String +} diff --git a/idea/testData/checker/NestedObjects.fir.kt b/idea/testData/checker/NestedObjects.fir.kt new file mode 100644 index 00000000000..bcc77fbb238 --- /dev/null +++ b/idea/testData/checker/NestedObjects.fir.kt @@ -0,0 +1,28 @@ +package nestedObjects + object A { + val b = B + val d = A.B.A + + object B { + val a = A + val e = B.A + + object A { + val a = A + val b = B + val x = nestedObjects.A.B.A + val y = this@A + } + } + + } + object B { + val b = B + val c = A.B + } + + val a = A + val b = B + val c = A.B + val d = A.B.A + val e = B.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: A">A</error>.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: B">B</error> diff --git a/idea/testData/checker/NotFinishedGenericDeclaration.kt b/idea/testData/checker/NotFinishedGenericDeclaration.kt index 1365377a533..ca26ea376f1 100644 --- a/idea/testData/checker/NotFinishedGenericDeclaration.kt +++ b/idea/testData/checker/NotFinishedGenericDeclaration.kt @@ -1,7 +1,7 @@ -// FIR_COMPARISON +// FIR_IDENTICAL class Test val localTest1 = Test() <error>-</error> 12 val localTest2 = Test() <error>></error> 12 -val localTest3 = Test() <error><</error> 12 \ No newline at end of file +val localTest3 = Test() <error><</error> 12 diff --git a/idea/testData/checker/NullAsAnnotationArgument.fir.kt b/idea/testData/checker/NullAsAnnotationArgument.fir.kt new file mode 100644 index 00000000000..167b03e5522 --- /dev/null +++ b/idea/testData/checker/NullAsAnnotationArgument.fir.kt @@ -0,0 +1,10 @@ +// test for KT-5337 +package test + +annotation class A(val value: String) + +<error descr="[INAPPLICABLE_CANDIDATE] Inapplicable candidate(s): test/A.A">@A(null)</error> +fun foo() {} + +<error descr="[INAPPLICABLE_CANDIDATE] Inapplicable candidate(s): test/A.A">@A(null)</error> +class B diff --git a/idea/testData/checker/Nullability.kt b/idea/testData/checker/Nullability.kt index fca42959394..eb11eafa108 100644 --- a/idea/testData/checker/Nullability.kt +++ b/idea/testData/checker/Nullability.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IDENTICAL fun test() { val a : Int? = 0 if (a != null) { diff --git a/idea/testData/checker/ObjectLiteralInDelegate.fir.kt b/idea/testData/checker/ObjectLiteralInDelegate.fir.kt new file mode 100644 index 00000000000..33c19fee094 --- /dev/null +++ b/idea/testData/checker/ObjectLiteralInDelegate.fir.kt @@ -0,0 +1,18 @@ +// Test for KT-8187 +interface A { + fun get(x: Int) +} + +class B : A by <error descr="[ABSTRACT_MEMBER_NOT_IMPLEMENTED] Object <anonymous> is not abstract and does not implement abstract member org.jetbrains.kotlin.fir.declarations.impl.FirSimpleFunctionImpl@181a2e4a: public abstract fun /A.get(x: R|kotlin/Int|): R|kotlin/Unit| +">object</error> : A {} + +class C : A by (<error descr="[ABSTRACT_MEMBER_NOT_IMPLEMENTED] Object <anonymous> is not abstract and does not implement abstract member org.jetbrains.kotlin.fir.declarations.impl.FirSimpleFunctionImpl@181a2e4a: public abstract fun /A.get(x: R|kotlin/Int|): R|kotlin/Unit| +">object</error> : A {}) + +class D : A by 1 <error descr="[NONE_APPLICABLE] None of the following functions are applicable: [kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, ...]">+</error> (<error descr="[ABSTRACT_MEMBER_NOT_IMPLEMENTED] Object <anonymous> is not abstract and does not implement abstract member org.jetbrains.kotlin.fir.declarations.impl.FirSimpleFunctionImpl@181a2e4a: public abstract fun /A.get(x: R|kotlin/Int|): R|kotlin/Unit| +">object</error> : A {}) + +fun bar() { + val e = object : A by <error descr="[ABSTRACT_MEMBER_NOT_IMPLEMENTED] Object <anonymous> is not abstract and does not implement abstract member org.jetbrains.kotlin.fir.declarations.impl.FirSimpleFunctionImpl@181a2e4a: public abstract fun /A.get(x: R|kotlin/Int|): R|kotlin/Unit| +">object</error> : A {} {} +} diff --git a/idea/testData/checker/Objects.fir.kt b/idea/testData/checker/Objects.fir.kt new file mode 100644 index 00000000000..5c096dd5d4b --- /dev/null +++ b/idea/testData/checker/Objects.fir.kt @@ -0,0 +1,28 @@ +package toplevelObjectDeclarations + open class Foo(y : Int) { + open fun foo() : Int = 1 + } + + <error descr="[INAPPLICABLE_CANDIDATE] Inapplicable candidate(s): toplevelObjectDeclarations/Foo.Foo">class T : <error descr="[SUPERTYPE_NOT_INITIALIZED] This type has a constructor, and thus must be initialized here">Foo</error> {}</error> + + <error descr="[INAPPLICABLE_CANDIDATE] Inapplicable candidate(s): toplevelObjectDeclarations/Foo.Foo">object A : <error descr="[SUPERTYPE_NOT_INITIALIZED] This type has a constructor, and thus must be initialized here">Foo</error> { + val x : Int = 2 + + fun test() : Int { + return x + foo() + } + }</error> + + object B : A {} + + val x = A.foo() + + val y = object : Foo(x) { + init { + x + 12 + } + + override fun foo() : Int = 1 + } + + val z = y.foo() diff --git a/idea/testData/checker/Override.fir.kt b/idea/testData/checker/Override.fir.kt new file mode 100644 index 00000000000..c90c0f43c11 --- /dev/null +++ b/idea/testData/checker/Override.fir.kt @@ -0,0 +1,40 @@ +package override + + interface MyTrait { + fun foo() + } + + abstract class MyAbstractClass { + abstract fun bar() + } + + open class MyClass : MyTrait, MyAbstractClass() { + override fun foo() {} + override fun bar() {} + } + + class MyChildClass : MyClass() {} + + <error descr="[ABSTRACT_MEMBER_NOT_IMPLEMENTED] Class MyIllegalClass is not abstract and does not implement abstract member org.jetbrains.kotlin.fir.declarations.impl.FirSimpleFunctionImpl@dae9e3: public abstract fun override/MyTrait.foo(): R|kotlin/Unit| +">class MyIllegalClass</error> : MyTrait, MyAbstractClass() {} + + <error descr="[ABSTRACT_CLASS_MEMBER_NOT_IMPLEMENTED] Class MyIllegalClass2 is not abstract and does not implement abstract base class member org.jetbrains.kotlin.fir.declarations.impl.FirSimpleFunctionImpl@62434f8c: public abstract fun override/MyAbstractClass.bar(): R|kotlin/Unit| +">class MyIllegalClass2</error> : MyTrait, MyAbstractClass() { + override fun foo() {} + } + + <error descr="[ABSTRACT_MEMBER_NOT_IMPLEMENTED] Class MyIllegalClass3 is not abstract and does not implement abstract member org.jetbrains.kotlin.fir.declarations.impl.FirSimpleFunctionImpl@dae9e3: public abstract fun override/MyTrait.foo(): R|kotlin/Unit| +">class MyIllegalClass3</error> : MyTrait, MyAbstractClass() { + override fun bar() {} + } + + <error descr="[ABSTRACT_CLASS_MEMBER_NOT_IMPLEMENTED] Class MyIllegalClass4 is not abstract and does not implement abstract base class member org.jetbrains.kotlin.fir.declarations.impl.FirSimpleFunctionImpl@62434f8c: public abstract fun override/MyAbstractClass.bar(): R|kotlin/Unit| +">class MyIllegalClass4</error> : MyTrait, MyAbstractClass() { + fun foo() {} + override fun other() {} + } + + class MyChildClass1 : MyClass() { + fun foo() {} + override fun bar() {} + } diff --git a/idea/testData/checker/OverridesAndGenerics.fir.kt b/idea/testData/checker/OverridesAndGenerics.fir.kt new file mode 100644 index 00000000000..e47bfa1d1a4 --- /dev/null +++ b/idea/testData/checker/OverridesAndGenerics.fir.kt @@ -0,0 +1,35 @@ + interface MyTrait<T> { + fun foo(t: T) : T + } + + abstract class MyAbstractClass<T> { + abstract fun bar(t: T) : T + } + + open class MyGenericClass<T> : MyTrait<T>, MyAbstractClass<T>() { + override fun foo(t: T) = t + override fun bar(t: T) = t + } + + class MyChildClass : MyGenericClass<Int>() {} + class MyChildClass1<T> : MyGenericClass<T>() {} + class MyChildClass2<T> : MyGenericClass<T>() { + fun foo(t: T) = t + override fun bar(t: T) = t + } + + open class MyClass : MyTrait<Int>, MyAbstractClass<String>() { + override fun foo(t: Int) = t + override fun bar(t: String) = t + } + + class MyIllegalGenericClass1<T> : MyTrait<T>, MyAbstractClass<T>() {} + class MyIllegalGenericClass2<T, R> : MyTrait<T>, MyAbstractClass<R>() { + override fun foo(r: R) = r + } + class MyIllegalClass1 : MyTrait<Int>, MyAbstractClass<String>() {} + + class MyIllegalClass2<T> : MyTrait<Int>, MyAbstractClass<Int>() { + fun foo(t: T) = t + fun bar(t: T) = t + } diff --git a/idea/testData/checker/PackageQualified.kt b/idea/testData/checker/PackageQualified.kt index 0fcc05274f1..79a7e6898ca 100644 --- a/idea/testData/checker/PackageQualified.kt +++ b/idea/testData/checker/PackageQualified.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IDENTICAL package a @@ -42,4 +42,4 @@ abstract class Collection<E> : Iterable<E> { } return current.done() } -} \ No newline at end of file +} diff --git a/idea/testData/checker/PrimaryConstructors.kt b/idea/testData/checker/PrimaryConstructors.kt index fe43f6fb40e..d7398641832 100644 --- a/idea/testData/checker/PrimaryConstructors.kt +++ b/idea/testData/checker/PrimaryConstructors.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL class X { <error>val x : Int</error> } @@ -12,4 +13,3 @@ class Y1 { class Z : Y() { } -// FIR_COMPARISON \ No newline at end of file diff --git a/idea/testData/checker/ProjectionsInSupertypes.fir.kt b/idea/testData/checker/ProjectionsInSupertypes.fir.kt new file mode 100644 index 00000000000..c1451f00f67 --- /dev/null +++ b/idea/testData/checker/ProjectionsInSupertypes.fir.kt @@ -0,0 +1,6 @@ +interface A<T> {} +interface B<T> {} +interface C<T> {} +interface D<T> {} + +interface Test : A<in Int>, B<out Int>, C<*>???, D<Int> {} diff --git a/idea/testData/checker/Properties.fir.kt b/idea/testData/checker/Properties.fir.kt new file mode 100644 index 00000000000..8f95099ec38 --- /dev/null +++ b/idea/testData/checker/Properties.fir.kt @@ -0,0 +1,25 @@ + var x : Int = 1 + x + get() : Int = 1 + set(value : Long) { + field = value.toInt() + field = 1.toLong() + } + + val xx : Int = <error descr="[PROPERTY_INITIALIZER_NO_BACKING_FIELD] Initializer is not allowed here because this property has no backing field">1 + x</error> + get() : Int = 1 + <error descr="[VAL_WITH_SETTER] A 'val'-property cannot have a setter">set(value : Long) {}</error> + + val p : Int = <error descr="[PROPERTY_INITIALIZER_NO_BACKING_FIELD] Initializer is not allowed here because this property has no backing field">1</error> + get() = 1 + +class Test() { + var a : Int = 111 + var b : Int get() = a; set(x) { a = x } + + init { + + } + fun f() { + + } +} diff --git a/idea/testData/checker/QualifiedExpressions.fir.kt b/idea/testData/checker/QualifiedExpressions.fir.kt new file mode 100644 index 00000000000..5c0943fb1a7 --- /dev/null +++ b/idea/testData/checker/QualifiedExpressions.fir.kt @@ -0,0 +1,15 @@ +// COMPILER_ARGUMENTS: -XXLanguage:-NewInference + +package qualified_expressions + +fun test(s: IntRange?) { + val a: Int = s?.start + val b: Int? = s?.start + val c: Int = s?.start ?: -11 + val d: Int = s?.start ?: "empty" + val e: String = s?.start ?: "empty" + val f: Int = s?.endInclusive ?: b ?: 1 + val g: Boolean? = e.startsWith("s")//?.length +} + +fun String.startsWith(s: String): Boolean = true diff --git a/idea/testData/checker/QualifiedThis.fir.kt b/idea/testData/checker/QualifiedThis.fir.kt new file mode 100644 index 00000000000..8f602472ff7 --- /dev/null +++ b/idea/testData/checker/QualifiedThis.fir.kt @@ -0,0 +1,22 @@ +class Dup { + fun Dup() : Unit { + this@Dup + } +} + +class A() { + fun foo() : Unit { + this@A + <error descr="[UNRESOLVED_LABEL] Unresolved label">this@a</error> + this + } + + val x = this@A.foo() + val y = this.foo() + val z = foo() +} + +fun foo1() : Unit { + <error descr="[NO_THIS] 'this' is not defined in this context">this</error> + <error descr="[UNRESOLVED_LABEL] Unresolved label">this@a</error> +} diff --git a/idea/testData/checker/QualifiedThisInClosures.fir.kt b/idea/testData/checker/QualifiedThisInClosures.fir.kt new file mode 100644 index 00000000000..7e8f45e3ea2 --- /dev/null +++ b/idea/testData/checker/QualifiedThisInClosures.fir.kt @@ -0,0 +1,18 @@ +fun <T> checkSubtype(t: T) = t + +class A(val a:Int) { + + inner class B() { + val x = checkSubtype<B>(this@B) + val y = checkSubtype<A>(this@A) + val z = checkSubtype<B>(this) + val Int.xx : Int get() = checkSubtype<Int>(this) + fun Byte.xx() : Double.() -> Unit { + checkSubtype<Byte>(this) + val a: Double.() -> Unit = { checkSubtype<Double>(this) + checkSubtype<Byte>(this@xx) } + val b: Double.() -> Unit = a@{checkSubtype<Double>(this@a) + checkSubtype<Byte>(this@xx) } + val c = a@{<error descr="[UNRESOLVED_LABEL] Unresolved label">this@a</error> + checkSubtype<Byte>(this@xx) } + return (a@{checkSubtype<Double>(this@a) + checkSubtype<Byte>(this@xx) }) + } + } + } diff --git a/idea/testData/checker/Redeclaration.fir.kt b/idea/testData/checker/Redeclaration.fir.kt new file mode 100644 index 00000000000..3044b6e1ec4 --- /dev/null +++ b/idea/testData/checker/Redeclaration.fir.kt @@ -0,0 +1,29 @@ +// !DIAGNOSTICS: -DUPLICATE_CLASS_NAMES +<error descr="[REDECLARATION] Conflicting declarations: [/a]">val a : Int = 1</error> +<error descr="[REDECLARATION] Conflicting declarations: [/a]">val a : Int = 1</error> + +<error descr="[CONFLICTING_OVERLOADS] Conflicting overloads: [/foo]">fun foo()</error> {} +<error descr="[CONFLICTING_OVERLOADS] Conflicting overloads: [/foo]">fun foo()</error> {} + +enum class EnumClass { + FOO, + FOO +} + +class A { + <error descr="[REDECLARATION] Conflicting declarations: [/A.a]">val a : Int = 1</error> + <error descr="[REDECLARATION] Conflicting declarations: [/A.a]">val a : Int = 1</error> + + <error descr="[CONFLICTING_OVERLOADS] Conflicting overloads: [/A.foo]">fun foo()</error> {} + <error descr="[CONFLICTING_OVERLOADS] Conflicting overloads: [/A.foo]">fun foo()</error> {} +} + +object B { + <error descr="[REDECLARATION] Conflicting declarations: [B.C]">class C</error> + <error descr="[REDECLARATION] Conflicting declarations: [B.C]">class C</error> +} + +fun <T, T> PairParam() {} +class PParam<T, T> {} + +val <T, T> T.fooParam : Int get() = 1 diff --git a/idea/testData/checker/Redeclaration.kt b/idea/testData/checker/Redeclaration.kt index cfdb80e5483..26b2c75e6ab 100644 --- a/idea/testData/checker/Redeclaration.kt +++ b/idea/testData/checker/Redeclaration.kt @@ -1,4 +1,3 @@ -// IGNORE_FIR // !DIAGNOSTICS: -DUPLICATE_CLASS_NAMES val <error>a</error> : Int = 1 val <error>a</error> : Int = 1 diff --git a/idea/testData/checker/Redeclarations.fir.kt b/idea/testData/checker/Redeclarations.fir.kt new file mode 100644 index 00000000000..3ae6b2ebc24 --- /dev/null +++ b/idea/testData/checker/Redeclarations.fir.kt @@ -0,0 +1,12 @@ +//package redeclarations { + <error descr="[REDECLARATION] Conflicting declarations: [A, /A]">object A</error> { + val x : Int = 0 + + val A = 1 + } + + <error descr="[REDECLARATION] Conflicting declarations: [A, /A]">class A {}</error> + + <error descr="[REDECLARATION] Conflicting declarations: [A, A]">val A = 1</error> + +//} diff --git a/idea/testData/checker/Redeclarations.kt b/idea/testData/checker/Redeclarations.kt index 61f45ab23df..954c3de7f47 100644 --- a/idea/testData/checker/Redeclarations.kt +++ b/idea/testData/checker/Redeclarations.kt @@ -1,5 +1,3 @@ -// IGNORE_FIR - //package redeclarations { object <error>A</error> { val x : Int = 0 diff --git a/idea/testData/checker/ResolveToJava.fir.kt b/idea/testData/checker/ResolveToJava.fir.kt new file mode 100644 index 00000000000..5252d6efc96 --- /dev/null +++ b/idea/testData/checker/ResolveToJava.fir.kt @@ -0,0 +1,48 @@ +import java.* +import java.util.* +import utils.* + +import java.io.PrintStream +import java.lang.Comparable as Com + +fun <T> checkSubtype(t: T) = t + +val l : MutableList<in Int> = ArrayList<Int>() + +fun test(l : List<Int>) { + val x : <error descr="[UNRESOLVED_REFERENCE] Unresolved reference: java.List">java.List</error> + val y : List<Int> + val b : java.lang.Object + val a : java.util.List<Int> + val z : <error descr="[UNRESOLVED_REFERENCE] Unresolved reference: java.utils.List<R|kotlin/Int|>">java.utils.List<Int></error> + + val f : java.io.File? = null + + Collections.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: emptyList">emptyList</error> + Collections.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: emptyList">emptyList</error><Int> + Collections.emptyList<Int>() + Collections.emptyList() + + checkSubtype<Set<Int>?>(Collections.singleton<Int>(1)) + Collections.<error descr="[INAPPLICABLE_CANDIDATE] Inapplicable candidate(s): java/util/Collections.singleton">singleton</error><Int>(1.0) + + List<Int> + + + val o = "sdf" as Object + + try { + // ... + } + catch(e: Throwable) { + System.out.println(e.message) + } + + PrintStream("sdf") + + val c : Com<Int>? = null + + checkSubtype<java.lang.Comparable<Int>?>(c) + +// Collections.sort<Integer>(ArrayList<Integer>()) +} diff --git a/idea/testData/checker/ResolveTypeInAnnotationArgumentRuntime.fir.kt b/idea/testData/checker/ResolveTypeInAnnotationArgumentRuntime.fir.kt new file mode 100644 index 00000000000..b1efa6c0c1b --- /dev/null +++ b/idea/testData/checker/ResolveTypeInAnnotationArgumentRuntime.fir.kt @@ -0,0 +1,6 @@ +// IGNORE_DUPLICATED_FIR_SOURCE_EXCEPTION +import kotlin.reflect.KClass + +annotation class Ann(val value: KClass<*>) + +@Ann(Array<<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: String123">String123</error>>::class) class A diff --git a/idea/testData/checker/ReturnTypeMismatchOnOverride.fir.kt b/idea/testData/checker/ReturnTypeMismatchOnOverride.fir.kt new file mode 100644 index 00000000000..03aec79470b --- /dev/null +++ b/idea/testData/checker/ReturnTypeMismatchOnOverride.fir.kt @@ -0,0 +1,13 @@ +// IGNORE_FIR + +interface Base { + fun foo(): Int + var bar: Int + val qux: Int +} + +class Derived : Base { + override fun foo(): <error descr="[RETURN_TYPE_MISMATCH_ON_OVERRIDE] Return type of 'foo' is not a subtype of the return type of the overridden member 'public abstract fun foo(): Int defined in Base'">String</error> = "" + override var bar: <error descr="[VAR_TYPE_MISMATCH_ON_OVERRIDE] Type of 'bar' doesn't match the type of the overridden var-property 'public abstract var bar: Int defined in Base'">String</error> = "" + override val qux: <error descr="[PROPERTY_TYPE_MISMATCH_ON_OVERRIDE] Type of 'qux' is not a subtype of the overridden property 'public abstract val qux: Int defined in Base'">String</error> = "" +} diff --git a/idea/testData/checker/ReturnTypeMismatchOnOverride.kt b/idea/testData/checker/ReturnTypeMismatchOnOverride.kt index c0efea8cbc1..03aec79470b 100644 --- a/idea/testData/checker/ReturnTypeMismatchOnOverride.kt +++ b/idea/testData/checker/ReturnTypeMismatchOnOverride.kt @@ -1,3 +1,5 @@ +// IGNORE_FIR + interface Base { fun foo(): Int var bar: Int @@ -8,4 +10,4 @@ class Derived : Base { override fun foo(): <error descr="[RETURN_TYPE_MISMATCH_ON_OVERRIDE] Return type of 'foo' is not a subtype of the return type of the overridden member 'public abstract fun foo(): Int defined in Base'">String</error> = "" override var bar: <error descr="[VAR_TYPE_MISMATCH_ON_OVERRIDE] Type of 'bar' doesn't match the type of the overridden var-property 'public abstract var bar: Int defined in Base'">String</error> = "" override val qux: <error descr="[PROPERTY_TYPE_MISMATCH_ON_OVERRIDE] Type of 'qux' is not a subtype of the overridden property 'public abstract val qux: Int defined in Base'">String</error> = "" -} \ No newline at end of file +} diff --git a/idea/testData/checker/SafeInvoke.fir.kt b/idea/testData/checker/SafeInvoke.fir.kt new file mode 100644 index 00000000000..7d3f3f1742b --- /dev/null +++ b/idea/testData/checker/SafeInvoke.fir.kt @@ -0,0 +1,10 @@ +// COMPILER_ARGUMENTS: -XXLanguage:-NewInference + +class Rule(val apply: () -> Unit) + +fun foo() { + val rule: Rule? = Rule { } + rule?.apply() + val apply = rule?.apply + <error descr="[UNSAFE_IMPLICIT_INVOKE_CALL] Reference has a nullable type 'kotlin/Function0<kotlin/Unit>?', use explicit \"?.invoke\" to make a function-like call instead.">apply</error>() +} diff --git a/idea/testData/checker/Shadowing.fir.kt b/idea/testData/checker/Shadowing.fir.kt new file mode 100644 index 00000000000..6178629d9ad --- /dev/null +++ b/idea/testData/checker/Shadowing.fir.kt @@ -0,0 +1,19 @@ +class A { + operator fun component1() = 42 + operator fun component2() = 42 +} + +fun arrayA(): Array<A> = null!! + +fun foo(a: A, c: Int) { + val (a, b) = a + val arr = arrayA() + for ((c, d) in arr) { + } +} + +fun f(p: Int): Int { + val p = 2 + val p = 3 + return p +} diff --git a/idea/testData/checker/StringTemplates.fir.kt b/idea/testData/checker/StringTemplates.fir.kt new file mode 100644 index 00000000000..be03d18bb9c --- /dev/null +++ b/idea/testData/checker/StringTemplates.fir.kt @@ -0,0 +1,23 @@ +fun demo() { + val abc = 1 + val a = "" + val asd = 1 + val bar = 5 + fun map(f : () -> Any?) : Int = 1 + fun buzz(f : () -> Any?) : Int = 1 + val sdf = 1 + val foo = 3; + use("$abc") + use("$") + use("$.$.asdf$\t") + use("asd\$") + use("asd$a\x") + use("asd$a$asd$ $<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: xxx">xxx</error>") + use("fosdfasdo${1 + bar + 100}}sdsdfgdsfsdf") + use("foo${bar + map {foo}}sdfsdf") + use("foo${bar + map { "foo" }}sdfsdf") + use("foo${bar + map { + "foo$sdf${ buzz{}}" }}sdfsdf") +} + +fun use(s: String) {} diff --git a/idea/testData/checker/SupertypeListChecks.fir.kt b/idea/testData/checker/SupertypeListChecks.fir.kt new file mode 100644 index 00000000000..026494bc013 --- /dev/null +++ b/idea/testData/checker/SupertypeListChecks.fir.kt @@ -0,0 +1,49 @@ +// KT-286 Check supertype lists + +/* +In a supertype list: + Same type should not be mentioned twice + Same type should not be indirectly mentioned with incoherent type arguments + Every interface's required dependencies should be satisfied + No final types should appear + Only one class is allowed +*/ + +class C1() + +open class OC1() + +open class C2 {} + +open class C3 {} + +interface T1 {} + +interface T2<T> {} + +interface <error descr="[CONSTRUCTOR_IN_INTERFACE] An interface may not have a constructor">Test()</error> { +} + +interface Test1 : <error descr="[INTERFACE_WITH_SUPERCLASS] An interface cannot inherit from a class"><error descr="[SUPERTYPE_INITIALIZED_IN_INTERFACE] Interfaces cannot initialize supertypes">C2</error></error>() {} + +interface Test2 : <error descr="[INTERFACE_WITH_SUPERCLASS] An interface cannot inherit from a class">C2</error> {} + +interface Test3 : <error descr="[INTERFACE_WITH_SUPERCLASS] An interface cannot inherit from a class">C2</error>, C3 {} + +interface Test4 : T1 {} + +interface Test5 : T1, T1 {} + +interface Test6 : <error descr="[INTERFACE_WITH_SUPERCLASS] An interface cannot inherit from a class">C1</error> {} + +class CTest1() : OC1() {} + +class CTest2 : <error descr="[SUPERTYPE_NOT_INITIALIZED] This type has a constructor, and thus must be initialized here">C2</error> {} + +class CTest3 : <error descr="[SUPERTYPE_NOT_INITIALIZED] This type has a constructor, and thus must be initialized here">C2</error>, C3 {} + +class CTest4 : T1 {} + +class CTest5 : T1, T1 {} + +class CTest6 : <error descr="[SUPERTYPE_NOT_INITIALIZED] This type has a constructor, and thus must be initialized here">C1</error> {} diff --git a/idea/testData/checker/SupertypeListChecks.kt b/idea/testData/checker/SupertypeListChecks.kt index 11f963ca348..e5964ec0502 100644 --- a/idea/testData/checker/SupertypeListChecks.kt +++ b/idea/testData/checker/SupertypeListChecks.kt @@ -1,4 +1,3 @@ -// IGNORE_FIR // KT-286 Check supertype lists /* @@ -48,4 +47,3 @@ class CTest4 : T1 {} class CTest5 : T1, <error>T1</error> {} class CTest6 : <error>C1</error> {} - diff --git a/idea/testData/checker/TraitSupertypeList.fir.kt b/idea/testData/checker/TraitSupertypeList.fir.kt new file mode 100644 index 00000000000..6e6cb0d9e9f --- /dev/null +++ b/idea/testData/checker/TraitSupertypeList.fir.kt @@ -0,0 +1,10 @@ +open class bar() + +interface <error descr="[CONSTRUCTOR_IN_INTERFACE] An interface may not have a constructor">Foo()</error> : <error descr="[INTERFACE_WITH_SUPERCLASS] An interface cannot inherit from a class"><error descr="[SUPERTYPE_INITIALIZED_IN_INTERFACE] Interfaces cannot initialize supertypes">bar</error></error>(), bar, bar { +} + +interface Foo2 : <error descr="[INTERFACE_WITH_SUPERCLASS] An interface cannot inherit from a class">bar</error>, Foo { +} + +open class Foo1() : bar(), bar, Foo, <error descr="[UNRESOLVED_REFERENCE] Unresolved reference: <init>">Foo</error>() {} +open class Foo12 : bar(), bar {} diff --git a/idea/testData/checker/TraitSupertypeList.kt b/idea/testData/checker/TraitSupertypeList.kt index 5996062ddb4..505131f1cf9 100644 --- a/idea/testData/checker/TraitSupertypeList.kt +++ b/idea/testData/checker/TraitSupertypeList.kt @@ -1,5 +1,3 @@ -// IGNORE_FIR - open class bar() interface Foo<error>()</error> : <error>bar</error><error>()</error>, <error><error>bar</error></error>, <error><error>bar</error></error> { diff --git a/idea/testData/checker/TypeArgumentsNotAllowed.fir.kt b/idea/testData/checker/TypeArgumentsNotAllowed.fir.kt new file mode 100644 index 00000000000..707f40d8d57 --- /dev/null +++ b/idea/testData/checker/TypeArgumentsNotAllowed.fir.kt @@ -0,0 +1,9 @@ +// IGNORE_FIR + +package foo + +open class A<T> + +fun <T> f(<warning descr="[UNUSED_PARAMETER] Parameter 't' is never used">t</warning>: T<error descr="[TYPE_ARGUMENTS_NOT_ALLOWED] Type arguments are not allowed for type parameters"><T></error>) {} + +fun <T> use(<warning descr="[UNUSED_PARAMETER] Parameter 'b' is never used">b</warning>: foo<error descr="[TYPE_ARGUMENTS_NOT_ALLOWED] Type arguments are not allowed here"><T></error>.A<T>) {} diff --git a/idea/testData/checker/TypeArgumentsNotAllowed.kt b/idea/testData/checker/TypeArgumentsNotAllowed.kt index b6ba2b892af..707f40d8d57 100644 --- a/idea/testData/checker/TypeArgumentsNotAllowed.kt +++ b/idea/testData/checker/TypeArgumentsNotAllowed.kt @@ -1,3 +1,5 @@ +// IGNORE_FIR + package foo open class A<T> diff --git a/idea/testData/checker/TypeParameterBounds.fir.kt b/idea/testData/checker/TypeParameterBounds.fir.kt new file mode 100644 index 00000000000..3fff15baa68 --- /dev/null +++ b/idea/testData/checker/TypeParameterBounds.fir.kt @@ -0,0 +1,11 @@ +// See KT-9438: Enforce the Single Instantiation Inheritance Rule for type parameters + +interface A + +interface B + +interface D<T> + +interface CorrectF<T> where T : D<A>, T : D<B> + +fun <T> bar() where T : D<A>, T : D<B> {} diff --git a/idea/testData/checker/UnreachableCode.fir.kt b/idea/testData/checker/UnreachableCode.fir.kt new file mode 100644 index 00000000000..fc2c1c9f4db --- /dev/null +++ b/idea/testData/checker/UnreachableCode.fir.kt @@ -0,0 +1,161 @@ +fun t1() : Int{ + return 0 + 1 +} + +fun t1a() : Int { + return + return 1 + 1 +} + +fun t1b() : Int { + return 1 + return 1 + 1 +} + +fun t1c() : Int { + return 1 + return + 1 +} + +fun t2() : Int { + if (1 > 2) + return 1 + else return 1 + 1 +} + +fun t2a() : Int { + if (1 > 2) { + return 1 + 1 + } else { return 1 + 2 + } + 1 +} + +fun t3() : Any { + if (1 > 2) + return 2 + else return "" + 1 +} + +fun t4(a : Boolean) : Int { + do { + return 1 + } + while (a) + 1 +} + +fun t4break(a : Boolean) : Int { + do { + break + } + while (a) + return 1 +} + +fun t5() : Int { + do { + return 1 + 2 + } + while (1 > 2) + return 1 +} + +fun t6() : Int { + while (1 > 2) { + return 1 + 2 + } + return 1 +} + +fun t6break() : Int { + while (1 > 2) { + break + 2 + } + return 1 +} + +fun t7(b : Int) : Int { + for (i in 1..b) { + return 1 + 2 + } + return 1 +} + +fun t7break(b : Int) : Int { + for (i in 1..b) { + return 1 + 2 + } + return 1 +} + +fun t7() : Int { + try { + return 1 + 2 + } + catch (<error descr="[TYPE_MISMATCH] Type mismatch: inferred type is kotlin/Any but kotlin/Throwable was expected">e : Any</error>) { + 2 + } + return 1 // this is OK, like in Java +} + +fun t8() : Int { + try { + return 1 + 2 + } + catch (<error descr="[TYPE_MISMATCH] Type mismatch: inferred type is kotlin/Any but kotlin/Throwable was expected">e : Any</error>) { + return 1 + 2 + } + return 1 +} + +fun blockAndAndMismatch() : Boolean { + (return true) || (return false) + return true +} + +fun tf() : Int { + try {return 1} finally{return 1} + return 1 +} + +fun failtest(a : Int) : Int { + if (fail() || true) { + + } + return 1 +} + +fun foo(a : Nothing) : Unit { + 1 + a + 2 +} + +fun fail() : Nothing { + throw java.lang.RuntimeException() +} + +fun nullIsNotNothing() : Unit { + val x : Int? = 1 + if (x != null) { + return + } + fail() +} diff --git a/idea/testData/checker/Unresolved.fir.kt b/idea/testData/checker/Unresolved.fir.kt new file mode 100644 index 00000000000..62f5b5de57a --- /dev/null +++ b/idea/testData/checker/Unresolved.fir.kt @@ -0,0 +1,43 @@ +// IGNORE_FIR + +package unresolved + +class Pair<A, B>(<warning>a</warning>: A, <warning>b</warning>: B) + +fun testGenericArgumentsCount() { + val <warning>p1</warning>: Pair<error><Int></error> = Pair(2, 2) + val <warning>p2</warning>: <error>Pair</error> = Pair(2, 2) +} + +fun testUnresolved() { + if (<error>a</error> is String) { + val <warning>s</warning> = <error>a</error> + } + <error>foo</error>(<error>a</error>) + val s = "s" + <error>foo</error>(s) + foo1(<error>i</error>) + s.<error>foo</error>() + + when(<error>a</error>) { + is Int -> <error>a</error> + is String -> <error>a</error> + else -> <error>a</error> + } + +<<<<<<< Updated upstream + for (j in <error>collection</error>) { + var i: Int = <error>j</error> + i += 1 + foo1(<error>j</error>) + } +======= + <error descr="[UNRESOLVED_REFERENCE] Unresolved reference: hasNext"><error descr="[UNRESOLVED_REFERENCE] Unresolved reference: next">for (j in <error descr="[UNRESOLVED_REFERENCE] Unresolved reference: collection">collection</error>) { + var i: Int = j + i += 1 + foo1(j) + }</error></error> +>>>>>>> Stashed changes +} + +fun foo1(<warning>i</warning>: Int) {} diff --git a/idea/testData/checker/Unresolved.kt b/idea/testData/checker/Unresolved.kt index 7d384ad75e1..866e2430bce 100644 --- a/idea/testData/checker/Unresolved.kt +++ b/idea/testData/checker/Unresolved.kt @@ -1,3 +1,5 @@ +// IGNORE_FIR + package unresolved class Pair<A, B>(<warning>a</warning>: A, <warning>b</warning>: B) diff --git a/idea/testData/checker/Unused.kt b/idea/testData/checker/Unused.kt index 6c21bfa594c..eb9dea6fc42 100644 --- a/idea/testData/checker/Unused.kt +++ b/idea/testData/checker/Unused.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IDENTICAL fun test(<warning textAttributesKey="NOT_USED_ELEMENT_ATTRIBUTES">unusedParam</warning>: Int) { // UNUSED_PARAMETER val str = ":)" @@ -17,4 +17,3 @@ fun test(<warning textAttributesKey="NOT_USED_ELEMENT_ATTRIBUTES">unusedParam</w redundantInitializer = 2 test(redundantInitializer) } - diff --git a/idea/testData/checker/Variance.fir.kt b/idea/testData/checker/Variance.fir.kt new file mode 100644 index 00000000000..f198effe496 --- /dev/null +++ b/idea/testData/checker/Variance.fir.kt @@ -0,0 +1,40 @@ +package variance + +abstract class Consumer<in T> {} + +abstract class Producer<out T> {} + +abstract class Usual<T> {} + +fun foo(c: Consumer<Int>, p: Producer<Int>, u: Usual<Int>) { + val c1: Consumer<Any> = c + val c2: Consumer<Int> = c1 + + val p1: Producer<Any> = p + val p2: Producer<Int> = p1 + + val u1: Usual<Any> = u + val u2: Usual<Int> = u1 +} + +//Arrays copy example +class Array<T>(val length : Int, val t : T) { + fun get(index : Int) : T { return t } + fun set(index : Int, value : T) { /* ... */ } +} + +fun copy1(from : Array<Any>, to : Array<Any>) {} + +fun copy2(from : Array<out Any>, to : Array<in Any>) {} + +fun <T> copy3(from : Array<out T>, to : Array<in T>) {} + +fun copy4(from : Array<out Number>, to : Array<in Int>) {} + +fun f(ints: Array<Int>, any: Array<Any>, numbers: Array<Number>) { + <error descr="[INAPPLICABLE_CANDIDATE] Inapplicable candidate(s): variance/copy1">copy1</error>(ints, any) + copy2(ints, any) //ok + <error descr="[INAPPLICABLE_CANDIDATE] Inapplicable candidate(s): variance/copy2">copy2</error>(ints, numbers) + copy3<Int>(ints, numbers) + copy4(ints, numbers) //ok +} diff --git a/idea/testData/checker/When.fir.kt b/idea/testData/checker/When.fir.kt new file mode 100644 index 00000000000..7280b6c4422 --- /dev/null +++ b/idea/testData/checker/When.fir.kt @@ -0,0 +1,45 @@ +fun Int.foo() : Boolean = true + +fun foo() : Int { + val s = "" + val x = 1 + when (x) { + is String -> 1 + !is Int -> 1 + is Any? -> 1 + s -> 1 + 1 -> 1 + 1 <error descr="[AMBIGUITY] Ambiguity between candidates: [kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, ...]">+</error> <error descr="[UNRESOLVED_REFERENCE] Unresolved reference: a">a</error> -> 1 + in 1..<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: a">a</error> -> 1 + !in 1..<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: a">a</error> -> 1 + else -> 1 + } + + return 0 +} + +val _type_test : Int = foo() // this is needed to ensure the inferred return type of foo() + +fun test() { + val x = 1; + val s = ""; + + when (x) { + s -> 1 + "" -> 1 + x -> 1 + 1 -> 1 + else -> 1 + } + + val z = 1 + + when (z) { + else -> 1 + 1 -> 2 + } + + when (z) { + else -> 1 + } +} diff --git a/idea/testData/checker/WhenInEnumInExtensionProperty.kt b/idea/testData/checker/WhenInEnumInExtensionProperty.kt index 5db12fdee0a..40aff35643a 100644 --- a/idea/testData/checker/WhenInEnumInExtensionProperty.kt +++ b/idea/testData/checker/WhenInEnumInExtensionProperty.kt @@ -1,5 +1,4 @@ -// FIR_COMPARISON - +// FIR_IDENTICAL // KT-3750 When without else enum class A { @@ -14,4 +13,4 @@ val B.foo: Int A.e1 -> 1 A.e2 -> 3 } - } \ No newline at end of file + } diff --git a/idea/testData/checker/WhenNonExhaustive.fir.kt b/idea/testData/checker/WhenNonExhaustive.fir.kt new file mode 100644 index 00000000000..ca5e1c75d95 --- /dev/null +++ b/idea/testData/checker/WhenNonExhaustive.fir.kt @@ -0,0 +1,65 @@ +fun nonExhaustiveInt(x: Int) = <error descr="[NO_ELSE_IN_WHEN] 'when' expression must be exhaustive, add necessary 'else' branch">when</error>(x) { + 0 -> false +} + +fun nonExhaustiveBoolean(b: Boolean) = <error descr="[NO_ELSE_IN_WHEN] 'when' expression must be exhaustive, add necessary 'true' branch or 'else' branch instead">when</error>(b) { + false -> 0 +} + +fun nonExhaustiveNullableBoolean(b: Boolean?) = <error descr="[NO_ELSE_IN_WHEN] 'when' expression must be exhaustive, add necessary 'null' branch or 'else' branch instead">when</error>(b) { + false -> 0 + true -> 1 +} + +enum class Color { + RED, + GREEN, + BLUE +} + +fun nonExhaustiveEnum(c: Color) = <error descr="[NO_ELSE_IN_WHEN] 'when' expression must be exhaustive, add necessary 'RED', 'BLUE' branches or 'else' branch instead">when</error>(c) { + Color.GREEN -> 0xff00 +} + +fun nonExhaustiveNullable(c: Color?) = <error descr="[NO_ELSE_IN_WHEN] 'when' expression must be exhaustive, add necessary 'GREEN', 'null' branches or 'else' branch instead">when</error>(c) { + Color.RED -> 0xff + Color.BLUE -> 0xff0000 +} + +fun whenOnEnum(c: Color) { + when(c) { + Color.BLUE -> {} + Color.GREEN -> {} + } +} + +enum class EnumInt { + A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15 +} + +fun whenOnLongEnum(i: EnumInt) = <error descr="[NO_ELSE_IN_WHEN] 'when' expression must be exhaustive, add necessary 'A0', 'A1', 'A2', 'A3', 'A4', 'A5', 'A6', ... branches or 'else' branch instead">when</error> (i) { + EnumInt.A7 -> 7 +} + +sealed class Variant { + object Singleton : Variant() + + class Something : Variant() + + object Another : Variant() +} + +fun nonExhaustiveSealed(v: Variant) = <error descr="[NO_ELSE_IN_WHEN] 'when' expression must be exhaustive, add necessary 'is Something', 'Another' branches or 'else' branch instead">when</error>(v) { + Variant.Singleton -> false +} + +fun nonExhaustiveNullableSealed(v: Variant?) = <error descr="[NO_ELSE_IN_WHEN] 'when' expression must be exhaustive, add necessary 'Another', 'null' branches or 'else' branch instead">when</error>(v) { + Variant.Singleton -> false + is Variant.Something -> true +} + +sealed class Empty + +fun nonExhaustiveEmpty(e: Empty) = <error descr="[NO_ELSE_IN_WHEN] 'when' expression must be exhaustive, add necessary 'else' branch">when</error>(e) {} + +fun nonExhaustiveNullableEmpty(e: Empty?) = <error descr="[NO_ELSE_IN_WHEN] 'when' expression must be exhaustive, add necessary 'null' branch or 'else' branch instead">when</error>(e) {} diff --git a/idea/testData/checker/diagnosticsMessage/fullPackageFQNameOnVisiblityError.fir.kt b/idea/testData/checker/diagnosticsMessage/fullPackageFQNameOnVisiblityError.fir.kt new file mode 100644 index 00000000000..d6823c82ea1 --- /dev/null +++ b/idea/testData/checker/diagnosticsMessage/fullPackageFQNameOnVisiblityError.fir.kt @@ -0,0 +1,6 @@ +// WITH_RUNTIME + +package a.b + +<error descr="[HIDDEN] Symbol kotlin/internal/InlineOnly.InlineOnly is invisible">@kotlin.internal.InlineOnly</error> +inline fun foo() {} diff --git a/idea/testData/checker/diagnosticsMessage/incompleteTypeArgumentList.fir.kt b/idea/testData/checker/diagnosticsMessage/incompleteTypeArgumentList.fir.kt new file mode 100644 index 00000000000..6fc18048f03 --- /dev/null +++ b/idea/testData/checker/diagnosticsMessage/incompleteTypeArgumentList.fir.kt @@ -0,0 +1,5 @@ +// IGNORE_FIR + +interface ApplicationFeature<in P : Pipeline<*>, B : Any, V> +open class Pipeline<TSubject : Any>() +fun <A : Pipeline<*>, T : Any, V> A.feature(feature: <error descr="[WRONG_NUMBER_OF_TYPE_ARGUMENTS] 3 type arguments expected for ApplicationFeature">ApplicationFeature<A, T></error>) : Unit {} diff --git a/idea/testData/checker/diagnosticsMessage/incompleteTypeArgumentList.kt b/idea/testData/checker/diagnosticsMessage/incompleteTypeArgumentList.kt index 5582280a7c2..6db81da7b18 100644 --- a/idea/testData/checker/diagnosticsMessage/incompleteTypeArgumentList.kt +++ b/idea/testData/checker/diagnosticsMessage/incompleteTypeArgumentList.kt @@ -1,3 +1,5 @@ +// IGNORE_FIR + interface ApplicationFeature<in P : Pipeline<*>, B : Any, V> open class Pipeline<TSubject : Any>() -fun <A : Pipeline<*>, T : Any, V> A.feature(<warning>feature</warning>: ApplicationFeature<error descr="[WRONG_NUMBER_OF_TYPE_ARGUMENTS] 3 type arguments expected for interface ApplicationFeature<in P : Pipeline<*>, B : Any, V>"><A, T></error>) : Unit {} \ No newline at end of file +fun <A : Pipeline<*>, T : Any, V> A.feature(<warning>feature</warning>: ApplicationFeature<error descr="[WRONG_NUMBER_OF_TYPE_ARGUMENTS] 3 type arguments expected for interface ApplicationFeature<in P : Pipeline<*>, B : Any, V>"><A, T></error>) : Unit {} diff --git a/idea/testData/checker/diagnosticsMessage/instantiationOfInnerClassInQualifiedForm.fir.kt b/idea/testData/checker/diagnosticsMessage/instantiationOfInnerClassInQualifiedForm.fir.kt new file mode 100644 index 00000000000..0c1091c07a5 --- /dev/null +++ b/idea/testData/checker/diagnosticsMessage/instantiationOfInnerClassInQualifiedForm.fir.kt @@ -0,0 +1,7 @@ +class A { + inner class XYZ + + fun foo() { + val v: A.XYZ = A.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: XYZ">XYZ</error>() + } +} diff --git a/idea/testData/checker/diagnosticsMessage/lateinitOfATypeWithNullableUpperBound.kt b/idea/testData/checker/diagnosticsMessage/lateinitOfATypeWithNullableUpperBound.kt index bfbf3840fb1..b038060ac29 100644 --- a/idea/testData/checker/diagnosticsMessage/lateinitOfATypeWithNullableUpperBound.kt +++ b/idea/testData/checker/diagnosticsMessage/lateinitOfATypeWithNullableUpperBound.kt @@ -1,5 +1,5 @@ -// FIR_COMPARISON +// FIR_IDENTICAL class C<V>() { <error descr="[INAPPLICABLE_LATEINIT_MODIFIER] 'lateinit' modifier is not allowed on properties of a type with nullable upper bound">lateinit</error> var item: V -} \ No newline at end of file +} diff --git a/idea/testData/checker/diagnosticsMessage/nArgumentsExpectedMessage.fir.kt b/idea/testData/checker/diagnosticsMessage/nArgumentsExpectedMessage.fir.kt new file mode 100644 index 00000000000..0d07188bb82 --- /dev/null +++ b/idea/testData/checker/diagnosticsMessage/nArgumentsExpectedMessage.fir.kt @@ -0,0 +1,9 @@ +// IGNORE_FIR + +package name.that.may.be.very.long + +import java.io.Serializable + +interface Foo<T> : Comparable<Foo<T>>, Serializable, Cloneable + +fun test(<warning>f</warning>: <error descr="[WRONG_NUMBER_OF_TYPE_ARGUMENTS] One type argument expected for interface Foo<T>">Foo</error>) {} diff --git a/idea/testData/checker/diagnosticsMessage/nArgumentsExpectedMessage.kt b/idea/testData/checker/diagnosticsMessage/nArgumentsExpectedMessage.kt index 3c8baee264d..0d07188bb82 100644 --- a/idea/testData/checker/diagnosticsMessage/nArgumentsExpectedMessage.kt +++ b/idea/testData/checker/diagnosticsMessage/nArgumentsExpectedMessage.kt @@ -1,7 +1,9 @@ +// IGNORE_FIR + package name.that.may.be.very.long import java.io.Serializable interface Foo<T> : Comparable<Foo<T>>, Serializable, Cloneable -fun test(<warning>f</warning>: <error descr="[WRONG_NUMBER_OF_TYPE_ARGUMENTS] One type argument expected for interface Foo<T>">Foo</error>) {} \ No newline at end of file +fun test(<warning>f</warning>: <error descr="[WRONG_NUMBER_OF_TYPE_ARGUMENTS] One type argument expected for interface Foo<T>">Foo</error>) {} diff --git a/idea/testData/checker/diagnosticsMessage/noSubstitutedTypeParameter.fir.kt b/idea/testData/checker/diagnosticsMessage/noSubstitutedTypeParameter.fir.kt new file mode 100644 index 00000000000..c0b3c5b9176 --- /dev/null +++ b/idea/testData/checker/diagnosticsMessage/noSubstitutedTypeParameter.fir.kt @@ -0,0 +1,6 @@ +// COMPILER_ARGUMENTS: -XXLanguage:-NewInference + +val f = listOf("").<error descr="[INAPPLICABLE_CANDIDATE] Inapplicable candidate(s): /firstOrNull">firstOrNull</error>(1) + +fun <T> listOf(element: T): List<T> = java.util.Collections.singletonList(element) +fun <T> Iterable<T>.firstOrNull(predicate: (T) -> Boolean): T? = null diff --git a/idea/testData/checker/diagnosticsMessage/operatorCallDiagnosticsOnInOperator.fir.kt b/idea/testData/checker/diagnosticsMessage/operatorCallDiagnosticsOnInOperator.fir.kt new file mode 100644 index 00000000000..50a94fee551 --- /dev/null +++ b/idea/testData/checker/diagnosticsMessage/operatorCallDiagnosticsOnInOperator.fir.kt @@ -0,0 +1,8 @@ +fun call() { + val list : String? = "sdfknsdkfm" + "x" <error descr="[UNSAFE_OPERATOR_CALL] Operator call corresponds to a dot-qualified call 'R|<local>/list|.contains(String(x))' which is not allowed on a nullable receiver 'R|<local>/list|'. ">in</error> list + + "x" <error descr="[UNSAFE_OPERATOR_CALL] Operator call corresponds to a dot-qualified call 'R|<local>/list|.contains(String(x))' which is not allowed on a nullable receiver 'R|<local>/list|'. ">!in</error> list +} + +operator fun CharSequence.contains(other: CharSequence, ignoreCase: Boolean = false): Boolean = true diff --git a/idea/testData/checker/infos/CapturedConstructorParameter.kt b/idea/testData/checker/infos/CapturedConstructorParameter.kt index 955975bda25..d52e18d4891 100644 --- a/idea/testData/checker/infos/CapturedConstructorParameter.kt +++ b/idea/testData/checker/infos/CapturedConstructorParameter.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IDENTICAL <info>import</info> kotlin.reflect.KProperty interface T diff --git a/idea/testData/checker/infos/CapturedInInlinedClosure.kt b/idea/testData/checker/infos/CapturedInInlinedClosure.kt index c5cd24bf888..6916e5744da 100644 --- a/idea/testData/checker/infos/CapturedInInlinedClosure.kt +++ b/idea/testData/checker/infos/CapturedInInlinedClosure.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IDENTICAL <info descr="null">inline</info> fun <T> run(f: () -> T) = f() fun run2(f: () -> Unit) = f() @@ -100,4 +100,4 @@ fun usage(param1: Int, param2: Int) { withNoInlineParam({ println(<info descr="Value captured in a closure">param1</info>) }, { println(param2) }) } -fun println(<warning>a</warning>: Any) {} \ No newline at end of file +fun println(<warning>a</warning>: Any) {} diff --git a/idea/testData/checker/infos/PropertiesWithBackingFields.kt b/idea/testData/checker/infos/PropertiesWithBackingFields.kt index ecc173d9ef0..2d1d259929a 100644 --- a/idea/testData/checker/infos/PropertiesWithBackingFields.kt +++ b/idea/testData/checker/infos/PropertiesWithBackingFields.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL <info>abstract</info> class Test() { <info>abstract</info> val x : Int <info>abstract</info> val x1 : Int <info>get</info> @@ -53,4 +54,3 @@ class TestPCParameters(w : Int, <warning>x</warning> : Int, val y : Int, var z : fun foo() = <error>x</error> } -// FIR_COMPARISON \ No newline at end of file diff --git a/idea/testData/checker/infos/SmartCastOnIf.kt b/idea/testData/checker/infos/SmartCastOnIf.kt index f24b5ecff3f..d3981735915 100644 --- a/idea/testData/checker/infos/SmartCastOnIf.kt +++ b/idea/testData/checker/infos/SmartCastOnIf.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IDENTICAL fun baz(s: String?): Int { return if (s == null) { diff --git a/idea/testData/checker/infos/SmartCastOnWhen.kt b/idea/testData/checker/infos/SmartCastOnWhen.kt index d05e7bfe0dc..fdcad5d5668 100644 --- a/idea/testData/checker/infos/SmartCastOnWhen.kt +++ b/idea/testData/checker/infos/SmartCastOnWhen.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IDENTICAL // COMPILER_ARGUMENTS: -XXLanguage:-NewInference diff --git a/idea/testData/checker/infos/SmartCastTarget.kt b/idea/testData/checker/infos/SmartCastTarget.kt index 6850dff6ce3..5171f5efa80 100644 --- a/idea/testData/checker/infos/SmartCastTarget.kt +++ b/idea/testData/checker/infos/SmartCastTarget.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IDENTICAL // See KT-15901 @@ -13,4 +13,4 @@ fun foo(): Any { return a } return "" -} \ No newline at end of file +} diff --git a/idea/testData/checker/infos/SmartCastToEnum.kt b/idea/testData/checker/infos/SmartCastToEnum.kt index 4de884eeaa0..92b903ae60c 100644 --- a/idea/testData/checker/infos/SmartCastToEnum.kt +++ b/idea/testData/checker/infos/SmartCastToEnum.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IDENTICAL package test2 diff --git a/idea/testData/checker/infos/SmartCasts.fir.kt b/idea/testData/checker/infos/SmartCasts.fir.kt new file mode 100644 index 00000000000..4aae9cdb2dd --- /dev/null +++ b/idea/testData/checker/infos/SmartCasts.fir.kt @@ -0,0 +1,282 @@ +// COMPILER_ARGUMENTS: -XXLanguage:-NewInference + +open class A() { + fun foo() { + if (this is B) { + bar() + } + } +} + +class B() : A() { + fun bar() {} +} + +fun f9(a : A?) { + a?.foo() + a?.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: bar">bar</error>() + if (a is B) { + a.bar() + a.foo() + } + a?.foo() + a?.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: bar">bar</error>() + if (!(a is B)) { + a?.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: bar">bar</error>() + a?.foo() + } + if (!(a is B) || a.bar() == Unit) { + a?.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: bar">bar</error>() + } + if (!(a is B)) { + return; + } + a.bar() + a.foo() +} + +fun fAny(a : Any?) { + if (a is B) { + a.bar() + a.foo() + } + if (!(a is B)) { + return; + } + a.bar() + a.foo() +} + +fun f10(a : A?) { + if (!(a is B)) { + return; + } + if (!(a is B)) { + return; + } +} + +class C() : A() { + fun bar() { + + } +} + +fun f101(a : A?) { + if (a is C) { + a.bar(); + } +} + +fun f11(a : A?) { + when (a) { + is B -> a.bar() + is A -> a.foo() + is Any -> a.foo() + is Any? -> a.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: bar">bar</error>() + else -> a?.foo() + } +} + +fun f12(a : A?) { + when (a) { + is B -> a.bar() + is A -> a.foo() + is Any -> a.foo(); + is Any? -> a.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: bar">bar</error>() + is C -> a.bar() + else -> a?.foo() + } + + if (a is Any?) { + a?.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: bar">bar</error>() + } + if (a is B) { + a.bar() + } +} + +fun f13(a : A?) { + if (a is B) { + a.foo() + a.bar() + } + else { + a?.foo() + <error descr="[UNRESOLVED_REFERENCE] Unresolved reference: c">c</error>.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: bar">bar</error>() + } + + a?.foo() + if (!(a is B)) { + a?.foo() + } + else { + a.foo() + } + + a?.foo() + if (a is B && a.foo() == Unit) { + a.foo() + a.bar() + } + else { + a?.foo() + } + + if (!(a is B) || !(a is C)) { + } + else { + } + + if (!(a is B) || !(a is C)) { + } + + if (!(a is B)) return + a.bar() +} + +fun f14(a : A?) { + while (!(a is B)) { + } + a.bar() +} +fun f15(a : A?) { + do { + } while (!(a is B)) + a.bar() +} + +fun getStringLength(obj : Any) : Char? { + if (obj !is String) + return null + return obj.get(0) // no cast to kotlin.String is needed +} + +fun toInt(i: Int?): Int = if (i != null) i else 0 +fun illegalWhenBody(a: Any): Int = when(a) { + is Int -> a + is String -> a + else -> 1 +} +fun illegalWhenBlock(a: Any): Int { + when(a) { + is Int -> return a + is String -> return a + else -> return 1 + } +} +fun declarations(a: Any?) { + if (a is String) { + val p4: String = a + } + if (a is String?) { + if (a != null) { + val s: String = a + } + } + if (a != null) { + if (a is String?) { + val s: String = a + } + } +} +fun vars(a: Any?) { + var b: Int = 0 + if (a is Int) { + b = a + } +} +fun returnFunctionLiteralBlock(a: Any?): Function0<Int> { + if (a is Int) return { a } + else return { 1 } +} +fun returnFunctionLiteral(a: Any?): Function0<Int> = + if (a is Int) (fun (): Int = a) + else { -> 1 } + +fun mergeSmartCasts(a: Any?) { + if (a is String || a is Int) { + a.<error descr="[INAPPLICABLE_CANDIDATE] Inapplicable candidate(s): kotlin/Comparable.compareTo">compareTo</error>("") + a.toString() + } + if (a is Int || a is String) { + a.<error descr="[INAPPLICABLE_CANDIDATE] Inapplicable candidate(s): kotlin/Comparable.compareTo">compareTo</error>("") + } + when (a) { + is String, is Any -> a.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: compareTo">compareTo</error>("") + } + if (a is String && a is Any) { + val i: Int = a.compareTo("") + } + if (a is String && a.compareTo("") == 0) {} + if (a is String || a.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: compareTo">compareTo</error>("") == 0) {} +} + +//mutability +fun f(): String { + var a: Any = 11 + if (a is String) { + val i: String = a + a.compareTo("f") + val f: Function0<String> = { + a = 42 + a + } + return a + } + return "" +} + +class Mutable(var x: String?) { + + val xx: String? + get() = x + + fun foo(): String { + if (x is String) { + return x + } + if (x != null) { + return x + } + if (xx is String) { + return xx + } + return "" + } + + fun bar(other: Mutable): String { + var y = other + if (y.x is String) { + return y.x + } + return "" + } +} + +fun foo(aa: Any): Int { + var a = aa + if (a is Int) { + return a + } + return 1 +} + +fun inForLoop(x: Any?) { + if (x is Array<*>) { + for (i in x) {} + } + <error descr="[UNRESOLVED_REFERENCE] Unresolved reference: hasNext"><error descr="[UNRESOLVED_REFERENCE] Unresolved reference: iterator"><error descr="[UNRESOLVED_REFERENCE] Unresolved reference: next">for (i in x) {}</error></error></error> +} + +class ExplicitAccessorForAnnotation { + val tt: String? = "good" + get + + fun foo(): String { + if (tt is String) { + return tt + } + return "" + } +} diff --git a/idea/testData/checker/infos/SmartCastsWithSafeAccess.kt b/idea/testData/checker/infos/SmartCastsWithSafeAccess.kt index 146cd5f8058..2b0cae619f5 100644 --- a/idea/testData/checker/infos/SmartCastsWithSafeAccess.kt +++ b/idea/testData/checker/infos/SmartCastsWithSafeAccess.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IDENTICAL interface A { fun foo() diff --git a/idea/testData/checker/infos/Typos.fir.kt b/idea/testData/checker/infos/Typos.fir.kt new file mode 100644 index 00000000000..84244e390e4 --- /dev/null +++ b/idea/testData/checker/infos/Typos.fir.kt @@ -0,0 +1,10 @@ +package kara.internal + +/* Test somthing */ +class MoreeFun { + fun wrte() { + val childen = 12 + val come = childen + wrte() + } +} diff --git a/idea/testData/checker/infos/TyposInOverrideParams.fir.kt b/idea/testData/checker/infos/TyposInOverrideParams.fir.kt new file mode 100644 index 00000000000..f0c3ba5bcd1 --- /dev/null +++ b/idea/testData/checker/infos/TyposInOverrideParams.fir.kt @@ -0,0 +1,14 @@ +abstract class Base { + abstract fun foo(oher: Int) + + abstract val smalVal: Int + abstract fun smalFun() +} + +class Other : Base() { + override fun foo(oher: Int) { + } + + override val smalVal: Int get() = 1 + override fun smalFun() {} +} diff --git a/idea/testData/checker/infos/WrapIntoRef.kt b/idea/testData/checker/infos/WrapIntoRef.kt index 7783e1cb7e2..e9f589edee3 100644 --- a/idea/testData/checker/infos/WrapIntoRef.kt +++ b/idea/testData/checker/infos/WrapIntoRef.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IDENTICAL fun refs() { var <warning>a</warning> = 1 diff --git a/idea/testData/checker/infos/multipleResolvedCalls.kt b/idea/testData/checker/infos/multipleResolvedCalls.kt index 9818e84ef2e..461b8e34d9c 100644 --- a/idea/testData/checker/infos/multipleResolvedCalls.kt +++ b/idea/testData/checker/infos/multipleResolvedCalls.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IDENTICAL interface I1 interface I2 diff --git a/idea/testData/checker/infos/smartCastOnElvis.kt b/idea/testData/checker/infos/smartCastOnElvis.kt index cade61c18c6..30bea136897 100644 --- a/idea/testData/checker/infos/smartCastOnElvis.kt +++ b/idea/testData/checker/infos/smartCastOnElvis.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IDENTICAL // COMPILER_ARGUMENTS: -XXLanguage:-NewInference @@ -16,4 +16,4 @@ fun bar(s: String?, r: String?): Int { s != null -> <info descr="Smart cast to kotlin.String">s</info> else -> "" }).length -} \ No newline at end of file +} diff --git a/idea/testData/checker/infos/threeImplicitReceivers.kt b/idea/testData/checker/infos/threeImplicitReceivers.kt index 44c7f56125f..7d49e2a2797 100644 --- a/idea/testData/checker/infos/threeImplicitReceivers.kt +++ b/idea/testData/checker/infos/threeImplicitReceivers.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IDENTICAL interface IA interface IB interface IC diff --git a/idea/testData/checker/infos/twoImplicitReceivers.kt b/idea/testData/checker/infos/twoImplicitReceivers.kt index 74aaf042762..628aa7b9da3 100644 --- a/idea/testData/checker/infos/twoImplicitReceivers.kt +++ b/idea/testData/checker/infos/twoImplicitReceivers.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IDENTICAL interface IA interface IB diff --git a/idea/testData/checker/kt32189returnTypeWithTypealiasSubtitution.kt b/idea/testData/checker/kt32189returnTypeWithTypealiasSubtitution.kt index 328794cc896..da1c7757b21 100644 --- a/idea/testData/checker/kt32189returnTypeWithTypealiasSubtitution.kt +++ b/idea/testData/checker/kt32189returnTypeWithTypealiasSubtitution.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IDENTICAL class B { class Builder } diff --git a/idea/testData/checker/recovery/namelessMembers.fir.kt b/idea/testData/checker/recovery/namelessMembers.fir.kt new file mode 100644 index 00000000000..4575656dc66 --- /dev/null +++ b/idea/testData/checker/recovery/namelessMembers.fir.kt @@ -0,0 +1,15 @@ +class C { + <error descr="[FUNCTION_DECLARATION_WITH_NO_NAME] Function declaration must have a name">fun ()</error> { + + } + + val<error descr="Expecting property name or receiver type"> </error>: Int = 1 + + class<error descr="Name expected"> </error>{} + + enum class<error descr="Name expected"> </error>{} +} + +class C1<<error descr="Type parameter name expected">in</error>> {} + +class C2(<error descr="[VALUE_PARAMETER_WITH_NO_TYPE_ANNOTATION] A type annotation is required on a value parameter">val</error><error descr="Parameter name expected">)</error> {} diff --git a/idea/testData/checker/recovery/namelessMembers.kt b/idea/testData/checker/recovery/namelessMembers.kt index 4bce5b81a09..25080b19da4 100644 --- a/idea/testData/checker/recovery/namelessMembers.kt +++ b/idea/testData/checker/recovery/namelessMembers.kt @@ -1,5 +1,3 @@ -// IGNORE_FIR - class C { <error>fun ()</error> { @@ -14,4 +12,4 @@ class C { class C1<<error>in</error>> {} -class C2(val<error>)</error> {} \ No newline at end of file +class C2(val<error>)</error> {} diff --git a/idea/testData/checker/recovery/namelessToplevelDeclarations.fir.kt b/idea/testData/checker/recovery/namelessToplevelDeclarations.fir.kt new file mode 100644 index 00000000000..0ef27de8c1f --- /dev/null +++ b/idea/testData/checker/recovery/namelessToplevelDeclarations.fir.kt @@ -0,0 +1,24 @@ +package<EOLError descr="Package name must be a '.'-separated identifier list placed on a single line"></EOLError> + +<error descr="[FUNCTION_DECLARATION_WITH_NO_NAME] Function declaration must have a name">fun ()</error> { + +} + +val<error descr="Expecting property name or receiver type"> </error>: Int = 1 + + +class<error descr="Name expected"> </error>{ + +} + +interface<error descr="Name expected"> </error>{ + +} + +object<error descr="Name expected"> </error>{ + +} + +enum class<error descr="Name expected"> </error>{} + +annotation class<error descr="Name expected"> </error>{} diff --git a/idea/testData/checker/recovery/namelessToplevelDeclarations.kt b/idea/testData/checker/recovery/namelessToplevelDeclarations.kt index b7b8fa08d97..a59c093f98e 100644 --- a/idea/testData/checker/recovery/namelessToplevelDeclarations.kt +++ b/idea/testData/checker/recovery/namelessToplevelDeclarations.kt @@ -1,5 +1,3 @@ -// IGNORE_FIR - package<EOLError></EOLError> <error>fun ()</error> { @@ -23,4 +21,4 @@ object<error> </error>{ enum class<error> </error>{} -annotation class<error> </error>{} \ No newline at end of file +annotation class<error> </error>{} diff --git a/idea/testData/checker/recovery/returnInFileAnnotation.fir.kt b/idea/testData/checker/recovery/returnInFileAnnotation.fir.kt new file mode 100644 index 00000000000..3d0ffd00af3 --- /dev/null +++ b/idea/testData/checker/recovery/returnInFileAnnotation.fir.kt @@ -0,0 +1 @@ +@file:<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: suppress">suppress</error>(return a) diff --git a/idea/testData/checker/regression/AmbiguityOnLazyTypeComputation.kt b/idea/testData/checker/regression/AmbiguityOnLazyTypeComputation.kt index 6e01e5ead84..cfc6d88d14f 100644 --- a/idea/testData/checker/regression/AmbiguityOnLazyTypeComputation.kt +++ b/idea/testData/checker/regression/AmbiguityOnLazyTypeComputation.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IDENTICAL // One of the two passes is making a scope and turning vals into functions // See KT-76 diff --git a/idea/testData/checker/regression/AnnotationOnNamedParameterOfFunctionType.fir.kt b/idea/testData/checker/regression/AnnotationOnNamedParameterOfFunctionType.fir.kt new file mode 100644 index 00000000000..c7fa4688a62 --- /dev/null +++ b/idea/testData/checker/regression/AnnotationOnNamedParameterOfFunctionType.fir.kt @@ -0,0 +1,3 @@ +fun <K, V> intercept(block: (@<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: A">A</error> key: K, (K) -> V) -> V) { + +} diff --git a/idea/testData/checker/regression/AnnotationOnParameterOfFunctionType.fir.kt b/idea/testData/checker/regression/AnnotationOnParameterOfFunctionType.fir.kt new file mode 100644 index 00000000000..005c91fc3da --- /dev/null +++ b/idea/testData/checker/regression/AnnotationOnParameterOfFunctionType.fir.kt @@ -0,0 +1,5 @@ +fun <K, V> intercept(block: (@A K, (K) -> V) -> V) { + +} + +annotation class A diff --git a/idea/testData/checker/regression/AssignmentsUnderOperators.kt b/idea/testData/checker/regression/AssignmentsUnderOperators.kt index ee8f2f88802..8c5a8c8a202 100644 --- a/idea/testData/checker/regression/AssignmentsUnderOperators.kt +++ b/idea/testData/checker/regression/AssignmentsUnderOperators.kt @@ -1,8 +1,8 @@ -// FIR_COMPARISON +// FIR_IDENTICAL fun test() { var a : Any? = null if (a is Any) else a = null; while (a is Any) a = null while (true) <warning>a =</warning> null -} \ No newline at end of file +} diff --git a/idea/testData/checker/regression/BadParseForClass.fir.kt b/idea/testData/checker/regression/BadParseForClass.fir.kt new file mode 100644 index 00000000000..b5c10ec1907 --- /dev/null +++ b/idea/testData/checker/regression/BadParseForClass.fir.kt @@ -0,0 +1,5 @@ +fun main(args: Array<String>) { + String.<error descr="[EXPRESSION_REQUIRED] ">class</error><EOLError descr="Name expected"></EOLError> +} + +// EA-56152: An attempt to build light class in checker to get diagnotics diff --git a/idea/testData/checker/regression/ClassDeclarationAfterDot.fir.kt b/idea/testData/checker/regression/ClassDeclarationAfterDot.fir.kt new file mode 100644 index 00000000000..dc8b1ecafa5 --- /dev/null +++ b/idea/testData/checker/regression/ClassDeclarationAfterDot.fir.kt @@ -0,0 +1,5 @@ +class A + +fun f() { + A.<error descr="[EXPRESSION_REQUIRED] ">class</error><EOLError descr="Name expected"></EOLError> +} diff --git a/idea/testData/checker/regression/ClassDeclarationAfterDot2.kt b/idea/testData/checker/regression/ClassDeclarationAfterDot2.kt index eb9fd988186..f1f0891f373 100644 --- a/idea/testData/checker/regression/ClassDeclarationAfterDot2.kt +++ b/idea/testData/checker/regression/ClassDeclarationAfterDot2.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IDENTICAL class A diff --git a/idea/testData/checker/regression/ClassDeclarationAsExpression.fir.kt b/idea/testData/checker/regression/ClassDeclarationAsExpression.fir.kt new file mode 100644 index 00000000000..d01010738dc --- /dev/null +++ b/idea/testData/checker/regression/ClassDeclarationAsExpression.fir.kt @@ -0,0 +1,5 @@ +val p = 1 <error descr="[AMBIGUITY] Ambiguity between candidates: [kotlin/Int.compareTo, kotlin/Int.compareTo, kotlin/Int.compareTo, ...]"><</error> <error descr="[EXPRESSION_REQUIRED] ">class A { + fun f() { + f() + } +}</error> diff --git a/idea/testData/checker/regression/ClassDeclarationAsExpression2.fir.kt b/idea/testData/checker/regression/ClassDeclarationAsExpression2.fir.kt new file mode 100644 index 00000000000..7b11e72d26d --- /dev/null +++ b/idea/testData/checker/regression/ClassDeclarationAsExpression2.fir.kt @@ -0,0 +1 @@ +fun g() = 1 <error descr="[AMBIGUITY] Ambiguity between candidates: [kotlin/Int.compareTo, kotlin/Int.compareTo, kotlin/Int.compareTo, ...]"><</error> <error descr="[EXPRESSION_REQUIRED] ">class A</error> diff --git a/idea/testData/checker/regression/ClassDeclarationAsExpression3.fir.kt b/idea/testData/checker/regression/ClassDeclarationAsExpression3.fir.kt new file mode 100644 index 00000000000..ee45f361ade --- /dev/null +++ b/idea/testData/checker/regression/ClassDeclarationAsExpression3.fir.kt @@ -0,0 +1,7 @@ +fun f(i: Int = 3 <error descr="[AMBIGUITY] Ambiguity between candidates: [kotlin/Int.compareTo, kotlin/Int.compareTo, kotlin/Int.compareTo, ...]"><</error> <error descr="[EXPRESSION_REQUIRED] ">class A { + fun f() { + f() + } +}</error>) { + +} diff --git a/idea/testData/checker/regression/CoercionToUnit.fir.kt b/idea/testData/checker/regression/CoercionToUnit.fir.kt new file mode 100644 index 00000000000..af845e1537a --- /dev/null +++ b/idea/testData/checker/regression/CoercionToUnit.fir.kt @@ -0,0 +1,9 @@ +fun foo(u : Unit) : Int = 1 + +fun test() : Int { + <error descr="[INAPPLICABLE_CANDIDATE] Inapplicable candidate(s): /foo">foo</error>(1) + val a : () -> Unit = { + <error descr="[INAPPLICABLE_CANDIDATE] Inapplicable candidate(s): /foo">foo</error>(1) + } + return 1 +} diff --git a/idea/testData/checker/regression/DescructuringDeclarationInForLoop.fir.kt b/idea/testData/checker/regression/DescructuringDeclarationInForLoop.fir.kt new file mode 100644 index 00000000000..1a53ad4b24d --- /dev/null +++ b/idea/testData/checker/regression/DescructuringDeclarationInForLoop.fir.kt @@ -0,0 +1,3 @@ +fun main() { + <error descr="[UNRESOLVED_REFERENCE] Unresolved reference: hasNext"><error descr="[UNRESOLVED_REFERENCE] Unresolved reference: iterator"><error descr="[UNRESOLVED_REFERENCE] Unresolved reference: next">for ((i, j)<error descr="Expecting 'in'">)</error> {}</error></error></error> +} diff --git a/idea/testData/checker/regression/DestructuringDeclarationInLambda.kt b/idea/testData/checker/regression/DestructuringDeclarationInLambda.kt index 6e7dcf0a66c..4680eeed218 100644 --- a/idea/testData/checker/regression/DestructuringDeclarationInLambda.kt +++ b/idea/testData/checker/regression/DestructuringDeclarationInLambda.kt @@ -1,7 +1,7 @@ -// FIR_COMPARISON +// FIR_IDENTICAL data class XY(val x: Int, val y: Int) fun convert(xy: XY, f: (XY) -> Int) = f(xy) -fun foo() = <error>convert</error> { (<error>x</error><error><error>,</error> y)</error> } \ No newline at end of file +fun foo() = <error>convert</error> { (<error>x</error><error><error>,</error> y)</error> } diff --git a/idea/testData/checker/regression/DollarsInName.kt b/idea/testData/checker/regression/DollarsInName.kt index df0370d7727..6230604b7a3 100644 --- a/idea/testData/checker/regression/DollarsInName.kt +++ b/idea/testData/checker/regression/DollarsInName.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IDENTICAL class `A$B` { class `$$$` { @@ -14,4 +14,4 @@ fun f() { inner class `C$D` } } -} \ No newline at end of file +} diff --git a/idea/testData/checker/regression/DoubleDefine.fir.kt b/idea/testData/checker/regression/DoubleDefine.fir.kt new file mode 100644 index 00000000000..96b2383e0b6 --- /dev/null +++ b/idea/testData/checker/regression/DoubleDefine.fir.kt @@ -0,0 +1,66 @@ +// RUNTIME +import java.util.* + +import java.io.* + +fun takeFirst(expr: StringBuilder): Char { + val c = expr.get(0) + expr.deleteCharAt(0) + return c +} + +fun evaluateArg(expr: CharSequence, numbers: ArrayList<Int>): Int { + if (expr.length == 0) throw Exception("Syntax error: Character expected"); + val c = <error descr="[INAPPLICABLE_CANDIDATE] Inapplicable candidate(s): /takeFirst">takeFirst</error>(expr) + if (c >= '0' && c <= '9') { + val n = c - '0' + if (!numbers.contains(n)) throw Exception("You used incorrect number: " + n) + numbers.remove(n) + return n + } + throw Exception("Syntax error: Unrecognized character " + c) +} + +fun evaluateAdd(expr: StringBuilder, numbers: ArrayList<Int>): Int { + val lhs = evaluateArg(expr, numbers) + if (expr.length > 0) { + + } + return lhs +} + +fun evaluate(expr: StringBuilder, numbers: ArrayList<Int>): Int { + val lhs = evaluateAdd(expr, numbers) + if (expr.length > 0) { + val c = expr.get(0) + expr.deleteCharAt(0) + } + return lhs +} + +fun main(args: Array<String>) { + System.out.println("24 game") + val numbers = ArrayList<Int>(4) + val rnd = Random(); + val prompt = StringBuilder() + for(i in 0..3) { + val n = rnd.nextInt(9) + 1 + numbers.add(n) + if (i > 0) prompt.append(" "); + prompt.append(n) + } + System.out.println("Your numbers: " + prompt) + System.out.println("Enter your expression:") + val reader = BufferedReader(InputStreamReader(System.`in`)) + val expr = StringBuilder(reader.readLine()!!) + try { + val result = evaluate(expr, numbers) + if (result != 24) + System.out.println("Sorry, that's " + result) + else + System.out.println("You won!"); + } + catch(e: Throwable) { + System.out.println(e.message) + } +} diff --git a/idea/testData/checker/regression/FunDeclarationAfterDot.fir.kt b/idea/testData/checker/regression/FunDeclarationAfterDot.fir.kt new file mode 100644 index 00000000000..3c49b063207 --- /dev/null +++ b/idea/testData/checker/regression/FunDeclarationAfterDot.fir.kt @@ -0,0 +1,7 @@ +class A + +fun f() { + A.<error descr="[EXPRESSION_REQUIRED] ">fun g() { + g() + }</error> +} diff --git a/idea/testData/checker/regression/FunctionLiteralInsideAnnotation.kt b/idea/testData/checker/regression/FunctionLiteralInsideAnnotation.kt index 997b405c3b1..a49a5ae3b0e 100644 --- a/idea/testData/checker/regression/FunctionLiteralInsideAnnotation.kt +++ b/idea/testData/checker/regression/FunctionLiteralInsideAnnotation.kt @@ -1,5 +1,5 @@ -// FIR_COMPARISON +// FIR_IDENTICAL package foo @<error>Anno</error> ({ val x: Int }) -fun f() {} \ No newline at end of file +fun f() {} diff --git a/idea/testData/checker/regression/FunctionTypes.kt b/idea/testData/checker/regression/FunctionTypes.kt index b3d7eadf586..f14e8b6ef72 100644 --- a/idea/testData/checker/regression/FunctionTypes.kt +++ b/idea/testData/checker/regression/FunctionTypes.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IDENTICAL fun <K, V> intercept(<warning>block</warning>: (key: K, next: (K) -> V, K) -> V) { } @@ -23,4 +23,4 @@ interface I<T> val c = object : I<(String) -> String> {} -class CCC() : I<(Int) -> Int> \ No newline at end of file +class CCC() : I<(Int) -> Int> diff --git a/idea/testData/checker/regression/IncompleteClassDelegation.fir.kt b/idea/testData/checker/regression/IncompleteClassDelegation.fir.kt new file mode 100644 index 00000000000..b25db772707 --- /dev/null +++ b/idea/testData/checker/regression/IncompleteClassDelegation.fir.kt @@ -0,0 +1,15 @@ +package c + +class C<T>: <error descr="[SUPERTYPE_NOT_A_CLASS_OR_INTERFACE] Supertype is not a class or interface">T</error> by { +} + +class D<T>: <error descr="[SUPERTYPE_NOT_A_CLASS_OR_INTERFACE] Supertype is not a class or interface">T</error> by<EOLError descr="Expecting an expression"></EOLError> + +class G<T> : <error descr="[SUPERTYPE_NOT_A_CLASS_OR_INTERFACE] Supertype is not a class or interface">T</error> by { + + val c = 3 +} + +interface I + +class A<T : I>(a: T) : <error descr="[SUPERTYPE_NOT_A_CLASS_OR_INTERFACE] Supertype is not a class or interface">T</error> by a diff --git a/idea/testData/checker/regression/InitializerInInterface.fir.kt b/idea/testData/checker/regression/InitializerInInterface.fir.kt new file mode 100644 index 00000000000..9f7478cd1e6 --- /dev/null +++ b/idea/testData/checker/regression/InitializerInInterface.fir.kt @@ -0,0 +1,6 @@ +interface I { + init { + val c = 1 + val g = c + } +} diff --git a/idea/testData/checker/regression/InterfaceDeclarationAsExpression.fir.kt b/idea/testData/checker/regression/InterfaceDeclarationAsExpression.fir.kt new file mode 100644 index 00000000000..d020b156090 --- /dev/null +++ b/idea/testData/checker/regression/InterfaceDeclarationAsExpression.fir.kt @@ -0,0 +1,5 @@ +val p = 1 <error descr="[AMBIGUITY] Ambiguity between candidates: [kotlin/Int.compareTo, kotlin/Int.compareTo, kotlin/Int.compareTo, ...]"><</error> <error descr="[EXPRESSION_REQUIRED] ">interface A { + fun f() { + f() + } +}</error> diff --git a/idea/testData/checker/regression/Jet11.fir.kt b/idea/testData/checker/regression/Jet11.fir.kt new file mode 100644 index 00000000000..bcd3207efb6 --- /dev/null +++ b/idea/testData/checker/regression/Jet11.fir.kt @@ -0,0 +1,4 @@ +// JET-11 Redeclaration & Forward reference for classes cause an exception +<error descr="[REDECLARATION] Conflicting declarations: [NoC]">open class NoC</error> +class NoC1 : NoC() +<error descr="[REDECLARATION] Conflicting declarations: [NoC]">open class NoC</error> diff --git a/idea/testData/checker/regression/Jet121.kt b/idea/testData/checker/regression/Jet121.kt index 44e47a1b7cc..b8918ed4c30 100644 --- a/idea/testData/checker/regression/Jet121.kt +++ b/idea/testData/checker/regression/Jet121.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IDENTICAL package jet121 fun box(): String { diff --git a/idea/testData/checker/regression/Jet124.kt b/idea/testData/checker/regression/Jet124.kt index c0e02d7503a..4c82a87afda 100644 --- a/idea/testData/checker/regression/Jet124.kt +++ b/idea/testData/checker/regression/Jet124.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IDENTICAL fun foo1() : (Int) -> Int = { x: Int -> x } diff --git a/idea/testData/checker/regression/Jet169.kt b/idea/testData/checker/regression/Jet169.kt index 0184765c3c5..49099c01e1f 100644 --- a/idea/testData/checker/regression/Jet169.kt +++ b/idea/testData/checker/regression/Jet169.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IDENTICAL fun set(<warning>key</warning> : String, <warning>value</warning> : String) { val a : String? = "" diff --git a/idea/testData/checker/regression/Jet183-1.kt b/idea/testData/checker/regression/Jet183-1.kt index fb4cfa5464e..78c91bfd793 100644 --- a/idea/testData/checker/regression/Jet183-1.kt +++ b/idea/testData/checker/regression/Jet183-1.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IDENTICAL enum class ProtocolState { WAITING { @@ -20,4 +20,4 @@ fun box(): String { x = x.signal() if (x != ProtocolState.WAITING) return "fail 2" return "OK" -} \ No newline at end of file +} diff --git a/idea/testData/checker/regression/Jet183.kt b/idea/testData/checker/regression/Jet183.kt index f308938215a..6467bd8aefd 100644 --- a/idea/testData/checker/regression/Jet183.kt +++ b/idea/testData/checker/regression/Jet183.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IDENTICAL enum class ProtocolState { WAITING { diff --git a/idea/testData/checker/regression/Jet53.kt b/idea/testData/checker/regression/Jet53.kt index 382978af233..985de058084 100644 --- a/idea/testData/checker/regression/Jet53.kt +++ b/idea/testData/checker/regression/Jet53.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IDENTICAL import java.util.Collections fun <T> checkSubtype(t: T) = t diff --git a/idea/testData/checker/regression/Jet67.kt b/idea/testData/checker/regression/Jet67.kt index d06b8eed039..e4b81f2833a 100644 --- a/idea/testData/checker/regression/Jet67.kt +++ b/idea/testData/checker/regression/Jet67.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IDENTICAL abstract class XXX { abstract val a : Int get diff --git a/idea/testData/checker/regression/Jet68.kt b/idea/testData/checker/regression/Jet68.kt index fffa246c6e3..6819b1da2eb 100644 --- a/idea/testData/checker/regression/Jet68.kt +++ b/idea/testData/checker/regression/Jet68.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IDENTICAL class Foo() @@ -10,4 +10,4 @@ fun test() { if (f != null) { } -} \ No newline at end of file +} diff --git a/idea/testData/checker/regression/Jet69.kt b/idea/testData/checker/regression/Jet69.kt index ca9801cac90..e66739851b6 100644 --- a/idea/testData/checker/regression/Jet69.kt +++ b/idea/testData/checker/regression/Jet69.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IDENTICAL class Command() {} diff --git a/idea/testData/checker/regression/Jet72.kt b/idea/testData/checker/regression/Jet72.kt index e0f32c079e6..8a07bbf84af 100644 --- a/idea/testData/checker/regression/Jet72.kt +++ b/idea/testData/checker/regression/Jet72.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IDENTICAL // JET-72 Type inference doesn't work when iterating over ArrayList diff --git a/idea/testData/checker/regression/OverrideResolution.kt b/idea/testData/checker/regression/OverrideResolution.kt index 2392d370b12..e495824aed6 100644 --- a/idea/testData/checker/regression/OverrideResolution.kt +++ b/idea/testData/checker/regression/OverrideResolution.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IDENTICAL fun box() { val a : C = C() diff --git a/idea/testData/checker/regression/PropertyDeclarationAsExpression.kt b/idea/testData/checker/regression/PropertyDeclarationAsExpression.kt index 77bffab3ac6..1236f5b0e80 100644 --- a/idea/testData/checker/regression/PropertyDeclarationAsExpression.kt +++ b/idea/testData/checker/regression/PropertyDeclarationAsExpression.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IDENTICAL val f = 1 <error>></error><EOLError descr="Expecting an element"></EOLError> val g: Int = 3 diff --git a/idea/testData/checker/regression/ScopeForSecondaryConstructors.kt b/idea/testData/checker/regression/ScopeForSecondaryConstructors.kt index e542461041e..ed312441322 100644 --- a/idea/testData/checker/regression/ScopeForSecondaryConstructors.kt +++ b/idea/testData/checker/regression/ScopeForSecondaryConstructors.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IDENTICAL fun <T> checkSubtype(t: T) = t @@ -19,4 +19,3 @@ class Foo(var bar : Int, var barr : Int, var barrr : Int) { checkSubtype<Foo>(this) } } - diff --git a/idea/testData/checker/regression/SpecififcityByReceiver.kt b/idea/testData/checker/regression/SpecififcityByReceiver.kt index 62833ba2ff6..1fac1837910 100644 --- a/idea/testData/checker/regression/SpecififcityByReceiver.kt +++ b/idea/testData/checker/regression/SpecififcityByReceiver.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IDENTICAL fun Any.<warning descr="[EXTENSION_SHADOWED_BY_MEMBER] Extension is shadowed by a member: public open operator fun equals(other: Any?): Boolean">equals</warning>(<warning descr="[UNUSED_PARAMETER] Parameter 'other' is never used">other</warning> : Any?) : Boolean = true @@ -8,4 +8,4 @@ fun main(<warning descr="[UNUSED_PARAMETER] Parameter 'args' is never used">args command<warning descr="[UNNECESSARY_SAFE_CALL] Unnecessary safe call on a non-null receiver of type Any">?.</warning>equals(null) command.equals(null) -} \ No newline at end of file +} diff --git a/idea/testData/checker/regression/WrongTraceInCallResolver.fir.kt b/idea/testData/checker/regression/WrongTraceInCallResolver.fir.kt new file mode 100644 index 00000000000..af8990c2eaa --- /dev/null +++ b/idea/testData/checker/regression/WrongTraceInCallResolver.fir.kt @@ -0,0 +1,9 @@ +open class Foo {} +open class Bar {} + +fun <T : Bar, T1> foo(x : Int) {} +fun <T1, T : Foo> foo(x : Long) {} + +fun f(): Unit { + <error descr="[NONE_APPLICABLE] None of the following functions are applicable: [/foo, /foo]">foo</error><Int, Int>(1) +} diff --git a/idea/testData/checker/regression/callVariableAsFunctionWithAnonymousObjectArg.kt b/idea/testData/checker/regression/callVariableAsFunctionWithAnonymousObjectArg.kt index 1628cebc406..c51724d84f7 100644 --- a/idea/testData/checker/regression/callVariableAsFunctionWithAnonymousObjectArg.kt +++ b/idea/testData/checker/regression/callVariableAsFunctionWithAnonymousObjectArg.kt @@ -1,5 +1,5 @@ -// FIR_COMPARISON +// FIR_IDENTICAL fun f() { val g = 3 <error>g</error>(object : Any() {}) -} \ No newline at end of file +} diff --git a/idea/testData/checker/regression/callVariableAsFunctionWithLambdaArg.fir.kt b/idea/testData/checker/regression/callVariableAsFunctionWithLambdaArg.fir.kt new file mode 100644 index 00000000000..3d2d152b091 --- /dev/null +++ b/idea/testData/checker/regression/callVariableAsFunctionWithLambdaArg.fir.kt @@ -0,0 +1,5 @@ +fun f() { + val g = 3 + <error descr="[UNRESOLVED_REFERENCE] Unresolved reference: g">g</error> { workingSet, customer -> + } +} diff --git a/idea/testData/checker/regression/createInnerInstance.kt b/idea/testData/checker/regression/createInnerInstance.kt index 2ec19957964..1af74067e2b 100644 --- a/idea/testData/checker/regression/createInnerInstance.kt +++ b/idea/testData/checker/regression/createInnerInstance.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IDENTICAL object A { class B diff --git a/idea/testData/checker/regression/extensionMemberInClassObject.kt b/idea/testData/checker/regression/extensionMemberInClassObject.kt index 4ef0359c9c0..87631befcd0 100644 --- a/idea/testData/checker/regression/extensionMemberInClassObject.kt +++ b/idea/testData/checker/regression/extensionMemberInClassObject.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IDENTICAL interface Bar { fun <T> T.bar() {} @@ -10,4 +10,4 @@ class A { fun test() { A.<error><error>bar</error></error>() -} \ No newline at end of file +} diff --git a/idea/testData/checker/regression/javaStyleClassLiteralInAnnotationArguments.fir.kt b/idea/testData/checker/regression/javaStyleClassLiteralInAnnotationArguments.fir.kt new file mode 100644 index 00000000000..430078b8aeb --- /dev/null +++ b/idea/testData/checker/regression/javaStyleClassLiteralInAnnotationArguments.fir.kt @@ -0,0 +1,6 @@ +annotation class A + +class B + +@A(B.class<error descr="Name expected">)</error><EOLError descr="Expecting ','"></EOLError> +<error descr="[TOO_MANY_ARGUMENTS] Too many arguments for public constructor A() defined in A"><error descr="[TOO_MANY_ARGUMENTS] Too many arguments for public constructor A() defined in A">fun <error descr="[ANONYMOUS_FUNCTION_WITH_NAME] Anonymous functions with names are prohibited">f</error>() {}</error></error><EOLError descr="Expecting a top level declaration"></EOLError><EOLError descr="Expecting ')'"></EOLError> diff --git a/idea/testData/checker/regression/kt251.fir.kt b/idea/testData/checker/regression/kt251.fir.kt new file mode 100644 index 00000000000..88ff66ca34c --- /dev/null +++ b/idea/testData/checker/regression/kt251.fir.kt @@ -0,0 +1,33 @@ +class A() { + var x: Int = 0 + get() = "s" + set(value: String) { + field = value + } + val y: Int + get(): String = "s" + val z: Int + get() { + return "s" + } + + var a: Any = 1 + set(v: String) { + field = v + } + val b: Int + get(): Any = "s" + val c: Int + get() { + return 1 + } + val d = 1 + get() { + return field + } + val e = 1 + get(): String { + return field + } + +} diff --git a/idea/testData/checker/regression/kt303.fir.kt b/idea/testData/checker/regression/kt303.fir.kt new file mode 100644 index 00000000000..8a324d553b6 --- /dev/null +++ b/idea/testData/checker/regression/kt303.fir.kt @@ -0,0 +1,11 @@ +// KT-303 Stack overflow on a cyclic class hierarchy + +open class Foo() : Bar() { + val a : Int = 1 +} + +open class Bar() : <error descr="[OTHER_ERROR] Unknown (other) error">Foo</error>() { + +} + +val x : Int = Foo() diff --git a/idea/testData/checker/regression/kt9887.fir.kt b/idea/testData/checker/regression/kt9887.fir.kt new file mode 100644 index 00000000000..8ae32fa024c --- /dev/null +++ b/idea/testData/checker/regression/kt9887.fir.kt @@ -0,0 +1,7 @@ +// IGNORE_FIR + +open class A<T>() +class G<T>() + + +class B : A<<error descr="[WRONG_NUMBER_OF_TYPE_ARGUMENTS] One type argument expected for class G<T>">G</error>>() diff --git a/idea/testData/checker/regression/kt9887.kt b/idea/testData/checker/regression/kt9887.kt index 4ad82a0d5de..8ae32fa024c 100644 --- a/idea/testData/checker/regression/kt9887.kt +++ b/idea/testData/checker/regression/kt9887.kt @@ -1,5 +1,7 @@ +// IGNORE_FIR + open class A<T>() class G<T>() -class B : A<<error descr="[WRONG_NUMBER_OF_TYPE_ARGUMENTS] One type argument expected for class G<T>">G</error>>() \ No newline at end of file +class B : A<<error descr="[WRONG_NUMBER_OF_TYPE_ARGUMENTS] One type argument expected for class G<T>">G</error>>() diff --git a/idea/testData/checker/regression/objectLiteralInSupertypeList.kt b/idea/testData/checker/regression/objectLiteralInSupertypeList.kt index b652f417b69..00b6025c633 100644 --- a/idea/testData/checker/regression/objectLiteralInSupertypeList.kt +++ b/idea/testData/checker/regression/objectLiteralInSupertypeList.kt @@ -1,7 +1,7 @@ -// FIR_COMPARISON +// FIR_IDENTICAL interface A open class B(<warning>i</warning>: Int, <warning>a</warning>: A) -class C() : B(3, object : A {}) \ No newline at end of file +class C() : B(3, object : A {}) diff --git a/idea/testData/checker/rendering/TypeInferenceError.fir.kt b/idea/testData/checker/rendering/TypeInferenceError.fir.kt new file mode 100644 index 00000000000..f8e00fefc51 --- /dev/null +++ b/idea/testData/checker/rendering/TypeInferenceError.fir.kt @@ -0,0 +1,13 @@ +// COMPILER_ARGUMENTS: -XXLanguage:-NewInference + +fun <K, V> testMutableMapEntry(map: MutableMap<K, V>, k1: K, v: V) { +} + +fun foo() { + <error descr="[INAPPLICABLE_CANDIDATE] Inapplicable candidate(s): /testMutableMapEntry">testMutableMapEntry</error>(hashMap(1 to 'a'), 'b') +} + +//extract from library +fun <K, V> hashMap(p: Pair<K, V>): MutableMap<K, V> {} +infix fun <K, V> K.to(v: V): Pair<K, V> {} +class Pair<K, V> {} diff --git a/idea/testData/checker/trivialHierarchyLoop.fir.kt b/idea/testData/checker/trivialHierarchyLoop.fir.kt new file mode 100644 index 00000000000..ac3602ab173 --- /dev/null +++ b/idea/testData/checker/trivialHierarchyLoop.fir.kt @@ -0,0 +1,3 @@ +class A : <error descr="[OTHER_ERROR] Unknown (other) error">A</error>() {} + +val x : Int = A() diff --git a/idea/tests/org/jetbrains/kotlin/checkers/KotlinHighlightWolfPassTestGenerated.java b/idea/tests/org/jetbrains/kotlin/checkers/KotlinHighlightWolfPassTestGenerated.java index c7e4450c9a8..7a6bc9e9d29 100644 --- a/idea/tests/org/jetbrains/kotlin/checkers/KotlinHighlightWolfPassTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/checkers/KotlinHighlightWolfPassTestGenerated.java @@ -26,7 +26,7 @@ public class KotlinHighlightWolfPassTestGenerated extends AbstractKotlinHighligh } public void testAllFilesPresentInWolf() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/checker/wolf"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/checker/wolf"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); } @TestMetadata("diagnostic.kt") diff --git a/idea/tests/org/jetbrains/kotlin/checkers/KotlinHighlightingPassTestGenerated.java b/idea/tests/org/jetbrains/kotlin/checkers/KotlinHighlightingPassTestGenerated.java index 94c1d65a404..fd8c7c4397c 100644 --- a/idea/tests/org/jetbrains/kotlin/checkers/KotlinHighlightingPassTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/checkers/KotlinHighlightingPassTestGenerated.java @@ -33,7 +33,7 @@ public class KotlinHighlightingPassTestGenerated extends AbstractKotlinHighlight } public void testAllFilesPresentInChecker() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/checker"), Pattern.compile("^(.+)\\.kt$"), null, false); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/checker"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), false); } @TestMetadata("AnnotationOnFile.kt") @@ -376,7 +376,7 @@ public class KotlinHighlightingPassTestGenerated extends AbstractKotlinHighlight } public void testAllFilesPresentInRegression() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/checker/regression"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/checker/regression"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); } @TestMetadata("AmbiguityOnLazyTypeComputation.kt") @@ -619,7 +619,7 @@ public class KotlinHighlightingPassTestGenerated extends AbstractKotlinHighlight } public void testAllFilesPresentInRecovery() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/checker/recovery"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/checker/recovery"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); } @TestMetadata("namelessMembers.kt") @@ -647,7 +647,7 @@ public class KotlinHighlightingPassTestGenerated extends AbstractKotlinHighlight } public void testAllFilesPresentInRendering() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/checker/rendering"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/checker/rendering"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); } @TestMetadata("TypeInferenceError.kt") @@ -665,7 +665,7 @@ public class KotlinHighlightingPassTestGenerated extends AbstractKotlinHighlight } public void testAllFilesPresentInScripts() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/checker/scripts"), Pattern.compile("^(.+)\\.kts$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/checker/scripts"), Pattern.compile("^(.+)\\.kts$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); } @TestMetadata("if.kts") @@ -698,7 +698,7 @@ public class KotlinHighlightingPassTestGenerated extends AbstractKotlinHighlight } public void testAllFilesPresentInDuplicateJvmSignature() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/checker/duplicateJvmSignature"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/checker/duplicateJvmSignature"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); } @TestMetadata("idea/testData/checker/duplicateJvmSignature/fields") @@ -710,7 +710,7 @@ public class KotlinHighlightingPassTestGenerated extends AbstractKotlinHighlight } public void testAllFilesPresentInFields() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/checker/duplicateJvmSignature/fields"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/checker/duplicateJvmSignature/fields"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); } @TestMetadata("classObjectCopiedFieldObject.kt") @@ -728,7 +728,7 @@ public class KotlinHighlightingPassTestGenerated extends AbstractKotlinHighlight } public void testAllFilesPresentInFunctionAndProperty() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/checker/duplicateJvmSignature/functionAndProperty"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/checker/duplicateJvmSignature/functionAndProperty"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); } @TestMetadata("ambiguous.kt") @@ -791,7 +791,7 @@ public class KotlinHighlightingPassTestGenerated extends AbstractKotlinHighlight } public void testAllFilesPresentInTraitImpl() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/checker/duplicateJvmSignature/traitImpl"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/checker/duplicateJvmSignature/traitImpl"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); } @TestMetadata("twoTraits.kt") @@ -810,7 +810,7 @@ public class KotlinHighlightingPassTestGenerated extends AbstractKotlinHighlight } public void testAllFilesPresentInInfos() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/checker/infos"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/checker/infos"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); } @TestMetadata("CapturedConstructorParameter.kt") @@ -903,7 +903,7 @@ public class KotlinHighlightingPassTestGenerated extends AbstractKotlinHighlight } public void testAllFilesPresentInDiagnosticsMessage() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/checker/diagnosticsMessage"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/checker/diagnosticsMessage"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); } @TestMetadata("fullPackageFQNameOnVisiblityError.kt")