From 24f1f1221e1bd7c268e7871df3549a3a47bfb8da Mon Sep 17 00:00:00 2001 From: vldf Date: Mon, 1 Mar 2021 19:29:59 +0300 Subject: [PATCH] Introduce FirInitializerTypeMismatchChecker --- .../testData/resolve/treeSet.kt | 2 +- .../InitializerTypeMismatch | 31 ++++++++ .../InitializerTypeMismatch.fir.txt | 69 ++++++++++++++++++ .../functionType.fir.txt | 43 +++++++++++ .../functionType.kt | 39 ++++++++++ .../testData/resolveWithStdlib/functionX.kt | 2 +- .../runners/FirDiagnosticTestGenerated.java | 26 +++++++ ...DiagnosticsWithLightTreeTestGenerated.java | 28 ++++++++ .../generator/diagnostics/DiagnosticData.kt | 3 +- .../diagnostics/FirDiagnosticsList.kt | 4 ++ .../fir/analysis/diagnostics/FirErrors.kt | 1 + .../FirInitializerTypeMismatchChecker.kt | 72 +++++++++++++++++++ .../diagnostics/FirDefaultErrorMessages.kt | 2 + .../LightTreePositioningStrategies.kt | 14 ++++ .../SourceElementPositioningStrategies.kt | 5 ++ .../fir/checkers/CommonDeclarationCheckers.kt | 3 +- .../diagnostics/PositioningStrategies.kt | 20 ++++++ .../testData/diagnostics/tests/Basic.fir.kt | 2 +- .../tests/FunctionReturnTypes.fir.kt | 20 +++--- .../diagnostics/tests/PackageQualified.fir.kt | 2 +- .../tests/QualifiedExpressions.fir.kt | 2 +- .../SafeCallNonNullReceiverReturnNull.fir.kt | 2 +- .../diagnostics/tests/Variance.fir.kt | 4 +- ...annotationOnParameterInFunctionType.fir.kt | 2 +- .../argumentAndReturnExpectedType.fir.kt | 2 +- .../genericFunctionsWithNullableTypes.fir.kt | 4 +- ...ionGenericCallableWithNullableTypes.fir.kt | 6 +- .../classLiteral/classLiteralType.fir.kt | 4 +- .../kt770.kt351.kt735_StatementType.fir.kt | 4 +- .../specialConstructsAndPlatformTypes.fir.kt | 10 +-- .../tests/cyclicHierarchy/kt303.fir.kt | 2 +- .../ScalaLikeNamedFun.fir.kt | 16 ++--- .../checkDeparenthesizedType.fir.kt | 6 +- .../binaryMinusIndependentExpType.fir.kt | 30 ++++---- .../diagnostics/tests/evaluate/integer.fir.kt | 10 +-- .../tests/evaluate/parentesized.fir.kt | 10 +-- .../unaryMinusIndependentExpType.fir.kt | 30 ++++---- .../functionAsExpression/FunctionType.fir.kt | 6 +- .../InferenceParametersTypes.fir.kt | 2 +- .../MissingParameterTypes.fir.kt | 8 +-- ...ntOperationInLambdaWithExpectedType.fir.kt | 6 +- .../missedTypeMismatch.fir.kt | 24 +++---- .../IfWithoutElseWithExplicitType.fir.kt | 8 +-- .../generics/nullability/nullToGeneric.fir.kt | 4 +- .../generics/projectionsScope/kt7296.fir.kt | 2 +- .../typeMismatchInLambda.fir.kt | 2 +- .../generics/suppressVarianceConflict.fir.kt | 4 +- .../imports/InaccessiblePrivateClass.fir.kt | 2 +- .../captureForNullableTypes.fir.kt | 4 +- .../expectedTypeMismatchWithInVariance.fir.kt | 2 +- .../coercionToUnit/noCoercion.fir.kt | 4 +- .../postponedArgumentsAnalysis/basic.fir.kt | 4 +- .../tests/inference/constraints/kt6320.fir.kt | 2 +- .../inference/dependantOnVariance.fir.kt | 14 ++-- .../diagnostics/tests/inference/kt1293.fir.kt | 2 +- ...alInitializerWithAnonymousFunctions.fir.kt | 4 +- .../tests/inference/regressions/kt1127.fir.kt | 2 +- .../tests/inference/regressions/kt2883.fir.kt | 4 +- .../tests/inference/tooEagerSmartcast.fir.kt | 2 +- .../typeInferenceExpectedTypeMismatch.fir.kt | 4 +- .../useBoundsIfUnknownParameters.fir.kt | 2 +- ...nceToSamFunctionAgainstExpectedType.fir.kt | 2 +- .../tests/library/Collections.fir.kt | 16 ++--- .../sameClassNameDifferentPackages.fir.kt | 2 +- .../AssertNotNull.fir.kt | 2 +- .../inferenceFlexibleTToNullable.fir.kt | 4 +- .../numbers/doublesInSimpleConstraints.fir.kt | 2 +- .../numbers/numbersInSimpleConstraints.fir.kt | 6 +- .../diagnostics/tests/objects/kt5527.fir.kt | 6 +- .../platformTypes/methodCall/singleton.fir.kt | 2 +- .../rawTypes/rawTypeInUpperBound.fir.kt | 2 +- .../TypeMismatchOnUnaryOperations.fir.kt | 14 ++-- .../tests/regressions/kt235.fir.kt | 24 +++---- .../tests/regressions/kt2768.fir.kt | 4 +- .../tests/regressions/kt2956.fir.kt | 2 +- .../tests/regressions/kt30245.fir.kt | 4 +- .../tests/regressions/kt312.fir.kt | 2 +- .../overloadConflicts/originalExamples.fir.kt | 2 +- .../scopes/inheritance/methodsPriority.fir.kt | 2 +- .../inheritFromContainingClass_after.fir.kt | 4 +- .../inheritFromContainingClass_before.fir.kt | 4 +- .../inheritance/statics/localVsStatic.fir.kt | 2 +- ...vePropertyInitializerWithoutPrimary.fir.kt | 2 +- .../inference/intersectionTypes.fir.kt | 2 +- .../smartCasts/safecalls/anotherVal.fir.kt | 2 +- .../findClosestCorrespondingSupertype.fir.kt | 2 +- .../tests/typealias/privateInFile.fir.kt | 8 +-- ...oUnsignedConversionWithExpectedType.fir.kt | 2 +- .../explicitUnsignedLongTypeCheck.fir.kt | 4 +- ...nsignedLiteralsOverflowSignedBorder.fir.kt | 2 +- .../unsignedLiteralsTypeCheck.fir.kt | 4 +- .../diagnostics/tests/when/kt9929.fir.kt | 4 +- .../diagnostics/tests/when/kt9972.fir.kt | 4 +- .../inference/suspendCallsWithErrors.fir.kt | 4 +- .../onlyInputTypesAndLowPriority.fir.kt | 2 +- .../purelyImplementedCollection/maps.fir.kt | 12 ++-- .../mapsWithNullableKey.fir.kt | 14 ++-- .../mapsWithNullableValues.fir.kt | 16 ++--- .../ea70485_functionTypeInheritor.fir.kt | 2 +- .../testsWithStdLib/tryCatch/assignTry.fir.kt | 4 +- .../p-1/pos/1.3.fir.kt | 3 +- .../introduction-1/p-6/neg/2.1.fir.kt | 14 ++-- .../diagnostics/notLinked/dfa/neg/13.fir.kt | 2 +- .../diagnostics/notLinked/dfa/neg/30.fir.kt | 8 +-- .../diagnostics/notLinked/dfa/pos/72.fir.kt | 2 +- .../diagnostics/KtFirDataClassConverters.kt | 8 +++ .../api/fir/diagnostics/KtFirDiagnostics.kt | 6 ++ .../fir/diagnostics/KtFirDiagnosticsImpl.kt | 9 +++ .../checker/QualifiedExpressions.fir.kt | 2 +- idea/testData/checker/UnreachableCode.fir.kt | 4 +- idea/testData/checker/Variance.fir.kt | 4 +- idea/testData/checker/regression/kt303.fir.kt | 2 +- .../checker/trivialHierarchyLoop.fir.kt | 2 +- .../propertyNullabilityChanged/fir-build.log | 18 ----- 114 files changed, 647 insertions(+), 285 deletions(-) create mode 100644 compiler/fir/analysis-tests/testData/resolveWithStdlib/diagnostics/initializerTypeMismatchChecker/InitializerTypeMismatch create mode 100644 compiler/fir/analysis-tests/testData/resolveWithStdlib/diagnostics/initializerTypeMismatchChecker/InitializerTypeMismatch.fir.txt create mode 100644 compiler/fir/analysis-tests/testData/resolveWithStdlib/diagnostics/initializerTypeMismatchChecker/functionType.fir.txt create mode 100644 compiler/fir/analysis-tests/testData/resolveWithStdlib/diagnostics/initializerTypeMismatchChecker/functionType.kt create mode 100644 compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirInitializerTypeMismatchChecker.kt delete mode 100644 jps-plugin/testData/incremental/classHierarchyAffected/propertyNullabilityChanged/fir-build.log diff --git a/compiler/fir/analysis-tests/testData/resolve/treeSet.kt b/compiler/fir/analysis-tests/testData/resolve/treeSet.kt index 695882645ec..6529230f09b 100644 --- a/compiler/fir/analysis-tests/testData/resolve/treeSet.kt +++ b/compiler/fir/analysis-tests/testData/resolve/treeSet.kt @@ -1,3 +1,3 @@ import java.util.* -val x: SortedSet = TreeSet() +val x: SortedSet = TreeSet() diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/diagnostics/initializerTypeMismatchChecker/InitializerTypeMismatch b/compiler/fir/analysis-tests/testData/resolveWithStdlib/diagnostics/initializerTypeMismatchChecker/InitializerTypeMismatch new file mode 100644 index 00000000000..cf2809f5d37 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/diagnostics/initializerTypeMismatchChecker/InitializerTypeMismatch @@ -0,0 +1,31 @@ +// FULL_JDK + +import java.util.* + +open class A +open class B : A() +class C : B() + +fun foo() { + // InitializerTypeMismatchChecker doesn't report here due this is work for another checker + val (a: Int, b: Int) = bar() +} + +fun bar(): Pair = null to null + +class Classes { + val p: Int = 1 // ok + val incorrect: C = B() + val correct: A = C() +} + +class Expressions { + val n: Number = 1 // ok + val s: Number = "" // not ok + val s2: Number = "" + "expression" // not ok +} + +class Generics { + val n: SortedSet = TreeSet() // ok + val b: SortedSet = TreeSet() // ok +} diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/diagnostics/initializerTypeMismatchChecker/InitializerTypeMismatch.fir.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/diagnostics/initializerTypeMismatchChecker/InitializerTypeMismatch.fir.txt new file mode 100644 index 00000000000..3c333340e11 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/diagnostics/initializerTypeMismatchChecker/InitializerTypeMismatch.fir.txt @@ -0,0 +1,69 @@ +FILE: InitializerTypeMismatch.kt + public open class A : R|kotlin/Any| { + public constructor(): R|A| { + super() + } + + } + public open class B : R|A| { + public constructor(): R|B| { + super() + } + + } + public final class C : R|B| { + public constructor(): R|C| { + super() + } + + } + public final fun foo(): R|kotlin/Unit| { + lval : R|kotlin/Pair| = R|/bar|() + lval a: R|kotlin/Int| = R|/|.R|SubstitutionOverride|() + lval b: R|kotlin/Int| = R|/|.R|SubstitutionOverride|() + } + public final fun bar(): R|kotlin/Pair| { + ^bar Null(null).R|kotlin/to|(Null(null)) + } + public final class Classes : R|kotlin/Any| { + public constructor(): R|Classes| { + super() + } + + public final val p: R|kotlin/Int| = Int(1) + public get(): R|kotlin/Int| + + public final val incorrect: R|C| = R|/B.B|() + public get(): R|C| + + public final val correct: R|A| = R|/C.C|() + public get(): R|A| + + } + public final class Expressions : R|kotlin/Any| { + public constructor(): R|Expressions| { + super() + } + + public final val n: R|kotlin/Number| = Int(1) + public get(): R|kotlin/Number| + + public final val s: R|kotlin/Number| = String() + public get(): R|kotlin/Number| + + public final val s2: R|kotlin/Number| = String().R|kotlin/String.plus|(String(expression)) + public get(): R|kotlin/Number| + + } + public final class Generics : R|kotlin/Any| { + public constructor(): R|Generics| { + super() + } + + public final val n: R|java/util/SortedSet| = R|java/util/TreeSet.TreeSet||>() + public get(): R|java/util/SortedSet| + + public final val b: R|java/util/SortedSet| = R|java/util/TreeSet.TreeSet||>() + public get(): R|java/util/SortedSet| + + } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/diagnostics/initializerTypeMismatchChecker/functionType.fir.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/diagnostics/initializerTypeMismatchChecker/functionType.fir.txt new file mode 100644 index 00000000000..1e20796d8fa --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/diagnostics/initializerTypeMismatchChecker/functionType.fir.txt @@ -0,0 +1,43 @@ +FILE: TestCase1.kt + public final class Case : R|kotlin/Any| { + public constructor(): R|testsCase1/Case| { + super() + } + + public final fun case(v: R|testsCase1/V|): R|kotlin/Unit| { + lval va: R|() -> kotlin/String| = Q|testsCase1/V|::R|testsCase1/a| + lval vb: R|() -> kotlin/String| = Q|testsCase1/V|::R|testsCase1/V.Companion.b| + lval va1: R|() -> kotlin/String| = R|/v|::R|testsCase1/a| + lval vb1: R|() -> kotlin/String| = Q|testsCase1/V|::R|testsCase1/V.Companion.b| + } + + public final val R|testsCase1/V.Companion|.b: R|kotlin/String| + public get(): R|kotlin/String| { + ^ String(1) + } + + } + public final val R|testsCase1/V|.a: R|kotlin/String| + public get(): R|kotlin/String| { + ^ String(1) + } + public final val R|testsCase1/V.Companion|.a: R|kotlin/String| + public get(): R|kotlin/String| { + ^ String(1) + } + public final class V : R|kotlin/Any| { + public constructor(): R|testsCase1/V| { + super() + } + + public final companion object Companion : R|kotlin/Any| { + private constructor(): R|testsCase1/V.Companion| { + super() + } + + public final const val b: R|kotlin/String| = String(1) + public get(): R|kotlin/String| + + } + + } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/diagnostics/initializerTypeMismatchChecker/functionType.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/diagnostics/initializerTypeMismatchChecker/functionType.kt new file mode 100644 index 00000000000..bdc2368580d --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/diagnostics/initializerTypeMismatchChecker/functionType.kt @@ -0,0 +1,39 @@ +// FULL_JDK +// !DIAGNOSTICS: -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_EXPRESSION +// SKIP_TXT + + + +// FILE: TestCase1.kt +// TESTCASE NUMBER: 1 +package testsCase1 + +class Case() { + fun case(v: V) { + // InitializerTypeMismatchChecker bug + val va: () -> String = (V)::a + + val vb: () -> String = (V)::b + + val va1: () -> String = v::a + val vb1: () -> String = (V)::b + + } + + val V.Companion.b: String // (3) + get() = "1" + +} + +val V.a: String + get() = "1" + +val V.Companion.a: String + get() = "1" + + +class V { + companion object { + const val b: String = "1" + } +} diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/functionX.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/functionX.kt index 5475c35c545..ea37c0eabc7 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/functionX.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/functionX.kt @@ -1,6 +1,6 @@ import kotlin.jvm.functions.Function0 -val x: Function0 = { 42 } +val x: Function0 = { 42 } val y: Function1 = { it } diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java index ba8244871df..412c427ff92 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java @@ -4772,6 +4772,32 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { } } + @Nested + @TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/diagnostics") + @TestDataPath("$PROJECT_ROOT") + public class Diagnostics { + @Test + public void testAllFilesPresentInDiagnostics() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolveWithStdlib/diagnostics"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @Nested + @TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/diagnostics/initializerTypeMismatchChecker") + @TestDataPath("$PROJECT_ROOT") + public class InitializerTypeMismatchChecker { + @Test + public void testAllFilesPresentInInitializerTypeMismatchChecker() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolveWithStdlib/diagnostics/initializerTypeMismatchChecker"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @Test + @TestMetadata("functionType.kt") + public void testFunctionType() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/diagnostics/initializerTypeMismatchChecker/functionType.kt"); + } + } + } + @Nested @TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/inference") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java index 8ef5438e748..efbac27d9e4 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java @@ -4841,6 +4841,34 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos } } + @Nested + @TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/diagnostics") + @TestDataPath("$PROJECT_ROOT") + @Execution(ExecutionMode.SAME_THREAD) + public class Diagnostics { + @Test + public void testAllFilesPresentInDiagnostics() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolveWithStdlib/diagnostics"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @Nested + @TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/diagnostics/initializerTypeMismatchChecker") + @TestDataPath("$PROJECT_ROOT") + @Execution(ExecutionMode.SAME_THREAD) + public class InitializerTypeMismatchChecker { + @Test + public void testAllFilesPresentInInitializerTypeMismatchChecker() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolveWithStdlib/diagnostics/initializerTypeMismatchChecker"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @Test + @TestMetadata("functionType.kt") + public void testFunctionType() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/diagnostics/initializerTypeMismatchChecker/functionType.kt"); + } + } + } + @Nested @TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/inference") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/DiagnosticData.kt b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/DiagnosticData.kt index ff80304e680..aabaafccb25 100644 --- a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/DiagnosticData.kt +++ b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/DiagnosticData.kt @@ -56,9 +56,10 @@ enum class PositioningStrategy(private val strategy: String? = null) { VALUE_ARGUMENTS, SUPERTYPES_LIST, RETURN_WITH_LABEL, + ASSIGNMENT_VALUE, INT_LITERAL_OUT_OF_RANGE, FLOAT_LITERAL_OUT_OF_RANGE, - LONG_LITERAL_SUFFIX + LONG_LITERAL_SUFFIX, ; diff --git a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt index 0575d5d1ec7..837a57352d5 100644 --- a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt +++ b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt @@ -495,6 +495,10 @@ object DIAGNOSTICS_LIST : DiagnosticList() { parameter("expectedType") parameter("actualType") } + val INITIALIZER_TYPE_MISMATCH by error(PositioningStrategy.ASSIGNMENT_VALUE) { + parameter("expected") + parameter("actual") + } } val MPP_PROJECTS by object : DiagnosticGroup("Multi-platform projects") { diff --git a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt index b47dd83c477..15a0d5e33eb 100644 --- a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt +++ b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt @@ -312,6 +312,7 @@ object FirErrors { val CONST_VAL_WITH_GETTER by error0() val CONST_VAL_WITH_DELEGATE by error0() val WRONG_SETTER_PARAMETER_TYPE by error2() + val INITIALIZER_TYPE_MISMATCH by error2(SourceElementPositioningStrategies.ASSIGNMENT_VALUE) // Multi-platform projects val EXPECTED_DECLARATION_WITH_BODY by error0(SourceElementPositioningStrategies.DECLARATION_SIGNATURE) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirInitializerTypeMismatchChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirInitializerTypeMismatchChecker.kt new file mode 100644 index 00000000000..73b5a1ccee0 --- /dev/null +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirInitializerTypeMismatchChecker.kt @@ -0,0 +1,72 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.analysis.checkers.declaration + +import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext +import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INITIALIZER_TYPE_MISMATCH +import org.jetbrains.kotlin.fir.declarations.FirProperty +import org.jetbrains.kotlin.fir.expressions.FirComponentCall +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.resolve.inference.isFunctionalType +import org.jetbrains.kotlin.fir.typeContext +import org.jetbrains.kotlin.fir.types.* +import org.jetbrains.kotlin.types.AbstractTypeChecker + +object FirInitializerTypeMismatchChecker : FirPropertyChecker() { + override fun check(declaration: FirProperty, context: CheckerContext, reporter: DiagnosticReporter) { + val initializer = declaration.initializer ?: return + if (declaration.isDestructuringDeclaration) return + if (initializer.isComponent) return + val propertyType = declaration.returnTypeRef.coneTypeSafe() ?: return + val expressionType = initializer.typeRef.coneTypeSafe() ?: return + val typeContext = context.session.typeContext + + // hack: if property's type is (args) -> Unit, and lambda returns non-Unit value, the type of the lambda + // will be non-unit, but it's OK + if (propertyType.isFunctionalType(context.session)) { + // getting property's expected return type + val expectedType = propertyType.typeArguments.lastOrNull() + if ((expectedType as? ConeClassLikeType)?.isUnit == true) { + // dropping the return type (getting only the lambda args) + val expectedArgs = propertyType.typeArguments.dropLast(1) + val actualArgs = expressionType.typeArguments.dropLast(1) + if (compareTypesList(actualArgs, expectedArgs, typeContext)) { + return + } + } + } + + if (!AbstractTypeChecker.isSubtypeOf(typeContext, expressionType, propertyType)) { + val source = declaration.source ?: return + reporter.report(INITIALIZER_TYPE_MISMATCH.on(source, propertyType, expressionType), context) + } + } + + private val FirProperty.isDestructuringDeclaration + get() = name.asString() == "" + private val FirExpression.isComponent + get() = this is FirComponentCall + + private fun compareTypesList( + expressionTypes: List, + propertyTypes: List, + context: ConeInferenceContext + ): Boolean { + if (expressionTypes.size != propertyTypes.size) return false + + for (i in expressionTypes.indices) { + val expressionType = expressionTypes[i].type ?: return false + val propertyType = propertyTypes[i].type ?: return false + + if (!AbstractTypeChecker.isSubtypeOf(context.session.typeContext, expressionType, propertyType)) { + return false + } + } + + return true + } +} \ No newline at end of file diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt index 747b0efe7ba..e4c7fb88aa8 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt @@ -108,6 +108,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INAPPLICABLE_LATE import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INCOMPATIBLE_MODIFIERS import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INFERENCE_ERROR import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INITIALIZER_REQUIRED_FOR_DESTRUCTURING_DECLARATION +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INITIALIZER_TYPE_MISMATCH import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INLINE_CLASS_CANNOT_BE_RECURSIVE import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INLINE_CLASS_CANNOT_EXTEND_CLASSES import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INLINE_CLASS_CANNOT_IMPLEMENT_INTERFACE_BY_DELEGATION @@ -687,6 +688,7 @@ class FirDefaultErrorMessages : DefaultErrorMessages.Extension { RENDER_TYPE, RENDER_TYPE ) + map.put(INITIALIZER_TYPE_MISMATCH, "Initializer type mismatch: expected {0}, actual {1}", RENDER_TYPE, RENDER_TYPE) // Multi-platform projects map.put(EXPECTED_DECLARATION_WITH_BODY, "Expected declaration must not have a body") diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategies.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategies.kt index 8bcd4198bdc..18610c9cf75 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategies.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategies.kt @@ -8,11 +8,13 @@ package org.jetbrains.kotlin.fir.analysis.diagnostics import com.intellij.lang.LighterASTNode import com.intellij.openapi.util.Ref import com.intellij.openapi.util.TextRange +import com.intellij.psi.impl.source.tree.ElementType import com.intellij.psi.tree.IElementType import com.intellij.psi.tree.TokenSet import com.intellij.util.diff.FlyweightCapableTreeStructure import org.jetbrains.kotlin.KtNodeTypes import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.analysis.checkers.getChildren import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.lexer.KtTokens.MODALITY_MODIFIERS import org.jetbrains.kotlin.lexer.KtTokens.VISIBILITY_MODIFIERS @@ -240,6 +242,18 @@ object LightTreePositioningStrategies { } } + val ASSIGNMENT_VALUE: LightTreePositioningStrategy = object : LightTreePositioningStrategy() { + override fun mark( + node: LighterASTNode, + startOffset: Int, + endOffset: Int, + tree: FlyweightCapableTreeStructure + ): List { + val value = tree.lastChild(node) ?: node + return markElement(value, startOffset, endOffset, tree, node) + } + } + private val LighterASTNode.isDeclaration: Boolean get() = when (tokenType) { diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/SourceElementPositioningStrategies.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/SourceElementPositioningStrategies.kt index 958e0d29fbd..5e35811c92a 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/SourceElementPositioningStrategies.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/SourceElementPositioningStrategies.kt @@ -178,6 +178,11 @@ object SourceElementPositioningStrategies { PositioningStrategies.RETURN_WITH_LABEL ) + val ASSIGNMENT_VALUE = SourceElementPositioningStrategy( + LightTreePositioningStrategies.ASSIGNMENT_VALUE, + PositioningStrategies.ASSIGNMENT_VALUE + ) + val LONG_LITERAL_SUFFIX = SourceElementPositioningStrategy( LightTreePositioningStrategies.LONG_LITERAL_SUFFIX, PositioningStrategies.LONG_LITERAL_SUFFIX diff --git a/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonDeclarationCheckers.kt b/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonDeclarationCheckers.kt index 75d3953cbbd..ff763d26c1f 100644 --- a/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonDeclarationCheckers.kt +++ b/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonDeclarationCheckers.kt @@ -41,7 +41,8 @@ object CommonDeclarationCheckers : DeclarationCheckers() { FirInapplicableLateinitChecker, FirDestructuringDeclarationChecker, FirConstPropertyChecker, - FirPropertyAccessorChecker + FirPropertyAccessorChecker, + FirInitializerTypeMismatchChecker ) override val classCheckers: Set = setOf( diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/PositioningStrategies.kt b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/PositioningStrategies.kt index 820088df4f5..f8d059c0915 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/PositioningStrategies.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/PositioningStrategies.kt @@ -780,6 +780,26 @@ object PositioningStrategies { val REFERENCE_BY_QUALIFIED: PositioningStrategy = FindReferencePositioningStrategy(false) val REFERENCED_NAME_BY_QUALIFIED: PositioningStrategy = FindReferencePositioningStrategy(true) + val ASSIGNMENT_VALUE: PositioningStrategy = object : PositioningStrategy() { + override fun mark(element: PsiElement): List { + return if (element is KtProperty) { + mark(element.initializer ?: element) + } else { + super.mark(element) + } + } + } + + val RETURN_EXPRESSION: PositioningStrategy = object : PositioningStrategy() { + override fun mark(element: PsiElement): List { + return if (element is KtReturnExpression) { + markElement(element.returnedExpression ?: element) + } else { + markElement(element) + } + } + } + /** * @param locateReferencedName whether to remove any nested parentheses while locating the reference element. This is useful for * diagnostics on super and unresolved references. For example, with the following, only the part inside the parentheses should be diff --git a/compiler/testData/diagnostics/tests/Basic.fir.kt b/compiler/testData/diagnostics/tests/Basic.fir.kt index 6f7f519ef99..d1734fa60bb 100644 --- a/compiler/testData/diagnostics/tests/Basic.fir.kt +++ b/compiler/testData/diagnostics/tests/Basic.fir.kt @@ -10,7 +10,7 @@ fun test() : Int { } class A() { - val x : Int = foo1(xx) + val x : Int = foo1(xx) } fun foo1() {} diff --git a/compiler/testData/diagnostics/tests/FunctionReturnTypes.fir.kt b/compiler/testData/diagnostics/tests/FunctionReturnTypes.fir.kt index ed8c4e2930c..9005fd18d90 100644 --- a/compiler/testData/diagnostics/tests/FunctionReturnTypes.fir.kt +++ b/compiler/testData/diagnostics/tests/FunctionReturnTypes.fir.kt @@ -171,31 +171,31 @@ class B() { } fun testFunctionLiterals() { - val endsWithVarDeclaration : () -> Boolean = { + val endsWithVarDeclaration : () -> Boolean = { val x = 2 - } + } - val endsWithAssignment: () -> Int = { + val endsWithAssignment: () -> Int = { var x = 1 x = 333 - } + } - val endsWithReAssignment: () -> Int = { + val endsWithReAssignment: () -> Int = { var x = 1 x += 333 - } + } - val endsWithFunDeclaration : () -> String = { + val endsWithFunDeclaration : () -> String = { var x = 1 x = 333 fun meow() : Unit {} - } + } - val endsWithObjectDeclaration : () -> Int = { + val endsWithObjectDeclaration : () -> Int = { var x = 1 x = 333 object A {} - } + } val expectedUnitReturnType1: () -> Unit = { val x = 1 diff --git a/compiler/testData/diagnostics/tests/PackageQualified.fir.kt b/compiler/testData/diagnostics/tests/PackageQualified.fir.kt index fd6b7ce34c8..7c2d34bd022 100644 --- a/compiler/testData/diagnostics/tests/PackageQualified.fir.kt +++ b/compiler/testData/diagnostics/tests/PackageQualified.fir.kt @@ -20,7 +20,7 @@ abstract class Foo() { package foobar.a import java.util.* - val b : List? = a + val b : List? = a val b1 : util.List? = a // FILE: d.kt diff --git a/compiler/testData/diagnostics/tests/QualifiedExpressions.fir.kt b/compiler/testData/diagnostics/tests/QualifiedExpressions.fir.kt index d34cd8ec1cc..78e08ab5865 100644 --- a/compiler/testData/diagnostics/tests/QualifiedExpressions.fir.kt +++ b/compiler/testData/diagnostics/tests/QualifiedExpressions.fir.kt @@ -2,7 +2,7 @@ package qualified_expressions fun test(s: IntRange?) { - val a: Int = s?.start + val a: Int = s?.start val b: Int? = s?.start val c: Int = s?.start ?: -11 val d: Int = s?.start ?: "empty" diff --git a/compiler/testData/diagnostics/tests/SafeCallNonNullReceiverReturnNull.fir.kt b/compiler/testData/diagnostics/tests/SafeCallNonNullReceiverReturnNull.fir.kt index d48f7c25ee5..e1ef23c55be 100644 --- a/compiler/testData/diagnostics/tests/SafeCallNonNullReceiverReturnNull.fir.kt +++ b/compiler/testData/diagnostics/tests/SafeCallNonNullReceiverReturnNull.fir.kt @@ -3,5 +3,5 @@ fun Int.gg() = null fun ff() { val a: Int = 1 - val b: Int = a?.gg() + val b: Int = a?.gg() } diff --git a/compiler/testData/diagnostics/tests/Variance.fir.kt b/compiler/testData/diagnostics/tests/Variance.fir.kt index 28aae719b0e..8178589aa1f 100644 --- a/compiler/testData/diagnostics/tests/Variance.fir.kt +++ b/compiler/testData/diagnostics/tests/Variance.fir.kt @@ -8,13 +8,13 @@ abstract class Producer {} abstract class Usual {} fun foo(c: Consumer, p: Producer, u: Usual) { - val c1: Consumer = c + val c1: Consumer = c val c2: Consumer = c1 val p1: Producer = p val p2: Producer = p1 - val u1: Usual = u + val u1: Usual = u val u2: Usual = u1 } diff --git a/compiler/testData/diagnostics/tests/annotations/annotationOnParameterInFunctionType.fir.kt b/compiler/testData/diagnostics/tests/annotations/annotationOnParameterInFunctionType.fir.kt index 63606691a1c..ff0271efe37 100644 --- a/compiler/testData/diagnostics/tests/annotations/annotationOnParameterInFunctionType.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/annotationOnParameterInFunctionType.fir.kt @@ -24,6 +24,6 @@ class A : (@Ann Int)->Unit { @Target(AnnotationTarget.TYPE) annotation class TypeAnn -val onType: (@TypeAnn A).(@Ann a: @TypeAnn A, @TypeAnn A)->@TypeAnn A? = { null } +val onType: (@TypeAnn A).(@Ann a: @TypeAnn A, @TypeAnn A)->@TypeAnn A? = { null } fun (@TypeAnn A).extFun(@Ann a: @TypeAnn A): @TypeAnn A? = null \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/callableReference/generic/argumentAndReturnExpectedType.fir.kt b/compiler/testData/diagnostics/tests/callableReference/generic/argumentAndReturnExpectedType.fir.kt index f3ef65d93c3..5bc8ad3e762 100644 --- a/compiler/testData/diagnostics/tests/callableReference/generic/argumentAndReturnExpectedType.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/generic/argumentAndReturnExpectedType.fir.kt @@ -18,7 +18,7 @@ fun test1() { bar("", 1, ::fooTakeString).checkType { _>() } bar("", "", ::fooReturnInt).checkType { _>() } - val x: String = bar("", "", ::fooReturnInt) + val x: String = bar("", "", ::fooReturnInt) baz(Int::toString, ::foo).checkType { _>() } } diff --git a/compiler/testData/diagnostics/tests/callableReference/generic/genericFunctionsWithNullableTypes.fir.kt b/compiler/testData/diagnostics/tests/callableReference/generic/genericFunctionsWithNullableTypes.fir.kt index f8504fe88f0..6ec37379837 100644 --- a/compiler/testData/diagnostics/tests/callableReference/generic/genericFunctionsWithNullableTypes.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/generic/genericFunctionsWithNullableTypes.fir.kt @@ -30,8 +30,8 @@ fun test(x: T) { baz(null, null, ::foo) val s3: Pair = bar(null, null, ::foo) - val s4: Pair = bar(null, null, ::foo) + val s4: Pair = bar(null, null, ::foo) - val s5: Pair = bar(1, "", ::foo) + val s5: Pair = bar(1, "", ::foo) val (a1: Int, b1: String) = bar(1, "", ::foo) } diff --git a/compiler/testData/diagnostics/tests/callableReference/generic/resolutionGenericCallableWithNullableTypes.fir.kt b/compiler/testData/diagnostics/tests/callableReference/generic/resolutionGenericCallableWithNullableTypes.fir.kt index da379751848..68c5db2e4c6 100644 --- a/compiler/testData/diagnostics/tests/callableReference/generic/resolutionGenericCallableWithNullableTypes.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/generic/resolutionGenericCallableWithNullableTypes.fir.kt @@ -17,7 +17,7 @@ fun test1() { baz(::foo).checkType { _() } baz(::foo).checkType { _() } - val b1: Int = baz(::foo) - val b2: String = baz(::foo) - val b3: Boolean = baz(::foo) + val b1: Int = baz(::foo) + val b2: String = baz(::foo) + val b3: Boolean = baz(::foo) } diff --git a/compiler/testData/diagnostics/tests/classLiteral/classLiteralType.fir.kt b/compiler/testData/diagnostics/tests/classLiteral/classLiteralType.fir.kt index c52949ae609..9463c6ddcdb 100644 --- a/compiler/testData/diagnostics/tests/classLiteral/classLiteralType.fir.kt +++ b/compiler/testData/diagnostics/tests/classLiteral/classLiteralType.fir.kt @@ -8,8 +8,8 @@ val arrayOfString: Array = null!! val a1 : KClass<*> = A::class val a2 : KClass = A::class -val a3 : KClass = A::class -val a4 : B = A::class +val a3 : KClass = A::class +val a4 : B = A::class val a5 : KClass> = listOfString::class val a6 : KClass> = arrayOfString::class diff --git a/compiler/testData/diagnostics/tests/controlStructures/kt770.kt351.kt735_StatementType.fir.kt b/compiler/testData/diagnostics/tests/controlStructures/kt770.kt351.kt735_StatementType.fir.kt index 87589398a2f..b5a6ce953dc 100644 --- a/compiler/testData/diagnostics/tests/controlStructures/kt770.kt351.kt735_StatementType.fir.kt +++ b/compiler/testData/diagnostics/tests/controlStructures/kt770.kt351.kt735_StatementType.fir.kt @@ -27,7 +27,7 @@ fun foo() { z = 34 } } - val f: ()-> Int = r + val f: ()-> Int = r val g: ()-> Any = r } @@ -80,7 +80,7 @@ fun testCoercionToUnit() { 45 } } - val f : () -> String = checkType + val f : () -> String = checkType } fun doSmth(i: Int) {} diff --git a/compiler/testData/diagnostics/tests/controlStructures/specialConstructsAndPlatformTypes.fir.kt b/compiler/testData/diagnostics/tests/controlStructures/specialConstructsAndPlatformTypes.fir.kt index 133ac6dee04..567e0756a26 100644 --- a/compiler/testData/diagnostics/tests/controlStructures/specialConstructsAndPlatformTypes.fir.kt +++ b/compiler/testData/diagnostics/tests/controlStructures/specialConstructsAndPlatformTypes.fir.kt @@ -12,7 +12,7 @@ public class J { val testImplicitExclExcl1: String = J.s val testImplicitExclExcl2: String? = J.s -val testImplicitExclExcl3: String = J.m[""] +val testImplicitExclExcl3: String = J.m[""] val testImplicitExclExcl4: String? = J.m[""] val testExclExcl1: String = J.s!! @@ -21,20 +21,20 @@ val testExclExcl2: String? = J.s!! val testExclExcl3: String = J.m[""]!! val testExclExcl4: String? = J.m[""]!! -val testSafeCall1: String = J.s?.let { it } +val testSafeCall1: String = J.s?.let { it } val testSafeCall2: String? = J.s?.let { it } -val testSafeCall3: String = J.m[""]?.let { it } +val testSafeCall3: String = J.m[""]?.let { it } val testSafeCall4: String? = J.m[""]?.let { it.toString() } val testIf1: String = if (true) J.s else J.s val testIf2: String? = if (true) J.s else J.s -val testIf3: String = if (true) J.m[""] else J.m[""] +val testIf3: String = if (true) J.m[""] else J.m[""] val testIf4: String? = if (true) J.m[""] else J.m[""] val testWhen1: String = when { else -> J.s } val testWhen2: String? = when { else -> J.s } -val testWhen3: String = when { else -> J.m[""] } +val testWhen3: String = when { else -> J.m[""] } val testWhen4: String? = when { else -> J.m[""] } diff --git a/compiler/testData/diagnostics/tests/cyclicHierarchy/kt303.fir.kt b/compiler/testData/diagnostics/tests/cyclicHierarchy/kt303.fir.kt index 725831b1992..c0f90cf663b 100644 --- a/compiler/testData/diagnostics/tests/cyclicHierarchy/kt303.fir.kt +++ b/compiler/testData/diagnostics/tests/cyclicHierarchy/kt303.fir.kt @@ -9,4 +9,4 @@ open class Bar() : Foo() { } -val x : Int = Foo() +val x : Int = Foo() diff --git a/compiler/testData/diagnostics/tests/declarationChecks/ScalaLikeNamedFun.fir.kt b/compiler/testData/diagnostics/tests/declarationChecks/ScalaLikeNamedFun.fir.kt index 7c93a338394..0ad9f653f61 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/ScalaLikeNamedFun.fir.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/ScalaLikeNamedFun.fir.kt @@ -3,16 +3,16 @@ fun test1(): Int = { return 1 } fun test2(): Int = { 1 } -val test3: () -> Int = fun (): Int = { return 1 } -val test4: () -> Int = fun (): Int = { 1 } +val test3: () -> Int = fun (): Int = { return 1 } +val test4: () -> Int = fun (): Int = { 1 } fun test5(): Int { return { 1 } } fun test6(): Int = fun (): Int = 1 fun outer() { fun test1(): Int = { return 1 } fun test2(): Int = { 1 } - val test3: () -> Int = fun (): Int = { return 1 } - val test4: () -> Int = fun (): Int = { 1 } + val test3: () -> Int = fun (): Int = { return 1 } + val test4: () -> Int = fun (): Int = { 1 } fun test5(): Int { return { 1 } } fun test6(): Int = fun (): Int = 1 } @@ -20,16 +20,16 @@ fun outer() { class Outer { fun test1(): Int = { return 1 } fun test2(): Int = { 1 } - val test3: () -> Int = fun (): Int = { return 1 } - val test4: () -> Int = fun (): Int = { 1 } + val test3: () -> Int = fun (): Int = { return 1 } + val test4: () -> Int = fun (): Int = { 1 } fun test5(): Int { return { 1 } } fun test6(): Int = fun (): Int = 1 class Nested { fun test1(): Int = { return 1 } fun test2(): Int = { 1 } - val test3: () -> Int = fun (): Int = { return 1 } - val test4: () -> Int = fun (): Int = { 1 } + val test3: () -> Int = fun (): Int = { return 1 } + val test4: () -> Int = fun (): Int = { 1 } fun test5(): Int { return { 1 } } fun test6(): Int = fun (): Int = 1 } diff --git a/compiler/testData/diagnostics/tests/deparenthesize/checkDeparenthesizedType.fir.kt b/compiler/testData/diagnostics/tests/deparenthesize/checkDeparenthesizedType.fir.kt index cab0f189f59..cbc3f4d1b96 100644 --- a/compiler/testData/diagnostics/tests/deparenthesize/checkDeparenthesizedType.fir.kt +++ b/compiler/testData/diagnostics/tests/deparenthesize/checkDeparenthesizedType.fir.kt @@ -13,10 +13,10 @@ fun test(i: Int?) { foo((l3@ i)) } - val a: Int = l4@ "" - val b: Int = ("") + val a: Int = l4@ "" + val b: Int = ("") val c: Int = checkSubtype("") - val d: Int = checkSubtype("") + val d: Int = checkSubtype("") foo(l4@ "") diff --git a/compiler/testData/diagnostics/tests/evaluate/binaryMinusIndependentExpType.fir.kt b/compiler/testData/diagnostics/tests/evaluate/binaryMinusIndependentExpType.fir.kt index f7f924c32ef..b6dcb1386e7 100644 --- a/compiler/testData/diagnostics/tests/evaluate/binaryMinusIndependentExpType.fir.kt +++ b/compiler/testData/diagnostics/tests/evaluate/binaryMinusIndependentExpType.fir.kt @@ -1,24 +1,24 @@ val p1: Int = 1 - 1 -val p2: Long = 1 - 1 -val p3: Byte = 1 - 1 -val p4: Short = 1 - 1 +val p2: Long = 1 - 1 +val p3: Byte = 1 - 1 +val p4: Short = 1 - 1 val l1: Long = 1 - 1.toLong() -val l2: Byte = 1 - 1.toLong() -val l3: Int = 1 - 1.toLong() -val l4: Short = 1 - 1.toLong() +val l2: Byte = 1 - 1.toLong() +val l3: Int = 1 - 1.toLong() +val l4: Short = 1 - 1.toLong() -val b1: Byte = 1 - 1.toByte() +val b1: Byte = 1 - 1.toByte() val b2: Int = 1 - 1.toByte() -val b3: Long = 1 - 1.toByte() -val b4: Short = 1 - 1.toByte() +val b3: Long = 1 - 1.toByte() +val b4: Short = 1 - 1.toByte() -val i1: Byte = 1 - 1.toInt() +val i1: Byte = 1 - 1.toInt() val i2: Int = 1 - 1.toInt() -val i3: Long = 1 - 1.toInt() -val i4: Short = 1 - 1.toInt() +val i3: Long = 1 - 1.toInt() +val i4: Short = 1 - 1.toInt() -val s1: Byte = 1 - 1.toShort() +val s1: Byte = 1 - 1.toShort() val s2: Int = 1 - 1.toShort() -val s3: Long = 1 - 1.toShort() -val s4: Short = 1 - 1.toShort() \ No newline at end of file +val s3: Long = 1 - 1.toShort() +val s4: Short = 1 - 1.toShort() diff --git a/compiler/testData/diagnostics/tests/evaluate/integer.fir.kt b/compiler/testData/diagnostics/tests/evaluate/integer.fir.kt index 329bb5d10c0..9e9f6984f9f 100644 --- a/compiler/testData/diagnostics/tests/evaluate/integer.fir.kt +++ b/compiler/testData/diagnostics/tests/evaluate/integer.fir.kt @@ -1,8 +1,8 @@ -val a1: Int = 1L -val a2: Int = 0x1L -val a3: Int = 0X1L -val a4: Int = 0b1L -val a5: Int = 0B1L +val a1: Int = 1L +val a2: Int = 0x1L +val a3: Int = 0X1L +val a4: Int = 0b1L +val a5: Int = 0B1L val a6: Long = 1L val a7: Long = 0x1L val a8: Long = 0X1L diff --git a/compiler/testData/diagnostics/tests/evaluate/parentesized.fir.kt b/compiler/testData/diagnostics/tests/evaluate/parentesized.fir.kt index 1b35f47790b..aeb47871192 100644 --- a/compiler/testData/diagnostics/tests/evaluate/parentesized.fir.kt +++ b/compiler/testData/diagnostics/tests/evaluate/parentesized.fir.kt @@ -1,10 +1,10 @@ -val p1: Byte = (1 + 2) * 2 -val p2: Short = (1 + 2) * 2 +val p1: Byte = (1 + 2) * 2 +val p2: Short = (1 + 2) * 2 val p3: Int = (1 + 2) * 2 -val p4: Long = (1 + 2) * 2 +val p4: Long = (1 + 2) * 2 -val b1: Byte = (1.toByte() + 2) * 2 -val b2: Short = (1.toShort() + 2) * 2 +val b1: Byte = (1.toByte() + 2) * 2 +val b2: Short = (1.toShort() + 2) * 2 val b3: Int = (1.toInt() + 2) * 2 val b4: Long = (1.toLong() + 2) * 2 diff --git a/compiler/testData/diagnostics/tests/evaluate/unaryMinusIndependentExpType.fir.kt b/compiler/testData/diagnostics/tests/evaluate/unaryMinusIndependentExpType.fir.kt index 29a08c66433..372ec2bda6d 100644 --- a/compiler/testData/diagnostics/tests/evaluate/unaryMinusIndependentExpType.fir.kt +++ b/compiler/testData/diagnostics/tests/evaluate/unaryMinusIndependentExpType.fir.kt @@ -3,27 +3,27 @@ val p2: Long = -1 val p3: Byte = -1 val p4: Short = -1 -val lp1: Int = -1111111111111111111 +val lp1: Int = -1111111111111111111 val lp2: Long = -1111111111111111111 -val lp3: Byte = -1111111111111111111 -val lp4: Short = -1111111111111111111 +val lp3: Byte = -1111111111111111111 +val lp4: Short = -1111111111111111111 val l1: Long = -1.toLong() -val l2: Byte = -1.toLong() -val l3: Int = -1.toLong() -val l4: Short = -1.toLong() +val l2: Byte = -1.toLong() +val l3: Int = -1.toLong() +val l4: Short = -1.toLong() -val b1: Byte = -1.toByte() +val b1: Byte = -1.toByte() val b2: Int = -1.toByte() -val b3: Long = -1.toByte() -val b4: Short = -1.toByte() +val b3: Long = -1.toByte() +val b4: Short = -1.toByte() -val i1: Byte = -1.toInt() +val i1: Byte = -1.toInt() val i2: Int = -1.toInt() -val i3: Long = -1.toInt() -val i4: Short = -1.toInt() +val i3: Long = -1.toInt() +val i4: Short = -1.toInt() -val s1: Byte = -1.toShort() +val s1: Byte = -1.toShort() val s2: Int = -1.toShort() -val s3: Long = -1.toShort() -val s4: Short = -1.toShort() \ No newline at end of file +val s3: Long = -1.toShort() +val s4: Short = -1.toShort() diff --git a/compiler/testData/diagnostics/tests/functionAsExpression/FunctionType.fir.kt b/compiler/testData/diagnostics/tests/functionAsExpression/FunctionType.fir.kt index fb97f697159..d304a2cee60 100644 --- a/compiler/testData/diagnostics/tests/functionAsExpression/FunctionType.fir.kt +++ b/compiler/testData/diagnostics/tests/functionAsExpression/FunctionType.fir.kt @@ -9,7 +9,7 @@ fun testReturnType(foo: String) { val bas: () -> String = fun () = foo - val bag: () -> Int = fun () = foo + val bag: () -> Int = fun () = foo } fun testParamType() { @@ -18,7 +18,7 @@ fun testParamType() { bar.checkType { _<(String) -> Unit>() } val bas: (String) -> Unit = fun (param: String) {} - val bag: (Int) -> Unit = fun (param: String) {} + val bag: (Int) -> Unit = fun (param: String) {} } fun testReceiverType() { @@ -28,5 +28,5 @@ fun testReceiverType() { val bas: String.() -> Unit = fun String.() {} - val bag: Int.() -> Unit = fun String.() {} + val bag: Int.() -> Unit = fun String.() {} } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/functionAsExpression/InferenceParametersTypes.fir.kt b/compiler/testData/diagnostics/tests/functionAsExpression/InferenceParametersTypes.fir.kt index d5cd7b305ed..bf1be9eec6a 100644 --- a/compiler/testData/diagnostics/tests/functionAsExpression/InferenceParametersTypes.fir.kt +++ b/compiler/testData/diagnostics/tests/functionAsExpression/InferenceParametersTypes.fir.kt @@ -17,4 +17,4 @@ fun test2(a: () -> List) { val a: (Int) -> Unit = fun(x) { checkSubtype(x) } -val b: (Int) -> Unit = fun(x: String) {} +val b: (Int) -> Unit = fun(x: String) {} diff --git a/compiler/testData/diagnostics/tests/functionAsExpression/MissingParameterTypes.fir.kt b/compiler/testData/diagnostics/tests/functionAsExpression/MissingParameterTypes.fir.kt index 46d054100dc..826a1679ed7 100644 --- a/compiler/testData/diagnostics/tests/functionAsExpression/MissingParameterTypes.fir.kt +++ b/compiler/testData/diagnostics/tests/functionAsExpression/MissingParameterTypes.fir.kt @@ -6,13 +6,13 @@ val a = fun (x) = x val b: (Int) -> Int = fun (x) = x + 3 -val c: (Int, String) -> Int = fun (x) = 3 +val c: (Int, String) -> Int = fun (x) = 3 -val d: (Int, String) -> Int = fun (x) = 3 +val d: (Int, String) -> Int = fun (x) = 3 -val e: (Int, String) -> Int = fun (x: String) = 3 +val e: (Int, String) -> Int = fun (x: String) = 3 -val f: (Int) -> Int = fun (x: String) = 3 +val f: (Int) -> Int = fun (x: String) = 3 fun test1(a: (Int) -> Unit) { test1(fun (x) { checkSubtype(x)}) diff --git a/compiler/testData/diagnostics/tests/functionLiterals/assignmentOperationInLambdaWithExpectedType.fir.kt b/compiler/testData/diagnostics/tests/functionLiterals/assignmentOperationInLambdaWithExpectedType.fir.kt index 97f237d0ca1..08e5bae9fc5 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/assignmentOperationInLambdaWithExpectedType.fir.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/assignmentOperationInLambdaWithExpectedType.fir.kt @@ -4,13 +4,13 @@ fun test(bal: Array) { val a: () -> Unit = { bar += 4 } - val b: () -> Int = { bar = 4 } + val b: () -> Int = { bar = 4 } val c: () -> UNRESOLVED = { bal[2] = 3 } - val d: () -> Int = { bar += 4 } + val d: () -> Int = { bar += 4 } val e: Unit = run { bar += 4 } - val f: Int = run { bar += 4 } + val f: Int = run { bar += 4 } } diff --git a/compiler/testData/diagnostics/tests/functionLiterals/missedTypeMismatch.fir.kt b/compiler/testData/diagnostics/tests/functionLiterals/missedTypeMismatch.fir.kt index 44a1e3f13a8..aa213a46407 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/missedTypeMismatch.fir.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/missedTypeMismatch.fir.kt @@ -7,33 +7,33 @@ fun id(x: T) = x // Before the fix, there wasn't any type mismatch error in NI due to result type not being a subtype of expected type fun main() { - val x: () -> Int = { "" } + val x: () -> Int = { "" } - val a0: () -> Int = fun(): String = "1" - val a1: () -> Int = (fun() = "1") + val a0: () -> Int = fun(): String = "1" + val a1: () -> Int = (fun() = "1") val a2: () -> Unit = (fun() = "1") - val a3: Unit = (fun() = "1") + val a3: Unit = (fun() = "1") val a4 = (fun() = "1") val a5 = (fun(): String = "1") val a6: () -> Int = (fun() = 1) val a7: () -> Int = (fun(): String = "1") as () -> Int - val a8: () -> Int = fun(): String = "1" + val a8: () -> Int = fun(): String = "1" val a9: () -> () -> () -> Int = fun(): () -> () -> String = fun(): () -> String = fun(): String = "1" foo(fun(): String = "1") foo(((fun(): String = "1"))) - val a10: Int.(String) -> Int = fun (x: String) = 10 + val a10: Int.(String) -> Int = fun (x: String) = 10 val a11: () -> () -> () -> Int = fun() = fun() = fun(): String = "1" - val a12: Int = fun(): String = "1" - val a13: Int = fun() = fun(): String = "1" - val a14: Int = fun() = fun() = "1" - val a15: Int = fun() = fun() = {} - val a16: Int = fun() = fun() {} + val a12: Int = fun(): String = "1" + val a13: Int = fun() = fun(): String = "1" + val a14: Int = fun() = fun() = "1" + val a15: Int = fun() = fun() = {} + val a16: Int = fun() = fun() {} val a17: () -> Unit = fun() {} - val a18: () -> Int = fun() {} + val a18: () -> Int = fun() {} val a19: () -> () -> Int = fun() = fun() {} val a20: () -> () -> () -> Unit = fun() = fun() = {} val a21: () -> () -> () -> Int = fun() = fun() = {} diff --git a/compiler/testData/diagnostics/tests/functionLiterals/return/IfWithoutElseWithExplicitType.fir.kt b/compiler/testData/diagnostics/tests/functionLiterals/return/IfWithoutElseWithExplicitType.fir.kt index 1bba3f19ba7..fecb9ea5bf4 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/return/IfWithoutElseWithExplicitType.fir.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/return/IfWithoutElseWithExplicitType.fir.kt @@ -1,8 +1,8 @@ val flag = true -val a: () -> Int = l@ { +val a: () -> Int = l@ { if (flag) return@l 4 -} +} val b: () -> Unit = l@ { if (flag) return@l 4 @@ -17,6 +17,6 @@ val d: () -> Int = l@ { 5 } -val e: () -> Int = l@ { +val e: () -> Int = l@ { if (flag) 4 -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/generics/nullability/nullToGeneric.fir.kt b/compiler/testData/diagnostics/tests/generics/nullability/nullToGeneric.fir.kt index ad512613934..a09000b76c9 100644 --- a/compiler/testData/diagnostics/tests/generics/nullability/nullToGeneric.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/nullability/nullToGeneric.fir.kt @@ -3,7 +3,7 @@ fun bar(x: E) {} fun foo(): T { - val x1: T = null + val x1: T = null val x2: T? = null bar(null) @@ -20,7 +20,7 @@ class A { fun xyz(x: F) {} fun foo(): F { - val x1: F = null + val x1: F = null val x2: F? = null xyz(null) diff --git a/compiler/testData/diagnostics/tests/generics/projectionsScope/kt7296.fir.kt b/compiler/testData/diagnostics/tests/generics/projectionsScope/kt7296.fir.kt index 0016cabdc19..247b88ce81b 100644 --- a/compiler/testData/diagnostics/tests/generics/projectionsScope/kt7296.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/projectionsScope/kt7296.fir.kt @@ -9,7 +9,7 @@ fun main() { val a : ArrayList> = ArrayList() val b : ListOfLists = ListOfLists(a) val c : ListOfLists<*> = b - val d : ArrayList> = c.x + val d : ArrayList> = c.x c.x checkType { _>>() } } diff --git a/compiler/testData/diagnostics/tests/generics/projectionsScope/typeMismatchInLambda.fir.kt b/compiler/testData/diagnostics/tests/generics/projectionsScope/typeMismatchInLambda.fir.kt index a16b1db7271..8e547cb5709 100644 --- a/compiler/testData/diagnostics/tests/generics/projectionsScope/typeMismatchInLambda.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/projectionsScope/typeMismatchInLambda.fir.kt @@ -13,7 +13,7 @@ class A { fun test(a: A, z: Out) { a.foo { - val x: String = 1 // Should be no TYPE_MISMATCH_DUE_TO_TYPE_PROJECTIONS + val x: String = 1 // Should be no TYPE_MISMATCH_DUE_TO_TYPE_PROJECTIONS "" } a.bar { Out() } diff --git a/compiler/testData/diagnostics/tests/generics/suppressVarianceConflict.fir.kt b/compiler/testData/diagnostics/tests/generics/suppressVarianceConflict.fir.kt index e3b863f05ee..f348329e716 100644 --- a/compiler/testData/diagnostics/tests/generics/suppressVarianceConflict.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/suppressVarianceConflict.fir.kt @@ -11,7 +11,7 @@ fun foo(x: A, cs: CharSequence, ls: List) { val y: A = x y.foo(cs) - val s: String = y.foo(cs, ls) + val s: String = y.foo(cs, ls) - val ls2: List = y.bar() + val ls2: List = y.bar() } diff --git a/compiler/testData/diagnostics/tests/imports/InaccessiblePrivateClass.fir.kt b/compiler/testData/diagnostics/tests/imports/InaccessiblePrivateClass.fir.kt index a44cf851515..b11568a67ba 100644 --- a/compiler/testData/diagnostics/tests/imports/InaccessiblePrivateClass.fir.kt +++ b/compiler/testData/diagnostics/tests/imports/InaccessiblePrivateClass.fir.kt @@ -14,5 +14,5 @@ package p1 import p2.* -val x: X = X() +val x: X = X() val y: Y = Y() diff --git a/compiler/testData/diagnostics/tests/inference/capturedTypes/captureForNullableTypes.fir.kt b/compiler/testData/diagnostics/tests/inference/capturedTypes/captureForNullableTypes.fir.kt index 502b407bb8f..42533c3bfae 100644 --- a/compiler/testData/diagnostics/tests/inference/capturedTypes/captureForNullableTypes.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/capturedTypes/captureForNullableTypes.fir.kt @@ -5,7 +5,7 @@ fun bar(a: Array): Array = null!! fun test1(a: Array) { - val r: Array = bar(a) + val r: Array = bar(a) val t = bar(a) t checkType { _>() } } @@ -13,7 +13,7 @@ fun test1(a: Array) { fun foo(l: Array): Array> = null!! fun test2(a: Array) { - val r: Array> = foo(a) + val r: Array> = foo(a) val t = foo(a) t checkType { _>>() } } diff --git a/compiler/testData/diagnostics/tests/inference/capturedTypes/expectedTypeMismatchWithInVariance.fir.kt b/compiler/testData/diagnostics/tests/inference/capturedTypes/expectedTypeMismatchWithInVariance.fir.kt index 3408e5adfd2..12bb9443a9e 100644 --- a/compiler/testData/diagnostics/tests/inference/capturedTypes/expectedTypeMismatchWithInVariance.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/capturedTypes/expectedTypeMismatchWithInVariance.fir.kt @@ -5,6 +5,6 @@ fun foo(a1: Array, a2: Array): T = null!! fun test(a1: Array, a2: Array) { - val c: Int = foo(a1, a2) + val c: Int = foo(a1, a2) } diff --git a/compiler/testData/diagnostics/tests/inference/coercionToUnit/noCoercion.fir.kt b/compiler/testData/diagnostics/tests/inference/coercionToUnit/noCoercion.fir.kt index 655898ee233..94f1cba028c 100644 --- a/compiler/testData/diagnostics/tests/inference/coercionToUnit/noCoercion.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/coercionToUnit/noCoercion.fir.kt @@ -10,9 +10,9 @@ fun noCoercionLastExpressionUsedAsReturnArgument() { } fun noCoercionBlockHasExplicitType() { - val b: () -> Int = { + val b: () -> Int = { if (true) 42 - } + } } fun noCoercionBlockHasExplicitReturn() { diff --git a/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/basic.fir.kt b/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/basic.fir.kt index e39c4d21ce3..1fa335e25d9 100644 --- a/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/basic.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/basic.fir.kt @@ -138,7 +138,7 @@ fun main() { * K <: (C) -> Unit -> TypeVariable(_RP1) >: C * K == (B) -> Unit -> TypeVariable(_RP1) == B */ - val x17: (C) -> Unit = selectB(id { it }, id { it }, id<(B) -> Unit> { x -> x }) + val x17: (C) -> Unit = selectB(id { it }, id { it }, id<(B) -> Unit> { x -> x }) val x18: (C) -> Unit = select(id { it }, { it }, id<(B) -> Unit> { x -> x }) // Resolution of extension/non-extension functions combination @@ -153,7 +153,7 @@ fun main() { // Convert to extension lambda is impossible because the lambda parameter types aren't specified explicitly select(id(fun String.(x: String) {}), id(fun(x: String, y: String) { }), { x, y -> x }) select(id(id(fun(x: String, y: String) { }), fun String.(x: String) {}), { x, y -> x }) - val x26: Int.(String) -> Int = fun (x: String) = 10 // it must be error, see KT-38439 + val x26: Int.(String) -> Int = fun (x: String) = 10 // it must be error, see KT-38439 // Receiver must be specified in anonymous function declaration val x27: Int.(String) -> Int = id(fun (x: String) = 10) select(id Unit> {}, { x: Int, y: String -> x }) diff --git a/compiler/testData/diagnostics/tests/inference/constraints/kt6320.fir.kt b/compiler/testData/diagnostics/tests/inference/constraints/kt6320.fir.kt index 4c494a58fa8..0d87ad62be1 100644 --- a/compiler/testData/diagnostics/tests/inference/constraints/kt6320.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/constraints/kt6320.fir.kt @@ -16,6 +16,6 @@ class C class D(foo: C) { fun test(a: C) { - val d: D = D(a) + val d: D = D(a) } } diff --git a/compiler/testData/diagnostics/tests/inference/dependantOnVariance.fir.kt b/compiler/testData/diagnostics/tests/inference/dependantOnVariance.fir.kt index 63bea3fbf23..1a332ce3272 100644 --- a/compiler/testData/diagnostics/tests/inference/dependantOnVariance.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/dependantOnVariance.fir.kt @@ -25,17 +25,17 @@ fun test1(int: Int, any: Any) { val a5 : MyList = getMyListToWriteTo(any) - val a6 : MyList = getMyList(int) + val a6 : MyList = getMyList(int) val a7 : MyList = getMyList(int) - val a8 : MyList = getMyListToReadFrom(int) - val a9 : MyList = getMyListToReadFrom(int) + val a8 : MyList = getMyListToReadFrom(int) + val a9 : MyList = getMyListToReadFrom(int) - val a10 : MyList = getMyList(any) - val a11 : MyList = getMyList(any) + val a10 : MyList = getMyList(any) + val a11 : MyList = getMyList(any) - val a12 : MyList = getMyListToWriteTo(any) - val a13 : MyList = getMyListToWriteTo(any) + val a12 : MyList = getMyListToWriteTo(any) + val a13 : MyList = getMyListToWriteTo(any) useMyList(getMyList(int), int) useMyList(getMyList(any), int) diff --git a/compiler/testData/diagnostics/tests/inference/kt1293.fir.kt b/compiler/testData/diagnostics/tests/inference/kt1293.fir.kt index ea29e46f681..2bff6e8f05f 100644 --- a/compiler/testData/diagnostics/tests/inference/kt1293.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/kt1293.fir.kt @@ -5,7 +5,7 @@ package kt1293 fun main() { val intArray = arrayOfNulls(10) - val i : Int = intArray[0] + val i : Int = intArray[0] requiresInt(intArray[0]) } diff --git a/compiler/testData/diagnostics/tests/inference/lambdaInValInitializerWithAnonymousFunctions.fir.kt b/compiler/testData/diagnostics/tests/inference/lambdaInValInitializerWithAnonymousFunctions.fir.kt index 399d26ddc54..5a2ef9e81ce 100644 --- a/compiler/testData/diagnostics/tests/inference/lambdaInValInitializerWithAnonymousFunctions.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/lambdaInValInitializerWithAnonymousFunctions.fir.kt @@ -5,5 +5,5 @@ val test2f: suspend Any.() -> Unit = fun Any.() {} // This is a bug in the old inference and should be fixed in new inference // see "Fix anonymous function literals handling in type checker" for more details -val test3f: suspend Any.(Int) -> Int = fun (k: Int) = k + 1 -val test4f: SuspendFn = fun Any.() {} \ No newline at end of file +val test3f: suspend Any.(Int) -> Int = fun (k: Int) = k + 1 +val test4f: SuspendFn = fun Any.() {} diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt1127.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt1127.fir.kt index bfd456688bc..b3a0999132f 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt1127.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt1127.fir.kt @@ -6,5 +6,5 @@ package d fun asList(t: T) : List? {} fun main() { - val list : List = asList("") + val list : List = asList("") } diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2883.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2883.fir.kt index d6e35203230..d014143a310 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt2883.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2883.fir.kt @@ -22,12 +22,12 @@ fun test() { doAction { bar(12) } - val u: Unit = bar(11) + val u: Unit = bar(11) } fun testWithoutInference(col: MutableCollection) { doAction { col.add(2) } - val u: Unit = col.add(2) + val u: Unit = col.add(2) } diff --git a/compiler/testData/diagnostics/tests/inference/tooEagerSmartcast.fir.kt b/compiler/testData/diagnostics/tests/inference/tooEagerSmartcast.fir.kt index 18be734f3fd..0fc3c7ddd57 100644 --- a/compiler/testData/diagnostics/tests/inference/tooEagerSmartcast.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/tooEagerSmartcast.fir.kt @@ -20,7 +20,7 @@ fun InvBase.myLastInv(): X = TODO() fun fooInv(x: InvBase) { if (x is InvDerived<*>) { - val l: T = x.myLastInv() // required T, found Cap(*). Only in NI + val l: T = x.myLastInv() // required T, found Cap(*). Only in NI } } diff --git a/compiler/testData/diagnostics/tests/inference/typeInferenceExpectedTypeMismatch.fir.kt b/compiler/testData/diagnostics/tests/inference/typeInferenceExpectedTypeMismatch.fir.kt index f98ecebf7f6..b60ddfcd681 100644 --- a/compiler/testData/diagnostics/tests/inference/typeInferenceExpectedTypeMismatch.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/typeInferenceExpectedTypeMismatch.fir.kt @@ -4,7 +4,7 @@ package typeInferenceExpectedTypeMismatch import java.util.* fun test() { - val s : Set = newList() + val s : Set = newList() use(s) } @@ -35,7 +35,7 @@ fun bar(o: Out, i: In): Two = throw Exception("$o $i") fun test2(outA: Out, inC: In) { bar(outA, inC) - val b: Two = bar(outA, inC) + val b: Two = bar(outA, inC) use(b) } diff --git a/compiler/testData/diagnostics/tests/inference/upperBounds/useBoundsIfUnknownParameters.fir.kt b/compiler/testData/diagnostics/tests/inference/upperBounds/useBoundsIfUnknownParameters.fir.kt index 05c1fbf9520..c442f006335 100644 --- a/compiler/testData/diagnostics/tests/inference/upperBounds/useBoundsIfUnknownParameters.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/upperBounds/useBoundsIfUnknownParameters.fir.kt @@ -8,5 +8,5 @@ class Client>(x: X) fun test() { val c = Client(StringBase()) // Type inference fails here for T. - val i : Int = c + val i : Int = c } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/j+k/sam/referenceToSamFunctionAgainstExpectedType.fir.kt b/compiler/testData/diagnostics/tests/j+k/sam/referenceToSamFunctionAgainstExpectedType.fir.kt index 18cda240d71..881ef99228e 100644 --- a/compiler/testData/diagnostics/tests/j+k/sam/referenceToSamFunctionAgainstExpectedType.fir.kt +++ b/compiler/testData/diagnostics/tests/j+k/sam/referenceToSamFunctionAgainstExpectedType.fir.kt @@ -17,7 +17,7 @@ public class Inv { // FILE: test.kt fun test(inv: Inv) { - val m: ((String) -> String) -> Inv = inv::map + val m: ((String) -> String) -> Inv = inv::map take(inv::map) } diff --git a/compiler/testData/diagnostics/tests/library/Collections.fir.kt b/compiler/testData/diagnostics/tests/library/Collections.fir.kt index 85fa039e77b..c721deda4d3 100644 --- a/compiler/testData/diagnostics/tests/library/Collections.fir.kt +++ b/compiler/testData/diagnostics/tests/library/Collections.fir.kt @@ -8,7 +8,7 @@ fun testCollection(c: Collection, t: T) { val iterator: Iterator = c.iterator() c.containsAll(c) - val mutableIterator: MutableIterator = c.iterator() + val mutableIterator: MutableIterator = c.iterator() c.add(t) c.remove(1) c.addAll(c) @@ -45,9 +45,9 @@ fun testList(l: List, t: T) { val value: T = l.set(1, t) l.add(1, t) l.remove(1) - val mutableListIterator: MutableListIterator = l.listIterator() - val mutableListIterator1: MutableListIterator = l.listIterator(1) - val mutableList: MutableList = l.subList(1, 2) + val mutableListIterator: MutableListIterator = l.listIterator() + val mutableListIterator1: MutableListIterator = l.listIterator(1) + val mutableList: MutableList = l.subList(1, 2) } fun testMutableList(l: MutableList, t: T) { @@ -66,7 +66,7 @@ fun testSet(s: Set, t: T) { val iterator: Iterator = s.iterator() s.containsAll(s) - val mutableIterator: MutableIterator = s.iterator() + val mutableIterator: MutableIterator = s.iterator() s.add(t) s.remove(1) s.addAll(s) @@ -97,9 +97,9 @@ fun testMap(m: Map) { val collection: Collection = m.values val set1: Set> = m.entries - val mutableSet: MutableSet = m.keys - val mutableCollection: MutableCollection = m.values - val mutableSet1: MutableSet> = m.entries + val mutableSet: MutableSet = m.keys + val mutableCollection: MutableCollection = m.values + val mutableSet1: MutableSet> = m.entries } fun testMutableMap(m: MutableMap) { diff --git a/compiler/testData/diagnostics/tests/multimodule/duplicateClass/sameClassNameDifferentPackages.fir.kt b/compiler/testData/diagnostics/tests/multimodule/duplicateClass/sameClassNameDifferentPackages.fir.kt index 6de2c5bc250..4105d6291d3 100644 --- a/compiler/testData/diagnostics/tests/multimodule/duplicateClass/sameClassNameDifferentPackages.fir.kt +++ b/compiler/testData/diagnostics/tests/multimodule/duplicateClass/sameClassNameDifferentPackages.fir.kt @@ -18,5 +18,5 @@ import p.* class A fun test() { - val a: A = B().a + val a: A = B().a } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/AssertNotNull.fir.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/AssertNotNull.fir.kt index 82aa7aee305..cf7143619e3 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/AssertNotNull.fir.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/AssertNotNull.fir.kt @@ -34,6 +34,6 @@ fun main() { } } - val f : String = a!! + val f : String = a!! checkSubtype(a!!) } diff --git a/compiler/testData/diagnostics/tests/nullableTypes/inferenceFlexibleTToNullable.fir.kt b/compiler/testData/diagnostics/tests/nullableTypes/inferenceFlexibleTToNullable.fir.kt index 5bd103abf79..b535da389e5 100644 --- a/compiler/testData/diagnostics/tests/nullableTypes/inferenceFlexibleTToNullable.fir.kt +++ b/compiler/testData/diagnostics/tests/nullableTypes/inferenceFlexibleTToNullable.fir.kt @@ -32,12 +32,12 @@ public class Foo { // FILE: main.kt fun bar(n: Number?, d: T, e: T) { - val a: Number = Foo.simpleId(n) + val a: Number = Foo.simpleId(n) val b: Number? = Foo.simpleId(n) val c = Foo.simpleId(n) val x4 = Foo(if (true) 10 else null) - val x5: Number = x4.produceT() + val x5: Number = x4.produceT() val x6: Number? = x4.produceT() val x7 = x4.produceT() val x8 = x4.produceNotNullT() diff --git a/compiler/testData/diagnostics/tests/numbers/doublesInSimpleConstraints.fir.kt b/compiler/testData/diagnostics/tests/numbers/doublesInSimpleConstraints.fir.kt index ed75bdb678d..3aa4281c58a 100644 --- a/compiler/testData/diagnostics/tests/numbers/doublesInSimpleConstraints.fir.kt +++ b/compiler/testData/diagnostics/tests/numbers/doublesInSimpleConstraints.fir.kt @@ -21,5 +21,5 @@ fun test() { val d = either(11, 2.3) checkSubtype(d) - val e: Float = id(1) + val e: Float = id(1) } diff --git a/compiler/testData/diagnostics/tests/numbers/numbersInSimpleConstraints.fir.kt b/compiler/testData/diagnostics/tests/numbers/numbersInSimpleConstraints.fir.kt index 295e47da674..ebdd8dc6deb 100644 --- a/compiler/testData/diagnostics/tests/numbers/numbersInSimpleConstraints.fir.kt +++ b/compiler/testData/diagnostics/tests/numbers/numbersInSimpleConstraints.fir.kt @@ -17,9 +17,9 @@ fun otherGeneric(l: List) {} fun test() { val a: Byte = id(1) - val b: Byte = id(300) + val b: Byte = id(300) - val c: Int = id(9223372036854775807) + val c: Int = id(9223372036854775807) val d = id(22) checkSubtype(d) @@ -29,7 +29,7 @@ fun test() { val f: Byte = either(1, 2) - val g: Byte = either(1, 300) + val g: Byte = either(1, 300) other(11) diff --git a/compiler/testData/diagnostics/tests/objects/kt5527.fir.kt b/compiler/testData/diagnostics/tests/objects/kt5527.fir.kt index 27ae3be0f08..de95c8a8022 100644 --- a/compiler/testData/diagnostics/tests/objects/kt5527.fir.kt +++ b/compiler/testData/diagnostics/tests/objects/kt5527.fir.kt @@ -7,13 +7,13 @@ class A { } fun foo() { - val i1: Int = Boo - val i2: Int = A.Boo + val i1: Int = Boo + val i2: Int = A.Boo useInt(Boo) useInt(A.Boo) } fun bar() { - val i1: Int = Unit + val i1: Int = Unit useInt(Unit) } diff --git a/compiler/testData/diagnostics/tests/platformTypes/methodCall/singleton.fir.kt b/compiler/testData/diagnostics/tests/platformTypes/methodCall/singleton.fir.kt index 5cce6cae9c7..96258980d2a 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/methodCall/singleton.fir.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/methodCall/singleton.fir.kt @@ -5,6 +5,6 @@ interface Foo fun test() { var nullable: Foo? = null - val foo: Collection = java.util.Collections.singleton(nullable) + val foo: Collection = java.util.Collections.singleton(nullable) val foo1: Collection = java.util.Collections.singleton(nullable!!) } diff --git a/compiler/testData/diagnostics/tests/platformTypes/rawTypes/rawTypeInUpperBound.fir.kt b/compiler/testData/diagnostics/tests/platformTypes/rawTypes/rawTypeInUpperBound.fir.kt index 6348481ec04..511fdb2da0a 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/rawTypes/rawTypeInUpperBound.fir.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/rawTypes/rawTypeInUpperBound.fir.kt @@ -31,7 +31,7 @@ fun foo(x: B<*>) { // Raw(B).field erased to A..A? Test.rawB.field = A() - val anyA: A = Test.rawB.field + val anyA: A = Test.rawB.field // FIR doesn't work here, because // field has a type of just 'A' and it's not clear why should it accept 'String' at consume diff --git a/compiler/testData/diagnostics/tests/regressions/TypeMismatchOnUnaryOperations.fir.kt b/compiler/testData/diagnostics/tests/regressions/TypeMismatchOnUnaryOperations.fir.kt index ba05c3f1ffe..074bc3a3894 100644 --- a/compiler/testData/diagnostics/tests/regressions/TypeMismatchOnUnaryOperations.fir.kt +++ b/compiler/testData/diagnostics/tests/regressions/TypeMismatchOnUnaryOperations.fir.kt @@ -2,15 +2,15 @@ fun main() { val a : Int? = null; var v = 1 - val b : String = v; - val f : String = a!!; + val b : String = v; + val f : String = a!!; val g : String = v++; val g1 : String = ++v; val h : String = v--; val h1 : String = --v; - val i : String = !true; - val j : String = foo@ true; - val k : String = foo@ bar@ true; - val l : String = -1; - val m : String = +1; + val i : String = !true; + val j : String = foo@ true; + val k : String = foo@ bar@ true; + val l : String = -1; + val m : String = +1; } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/regressions/kt235.fir.kt b/compiler/testData/diagnostics/tests/regressions/kt235.fir.kt index f404c6c8a8a..5561051210f 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt235.fir.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt235.fir.kt @@ -4,29 +4,29 @@ package kt235 fun main() { val array = MyArray() - val f: () -> String = { + val f: () -> String = { array[2] = 23 //error: Type mismatch: inferred type is Int (!!!) but String was expected - } - val g: () -> String = { + } + val g: () -> String = { var x = 1 x += 2 //no error, but it should be here - } - val h: () -> String = { + } + val h: () -> String = { var x = 1 x = 2 //the same - } + } val array1 = MyArray1() - val i: () -> String = { + val i: () -> String = { array1[2] = 23 - } + } - val fi: () -> String = { + val fi: () -> String = { array[2] = 23 - } - val gi: () -> String = { + } + val gi: () -> String = { var x = 1 x += 21 - } + } var m: MyNumber = MyNumber() val a: () -> MyNumber = { diff --git a/compiler/testData/diagnostics/tests/regressions/kt2768.fir.kt b/compiler/testData/diagnostics/tests/regressions/kt2768.fir.kt index 0670f633eb2..b5eacfa03c0 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt2768.fir.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt2768.fir.kt @@ -6,13 +6,13 @@ fun main() { val bytePos = 128.toByte() // Byte.MAX_VALUE + 1 assertEquals(-128, bytePos.toInt()) // correct, wrapped to Byte.MIN_VALUE - val byteNeg: Byte = -bytePos // should not compile, byteNeg should be Int + val byteNeg: Byte = -bytePos // should not compile, byteNeg should be Int assertEquals(128, byteNeg.toInt()) // passes, should not be possible val shortPos = 32768.toShort() // Short.MAX_VALUE + 1 assertEquals(-32768, shortPos.toInt()) // correct, wrapped to Short.MIN_VALUE - val shortNeg: Short = -shortPos // should not compile, shortNeg should be Int + val shortNeg: Short = -shortPos // should not compile, shortNeg should be Int assertEquals(32768, shortNeg.toInt()) // passes, should not be possible (-128).toByte() diff --git a/compiler/testData/diagnostics/tests/regressions/kt2956.fir.kt b/compiler/testData/diagnostics/tests/regressions/kt2956.fir.kt index 491dea82e02..bfe423f976e 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt2956.fir.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt2956.fir.kt @@ -1 +1 @@ -val a: String = Nothing \ No newline at end of file +val a: String = Nothing diff --git a/compiler/testData/diagnostics/tests/regressions/kt30245.fir.kt b/compiler/testData/diagnostics/tests/regressions/kt30245.fir.kt index d621faff8f1..7af615291cb 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt30245.fir.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt30245.fir.kt @@ -80,8 +80,8 @@ fun test2() { // to extension lambda 1 val e = E.VALUE val w27 = W2(when (e) { E.VALUE -> { s: String -> this + s.length } }) // oi- ni+ val w27a = W2(when (e) { E.VALUE -> { s -> this + s.length } }) // oi+ ni+ - val i27: E1 = when (e) { E.VALUE -> { s: String -> this + s.length } } // oi+ ni+ - val i27a: E1 = when (e) { E.VALUE -> { s -> this + s.length } } // oi+ ni+ + val i27: E1 = when (e) { E.VALUE -> { s: String -> this + s.length } } // oi+ ni+ + val i27a: E1 = when (e) { E.VALUE -> { s -> this + s.length } } // oi+ ni+ val w28 = W2 { i: Int, s -> i + s.length } // oi- ni- val i28: E1 = id { i: Int, s -> i + s.length } // oi- ni- diff --git a/compiler/testData/diagnostics/tests/regressions/kt312.fir.kt b/compiler/testData/diagnostics/tests/regressions/kt312.fir.kt index acc1f575bea..c0917fdfd79 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt312.fir.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt312.fir.kt @@ -6,5 +6,5 @@ fun Array.safeGet(index : Int) : T? { } val args : Array = Array(1, {""}) -val name : String = args.safeGet(0) // No error, must be type mismatch +val name : String = args.safeGet(0) // No error, must be type mismatch val name1 : String? = args.safeGet(0) diff --git a/compiler/testData/diagnostics/tests/resolve/overloadConflicts/originalExamples.fir.kt b/compiler/testData/diagnostics/tests/resolve/overloadConflicts/originalExamples.fir.kt index 63f59b6fc34..ac2070fe9e5 100644 --- a/compiler/testData/diagnostics/tests/resolve/overloadConflicts/originalExamples.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/overloadConflicts/originalExamples.fir.kt @@ -8,7 +8,7 @@ fun overloadedFun1(c: Any = "", b: String = "", f: Any = "") = Right fun overloadedFun1(b: Any = "", c: Any = "", e: String = "") = Wrong val test1: Right = overloadedFun1(b = "") -val test1a: Wrong = overloadedFun1(b = "") +val test1a: Wrong = overloadedFun1(b = "") fun overloadedFun2(a: String, b: Any = "") = Right fun overloadedFun2(a: Any, b: String = "") = Wrong diff --git a/compiler/testData/diagnostics/tests/scopes/inheritance/methodsPriority.fir.kt b/compiler/testData/diagnostics/tests/scopes/inheritance/methodsPriority.fir.kt index 6cb02f88f68..f7c35ad409b 100644 --- a/compiler/testData/diagnostics/tests/scopes/inheritance/methodsPriority.fir.kt +++ b/compiler/testData/diagnostics/tests/scopes/inheritance/methodsPriority.fir.kt @@ -20,7 +20,7 @@ fun test() { class B: A() { init { - val a: Int = foo() // todo + val a: Int = foo() // todo } } } diff --git a/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromContainingClass_after.fir.kt b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromContainingClass_after.fir.kt index 125b8a7661f..2bce74682e1 100644 --- a/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromContainingClass_after.fir.kt +++ b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromContainingClass_after.fir.kt @@ -12,14 +12,14 @@ open class A : J() { init { foo() bar() - val a: Int = baz() + val a: Int = baz() val b: T = baz() } fun test1() { foo() bar() - val a: Int = baz() + val a: Int = baz() val b: T = baz() } diff --git a/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromContainingClass_before.fir.kt b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromContainingClass_before.fir.kt index 89226a4a963..1482463d2e1 100644 --- a/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromContainingClass_before.fir.kt +++ b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromContainingClass_before.fir.kt @@ -12,14 +12,14 @@ open class A : J() { init { foo() bar() - val a: Int = baz() + val a: Int = baz() val b: T = baz() } fun test1() { foo() bar() - val a: Int = baz() + val a: Int = baz() val b: T = baz() } diff --git a/compiler/testData/diagnostics/tests/scopes/inheritance/statics/localVsStatic.fir.kt b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/localVsStatic.fir.kt index 6c66335bc88..4f2380bb4ae 100644 --- a/compiler/testData/diagnostics/tests/scopes/inheritance/statics/localVsStatic.fir.kt +++ b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/localVsStatic.fir.kt @@ -21,7 +21,7 @@ fun test() { class B: A() { init { - val a: Int = foo() // todo + val a: Int = foo() // todo } } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/resolvePropertyInitializerWithoutPrimary.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/resolvePropertyInitializerWithoutPrimary.fir.kt index c49f6814c5e..ed8a7fff121 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/resolvePropertyInitializerWithoutPrimary.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/resolvePropertyInitializerWithoutPrimary.fir.kt @@ -1,4 +1,4 @@ class A { - val prop: Int = "" + val prop: Int = "" constructor() } diff --git a/compiler/testData/diagnostics/tests/smartCasts/inference/intersectionTypes.fir.kt b/compiler/testData/diagnostics/tests/smartCasts/inference/intersectionTypes.fir.kt index 7d242f7cdd9..1a5d2bf5272 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/inference/intersectionTypes.fir.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/inference/intersectionTypes.fir.kt @@ -31,7 +31,7 @@ fun test(a: A, b: B, c: C) { val k = three(a, b, c) checkSubtype(k) checkSubtype(k) - val l: Int = three(a, b, c) + val l: Int = three(a, b, c) use(d, e, f, g, h, k, l) } diff --git a/compiler/testData/diagnostics/tests/smartCasts/safecalls/anotherVal.fir.kt b/compiler/testData/diagnostics/tests/smartCasts/safecalls/anotherVal.fir.kt index c8e1e81570d..d66fc29153c 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/safecalls/anotherVal.fir.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/safecalls/anotherVal.fir.kt @@ -3,6 +3,6 @@ fun calc(x: List?, y: Int?): Int { x?.get(y!! - 1) // y!! above should not provide smart cast here - val yy: Int = y + val yy: Int = y return yy + (x?.size ?: 0) } diff --git a/compiler/testData/diagnostics/tests/subtyping/findClosestCorrespondingSupertype.fir.kt b/compiler/testData/diagnostics/tests/subtyping/findClosestCorrespondingSupertype.fir.kt index 30bd7887a92..f42d97e3c21 100644 --- a/compiler/testData/diagnostics/tests/subtyping/findClosestCorrespondingSupertype.fir.kt +++ b/compiler/testData/diagnostics/tests/subtyping/findClosestCorrespondingSupertype.fir.kt @@ -6,5 +6,5 @@ interface B : A, X fun foo(x: B) { // Checks that when checking subtypes we search closes corresponding constructor (e.g. with BFS) - val y: X = x + val y: X = x } diff --git a/compiler/testData/diagnostics/tests/typealias/privateInFile.fir.kt b/compiler/testData/diagnostics/tests/typealias/privateInFile.fir.kt index 9700eb28880..c61088d8286 100644 --- a/compiler/testData/diagnostics/tests/typealias/privateInFile.fir.kt +++ b/compiler/testData/diagnostics/tests/typealias/privateInFile.fir.kt @@ -6,16 +6,16 @@ private class C { private typealias TA = C private val test1: C = C() -private val test1co: C.Companion = C +private val test1co: C.Companion = C -private val test2: TA = TA() +private val test2: TA = TA() private val test2co = TA // FILE: file2.kt private val test1: C = C() -private val test1co: C.Companion = C +private val test1co: C.Companion = C -private val test2: TA = TA() +private val test2: TA = TA() private val test2co = TA private class C diff --git a/compiler/testData/diagnostics/tests/unsignedTypes/conversions/signedToUnsignedConversionWithExpectedType.fir.kt b/compiler/testData/diagnostics/tests/unsignedTypes/conversions/signedToUnsignedConversionWithExpectedType.fir.kt index 6be76f49a5b..e03a172049a 100644 --- a/compiler/testData/diagnostics/tests/unsignedTypes/conversions/signedToUnsignedConversionWithExpectedType.fir.kt +++ b/compiler/testData/diagnostics/tests/unsignedTypes/conversions/signedToUnsignedConversionWithExpectedType.fir.kt @@ -60,6 +60,6 @@ const val constVal = 10 val globalVariableWithGetter: Int get() = 0 -val prop: UByte = 255 +val prop: UByte = 255 fun Int.myPlus(other: Int): Int = this + other diff --git a/compiler/testData/diagnostics/tests/unsignedTypes/explicitUnsignedLongTypeCheck.fir.kt b/compiler/testData/diagnostics/tests/unsignedTypes/explicitUnsignedLongTypeCheck.fir.kt index 61cad031fbd..90d8eabcea7 100644 --- a/compiler/testData/diagnostics/tests/unsignedTypes/explicitUnsignedLongTypeCheck.fir.kt +++ b/compiler/testData/diagnostics/tests/unsignedTypes/explicitUnsignedLongTypeCheck.fir.kt @@ -1,7 +1,7 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER -val a0: Int = 1uL -val a1: UInt = 1uL +val a0: Int = 1uL +val a1: UInt = 1uL val a3: ULong = 1uL val a4 = 1UL + 2UL val a5 = -1UL diff --git a/compiler/testData/diagnostics/tests/unsignedTypes/unsignedLiteralsOverflowSignedBorder.fir.kt b/compiler/testData/diagnostics/tests/unsignedTypes/unsignedLiteralsOverflowSignedBorder.fir.kt index 42681aac5b8..c5bb0fa8aa4 100644 --- a/compiler/testData/diagnostics/tests/unsignedTypes/unsignedLiteralsOverflowSignedBorder.fir.kt +++ b/compiler/testData/diagnostics/tests/unsignedTypes/unsignedLiteralsOverflowSignedBorder.fir.kt @@ -21,5 +21,5 @@ fun test() { takeUByte(0xFFu) } -val s1: UByte = 256u +val s1: UByte = 256u val s2 = 18446744073709551616u diff --git a/compiler/testData/diagnostics/tests/unsignedTypes/unsignedLiteralsTypeCheck.fir.kt b/compiler/testData/diagnostics/tests/unsignedTypes/unsignedLiteralsTypeCheck.fir.kt index 95efec7db89..f35926bf4f7 100644 --- a/compiler/testData/diagnostics/tests/unsignedTypes/unsignedLiteralsTypeCheck.fir.kt +++ b/compiler/testData/diagnostics/tests/unsignedTypes/unsignedLiteralsTypeCheck.fir.kt @@ -1,7 +1,7 @@ val a0: Any = 1u -val n0: Number = 1u +val n0: Number = 1u val c0: Comparable<*> = 1u val c1: Comparable = 1u @@ -11,7 +11,7 @@ val u1: UInt? = 1u val u2: UInt? = u0 val u3: UInt? = u1 -val i0: Int = 1u +val i0: Int = 1u val m0 = -1u val m1: UInt = -1u diff --git a/compiler/testData/diagnostics/tests/when/kt9929.fir.kt b/compiler/testData/diagnostics/tests/when/kt9929.fir.kt index 99e8a97adf9..74a98288213 100644 --- a/compiler/testData/diagnostics/tests/when/kt9929.fir.kt +++ b/compiler/testData/diagnostics/tests/when/kt9929.fir.kt @@ -1,5 +1,5 @@ // !WITH_NEW_INFERENCE -val test: Int = if (true) { +val test: Int = if (true) { when (2) { 1 -> 1 else -> null @@ -7,4 +7,4 @@ val test: Int = if (true) { } else { 2 -} +} diff --git a/compiler/testData/diagnostics/tests/when/kt9972.fir.kt b/compiler/testData/diagnostics/tests/when/kt9972.fir.kt index 779a4c0b0ab..cccc3ce4314 100644 --- a/compiler/testData/diagnostics/tests/when/kt9972.fir.kt +++ b/compiler/testData/diagnostics/tests/when/kt9972.fir.kt @@ -21,9 +21,9 @@ fun test1(): Int { } fun test2(): Int { - val x: String = when { + val x: String = when { true -> Any() else -> null - } ?: return 0 + } ?: return 0 return x.hashCode() } diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/suspendCallsWithErrors.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/suspendCallsWithErrors.fir.kt index 7da1401ab2a..bfb426348a6 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/suspendCallsWithErrors.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/suspendCallsWithErrors.fir.kt @@ -19,6 +19,6 @@ val test1 = generate { yield(A) } -val test2: Int = generate { +val test2: Int = generate { yield(A()) -} +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.fir.kt index dc723a5ed63..dd639f20b89 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.fir.kt @@ -18,7 +18,7 @@ public fun Map.get1(key: Any?): Int = null!! public fun <@kotlin.internal.OnlyInputTypes K, V> Map.get1(key: K): V? = null!! fun test(map: Map) { - val a: Int = listOf(1).contains1("") + val a: Int = listOf(1).contains1("") val b: Boolean = listOf(1).contains1(1) val c: String? = map.get1("") diff --git a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/maps.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/maps.fir.kt index 26697f2a424..3e7f0ce0212 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/maps.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/maps.fir.kt @@ -26,8 +26,8 @@ fun hashMapTest() { val b4: Map = x val b5: Map = x - val b6: Int = x[""] - val b7: Int = x.get("") + val b6: Int = x[""] + val b7: Int = x.get("") val b8: Int? = x.get("") } @@ -50,8 +50,8 @@ fun treeMapTest() { val b4: Map = x val b5: Map = x - val b6: Int = x[""] - val b7: Int = x.get("") + val b6: Int = x[""] + val b7: Int = x.get("") val b8: Int? = x.get("") } @@ -74,8 +74,8 @@ fun concurrentHashMapTest() { val b4: Map = x val b5: Map = x - val b6: Int = x[""] - val b7: Int = x.get("") + val b6: Int = x[""] + val b7: Int = x.get("") val b8: Int? = x.get("") } diff --git a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/mapsWithNullableKey.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/mapsWithNullableKey.fir.kt index d139896edca..a6165a0767a 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/mapsWithNullableKey.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/mapsWithNullableKey.fir.kt @@ -23,11 +23,11 @@ fun hashMapTest() { val b2: MutableMap = x val b3: Map = x val b4: Map = x - val b5: Map = x + val b5: Map = x - val b6: Int = x[""] - val b7: Int = x[null] - val b8: Int = x.get("") + val b6: Int = x[""] + val b7: Int = x[null] + val b8: Int = x.get("") val b9: Int? = x.get("") } @@ -48,10 +48,10 @@ fun treeMapTest() { val b2: MutableMap = x val b3: Map = x val b4: Map = x - val b5: Map = x + val b5: Map = x - val b6: Int = x[""] - val b7: Int = x.get("") + val b6: Int = x[""] + val b7: Int = x.get("") val b8: Int? = x.get("") } diff --git a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/mapsWithNullableValues.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/mapsWithNullableValues.fir.kt index f06efd6038e..754fd19f4fb 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/mapsWithNullableValues.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/mapsWithNullableValues.fir.kt @@ -19,14 +19,14 @@ fun hashMapTest() { x[""] = nullableInt x[""] = 1 - val b1: MutableMap = x + val b1: MutableMap = x val b2: MutableMap = x - val b3: Map = x + val b3: Map = x val b4: Map = x val b5: Map = x - val b6: Int = x[""] - val b7: Int = x.get("") + val b6: Int = x[""] + val b7: Int = x.get("") val b8: Int? = x.get("") } @@ -43,14 +43,14 @@ fun treeMapTest() { x[""] = nullableInt x[""] = 1 - val b1: MutableMap = x + val b1: MutableMap = x val b2: MutableMap = x - val b3: Map = x + val b3: Map = x val b4: Map = x val b5: Map = x - val b6: Int = x[""] - val b7: Int = x.get("") + val b6: Int = x[""] + val b7: Int = x.get("") val b8: Int? = x.get("") } diff --git a/compiler/testData/diagnostics/testsWithStdLib/regression/ea70485_functionTypeInheritor.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/regression/ea70485_functionTypeInheritor.fir.kt index 8bcc67304aa..b2afdc72754 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/regression/ea70485_functionTypeInheritor.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/regression/ea70485_functionTypeInheritor.fir.kt @@ -13,5 +13,5 @@ fun test() { } fun test2() { - val f: Ext = {} + val f: Ext = {} } diff --git a/compiler/testData/diagnostics/testsWithStdLib/tryCatch/assignTry.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/tryCatch/assignTry.fir.kt index 641f7d94e6d..2c11962adef 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/tryCatch/assignTry.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/tryCatch/assignTry.fir.kt @@ -6,7 +6,7 @@ class ExcA : Exception() class ExcB : Exception() fun test2() { - val s: String? = try { + val s: String? = try { "" } catch (e: ExcA) { @@ -14,7 +14,7 @@ fun test2() { } catch (e: ExcB) { 10 - } + } s.length } diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/resolving-callable-references/resolving-callable-references-not-used-as-arguments-to-a-call/p-1/pos/1.3.fir.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/resolving-callable-references/resolving-callable-references-not-used-as-arguments-to-a-call/p-1/pos/1.3.fir.kt index 24ff5740dcb..b0c7e2e933c 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/resolving-callable-references/resolving-callable-references-not-used-as-arguments-to-a-call/p-1/pos/1.3.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/resolving-callable-references/resolving-callable-references-not-used-as-arguments-to-a-call/p-1/pos/1.3.fir.kt @@ -10,7 +10,8 @@ package testsCase1 class Case() { fun case(v: V) { - val va: () -> String = (V)::a + // InitializertTypeCheckerMismatch bug + val va: () -> String = (V)::a val vb: () -> String = (V)::b diff --git a/compiler/tests-spec/testData/diagnostics/linked/type-system/introduction-1/p-6/neg/2.1.fir.kt b/compiler/tests-spec/testData/diagnostics/linked/type-system/introduction-1/p-6/neg/2.1.fir.kt index f2d793d28de..77015dfce02 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/type-system/introduction-1/p-6/neg/2.1.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/type-system/introduction-1/p-6/neg/2.1.fir.kt @@ -4,32 +4,32 @@ // TESTCASE NUMBER: 1 fun case_1() { - val x: Int = null + val x: Int = null } // TESTCASE NUMBER: 2 fun case_2() { - val x: Any = null + val x: Any = null } // TESTCASE NUMBER: 3 fun case_3() { - val x: Nothing = null + val x: Nothing = null } // TESTCASE NUMBER: 4 fun case_4() { - var x: Int = null + var x: Int = null } // TESTCASE NUMBER: 5 fun case_5() { - var x: Any = null + var x: Any = null } // TESTCASE NUMBER: 6 fun case_6() { - var x: Nothing = null + var x: Nothing = null } // TESTCASE NUMBER: 7 @@ -47,7 +47,7 @@ fun case_8() { // TESTCASE NUMBER: 9 fun case_9() { val x = null - val y: Int = x + val y: Int = x } // TESTCASE NUMBER: 10 diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/13.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/13.fir.kt index f167a08ef89..3efe850ab52 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/13.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/13.fir.kt @@ -12,7 +12,7 @@ fun case_1(x: Class?) { // TESTCASE NUMBER: 2 fun case_2() { - var x: Class? = 10 + var x: Class? = 10 x!! x(if (true) {x=null;0} else 0, x) x diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/30.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/30.fir.kt index dbef0bc6f61..c2d04c6db1d 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/30.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/30.fir.kt @@ -5,23 +5,23 @@ // TESTCASE NUMBER: 1 class Case1(val x: Any?) { val y = x!! - val z: Any = x + val z: Any = x } // TESTCASE NUMBER: 2 class Case2(val y: Any?): ClassWithCostructorParam(y!!) { - val z: Any = y + val z: Any = y } // TESTCASE NUMBER: 3 class Case3(val y: Any?): ClassWithCostructorParam(y as Class) { - val z: Class = y + val z: Class = y } // TESTCASE NUMBER: 4 class Case4(val y: Any?): ClassWithCostructorParam(y!!) { init { - val z: Any = y + val z: Any = y } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/72.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/72.fir.kt index f2e83290499..00c243f8d15 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/72.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/72.fir.kt @@ -13,5 +13,5 @@ fun case_1() { val strs = list as MutableList strs.add("two") & kotlin.collections.MutableList & kotlin.collections.MutableList")!>list - val s: String = & kotlin.collections.MutableList & kotlin.collections.MutableList")!>list[0] + val s: String = & kotlin.collections.MutableList & kotlin.collections.MutableList")!>list[0] } diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt index 3258521c4b1..4820e812538 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt @@ -1430,6 +1430,14 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert token, ) } + add(FirErrors.INITIALIZER_TYPE_MISMATCH) { firDiagnostic -> + InitializerTypeMismatchImpl( + firSymbolBuilder.typeBuilder.buildKtType(firDiagnostic.a), + firSymbolBuilder.typeBuilder.buildKtType(firDiagnostic.b), + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } add(FirErrors.EXPECTED_DECLARATION_WITH_BODY) { firDiagnostic -> ExpectedDeclarationWithBodyImpl( firDiagnostic as FirPsiDiagnostic<*>, diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt index 446d85e68a2..506e88683c9 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt @@ -1011,6 +1011,12 @@ sealed class KtFirDiagnostic : KtDiagnosticWithPsi { abstract val actualType: KtType } + abstract class InitializerTypeMismatch : KtFirDiagnostic() { + override val diagnosticClass get() = InitializerTypeMismatch::class + abstract val expected: KtType + abstract val actual: KtType + } + abstract class ExpectedDeclarationWithBody : KtFirDiagnostic() { override val diagnosticClass get() = ExpectedDeclarationWithBody::class } diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt index 3a077237440..d537c8b0a45 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt @@ -1636,6 +1636,15 @@ internal class WrongSetterParameterTypeImpl( override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) } +internal class InitializerTypeMismatchImpl( + override val expected: KtType, + override val actual: KtType, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.InitializerTypeMismatch(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) +} + internal class ExpectedDeclarationWithBodyImpl( firDiagnostic: FirPsiDiagnostic<*>, override val token: ValidityToken, diff --git a/idea/testData/checker/QualifiedExpressions.fir.kt b/idea/testData/checker/QualifiedExpressions.fir.kt index 5c0943fb1a7..d277b0b0839 100644 --- a/idea/testData/checker/QualifiedExpressions.fir.kt +++ b/idea/testData/checker/QualifiedExpressions.fir.kt @@ -3,7 +3,7 @@ package qualified_expressions fun test(s: IntRange?) { - val a: Int = s?.start + val a: Int = s?.start val b: Int? = s?.start val c: Int = s?.start ?: -11 val d: Int = s?.start ?: "empty" diff --git a/idea/testData/checker/UnreachableCode.fir.kt b/idea/testData/checker/UnreachableCode.fir.kt index fc2c1c9f4db..58f223a0966 100644 --- a/idea/testData/checker/UnreachableCode.fir.kt +++ b/idea/testData/checker/UnreachableCode.fir.kt @@ -4,7 +4,7 @@ fun t1() : Int{ } fun t1a() : Int { - return + return return 1 1 } @@ -17,7 +17,7 @@ fun t1b() : Int { fun t1c() : Int { return 1 - return + return 1 } diff --git a/idea/testData/checker/Variance.fir.kt b/idea/testData/checker/Variance.fir.kt index bae418ec31d..efc008e760b 100644 --- a/idea/testData/checker/Variance.fir.kt +++ b/idea/testData/checker/Variance.fir.kt @@ -7,13 +7,13 @@ abstract class Producer {} abstract class Usual {} fun foo(c: Consumer, p: Producer, u: Usual) { - val c1: Consumer = c + val c1: Consumer = c val c2: Consumer = c1 val p1: Producer = p val p2: Producer = p1 - val u1: Usual = u + val u1: Usual = u val u2: Usual = u1 } diff --git a/idea/testData/checker/regression/kt303.fir.kt b/idea/testData/checker/regression/kt303.fir.kt index 8a324d553b6..ac3cc5182cf 100644 --- a/idea/testData/checker/regression/kt303.fir.kt +++ b/idea/testData/checker/regression/kt303.fir.kt @@ -8,4 +8,4 @@ open class Bar() : FooFoo() diff --git a/idea/testData/checker/trivialHierarchyLoop.fir.kt b/idea/testData/checker/trivialHierarchyLoop.fir.kt index ac3602ab173..685438e8651 100644 --- a/idea/testData/checker/trivialHierarchyLoop.fir.kt +++ b/idea/testData/checker/trivialHierarchyLoop.fir.kt @@ -1,3 +1,3 @@ class A : A() {} -val x : Int = A() +val x : Int = A() diff --git a/jps-plugin/testData/incremental/classHierarchyAffected/propertyNullabilityChanged/fir-build.log b/jps-plugin/testData/incremental/classHierarchyAffected/propertyNullabilityChanged/fir-build.log deleted file mode 100644 index 72e0d088492..00000000000 --- a/jps-plugin/testData/incremental/classHierarchyAffected/propertyNullabilityChanged/fir-build.log +++ /dev/null @@ -1,18 +0,0 @@ -================ Step #1 ================= - -Compiling files: - src/A.kt - src/AChild.kt - src/useAChild.kt -End of files -Exit code: OK - -================ Step #2 ================= - -Compiling files: - src/A.kt - src/AChild.kt - src/useAChild.kt -End of files -Exit code: OK -