From f374eec8f1c6e4dc1f8503ddef2b1922140b38c7 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 21 Apr 2015 18:32:31 +0200 Subject: [PATCH] deprecating types after colon --- .../jetbrains/kotlin/diagnostics/Errors.java | 4 +-- .../rendering/DefaultErrorMessages.java | 2 +- .../BasicExpressionTypingVisitor.java | 3 +- compiler/testData/diagnostics/tests/Casts.kt | 22 ++++++------ .../testData/diagnostics/tests/Constants.kt | 28 ++++++++------- .../diagnostics/tests/ForRangeConventions.kt | 4 ++- .../tests/FunctionCalleeExpressions.kt | 6 ++-- .../tests/GenericFunctionIsLessSpecific.kt | 6 ++-- .../diagnostics/tests/LValueAssignment.kt | 13 +------ .../diagnostics/tests/ResolveToJava.kt | 6 ++-- .../testData/diagnostics/tests/UnitValue.kt | 4 ++- .../tests/annotations/kt1860-negative.kt | 2 +- .../tests/annotations/kt1860-positive.kt | 2 +- .../diagnostics/tests/cast/bare/AsNullable.kt | 4 ++- .../tests/cast/bare/AsNullableNotEnough.kt | 4 ++- .../diagnostics/tests/cast/bare/EitherAs.kt | 6 ++-- .../tests/cast/bare/EitherSafeAs.kt | 6 ++-- .../tests/cast/bare/ErrorsInSubstitution.kt | 4 ++- .../tests/cast/bare/FromErrorType.kt | 6 ++-- .../diagnostics/tests/cast/bare/NullableAs.kt | 4 ++- .../tests/cast/bare/NullableAsNotEnough.kt | 4 ++- .../tests/cast/bare/NullableAsNullable.kt | 4 ++- .../cast/bare/NullableAsNullableNotEnough.kt | 4 ++- .../tests/cast/bare/UnrelatedAs.kt | 4 ++- .../tests/cast/bare/UnrelatedColon.kt | 4 ++- .../tests/checkArguments/SpreadVarargs.kt | 20 ++++++----- .../testData/diagnostics/tests/checkType.kt | 6 ++-- .../diagnostics/tests/classObjects/kt3866.kt | 5 ++- .../typeInferenceForExclExcl.kt | 8 ++--- .../componentFunctionInSubClass.kt | 6 ++-- .../tests/dataClasses/firstParamIsVal.kt | 4 ++- .../tests/dataClasses/firstParamIsVar.kt | 4 ++- .../tests/dataClasses/multiDeclaration.kt | 6 ++-- .../tests/dataClasses/multiDeclarationFor.kt | 6 ++-- .../tests/dataClasses/oneValParam.kt | 4 ++- .../tests/dataClasses/secondParamIsVal.kt | 4 ++- .../tests/dataClasses/secondParamIsVar.kt | 4 ++- .../tests/dataClasses/twoValParams.kt | 6 ++-- .../tests/dataClasses/twoVarParams.kt | 6 ++-- .../diagnostics/tests/dataFlow/EmptyIf.kt | 12 ++++--- .../tests/dataFlow/assignment/kt6118.kt | 2 +- .../dataFlowInfoTraversal/ArrayExpression.kt | 4 ++- .../ArrayGetSetConvention.kt | 14 ++++---- .../dataFlowInfoTraversal/ArrayIndices.kt | 6 ++-- .../AssignmentOperation.kt | 8 +++-- .../AssignmentToArrayElement.kt | 6 ++-- .../BinaryExpressionBooleanOperations.kt | 10 +++--- .../BinaryExpressionCompareToConvention.kt | 6 ++-- .../BinaryExpressionContainsConvention.kt | 4 ++- .../BinaryExpressionElvis.kt | 6 ++-- .../BinaryExpressionEqualsConvention.kt | 6 ++-- .../BinaryExpressionIdentifier.kt | 6 ++-- .../BinaryExpressionPlusConvention.kt | 6 ++-- .../tests/dataFlowInfoTraversal/Condition.kt | 6 ++-- .../ContinueOuterLoop.kt | 16 +++++---- .../dataFlowInfoTraversal/DoWhileCondition.kt | 10 +++--- .../dataFlowInfoTraversal/ForLoopRange.kt | 6 ++-- .../dataFlowInfoTraversal/IfStatement.kt | 20 ++++++----- .../dataFlowInfoTraversal/IsExpression.kt | 6 ++-- .../tests/dataFlowInfoTraversal/ManyIfs.kt | 6 ++-- .../dataFlowInfoTraversal/MultiDeclaration.kt | 6 ++-- .../dataFlowInfoTraversal/StringTemplate.kt | 6 ++-- .../tests/dataFlowInfoTraversal/TryFinally.kt | 8 +++-- .../dataFlowInfoTraversal/WhenEntryAs.kt | 14 ++++---- .../dataFlowInfoTraversal/WhenEntryIs.kt | 14 ++++---- .../tests/dataFlowInfoTraversal/WhenIn.kt | 6 ++-- .../dataFlowInfoTraversal/WhenSubject.kt | 6 ++-- .../dataFlowInfoTraversal/WhileCondition.kt | 12 ++++--- .../kt2631_MultipleDeclaration.kt | 14 ++++---- .../useCompleterWithoutExpectedType.kt | 4 ++- .../checkDeparenthesizedType.kt | 10 +++--- .../tests/enum/javaEnumValueOfMethod.kt | 3 +- .../tests/enum/javaEnumValuesMethod.kt | 3 +- .../tests/enum/javaEnumWithAbstractFun.kt | 3 +- .../tests/extensions/GenericIterator2.kt | 4 ++- .../tests/functionAsExpression/Common.kt | 5 +-- .../functionAsExpression/FunctionType.kt | 6 ++-- .../InferenceParametersTypes.kt | 5 +-- .../MissingParameterTypes.kt | 3 +- .../assignmentOperationInLambda.kt | 10 +++--- .../functionLIteralInBlockInIf.kt | 2 +- .../functionLiteralWithoutArgumentList.kt | 2 +- .../return/LocalAndNonLocalReturnInLambda.kt | 4 ++- .../LocalReturnExplicitLabelNoParens.kt | 4 ++- .../return/LocalReturnExplicitLabelParens.kt | 6 ++-- .../return/LocalReturnHasTypeNothing.kt | 4 ++- .../return/LocalReturnInNestedFunction.kt | 4 ++- .../return/LocalReturnInNestedLambda.kt | 4 ++- .../return/LocalReturnUnit.kt | 4 ++- .../return/MixedReturnsFromLambda.kt | 4 ++- .../diagnostics/tests/generics/Projections.kt | 4 ++- .../setterNotProjectedOutAssign.kt | 2 +- .../varProjection/setterProjectedOutAssign.kt | 2 +- .../capturedTypes/captureForNullableTypes.kt | 4 +-- .../capturedTypes/captureForPlatformTypes.kt | 8 ++--- .../captureFromNullableTypeVariable.kt | 4 +-- .../inference/capturedTypes/capturedType.kt | 4 +-- .../capturedTypeAndApproximation.kt | 4 +-- ...edTypeSubstitutedIntoOppositeProjection.kt | 4 +-- .../tests/inference/capturedTypes/kt2570.kt | 2 +- .../overApproximationForInCaptured.kt | 2 +- .../overApproximationForOutCaptured.kt | 2 +- .../completeInferenceIfManyFailed.kt | 4 ++- .../equalityConstraintOnNullableType.kt | 6 ++-- .../ignoreConstraintFromImplicitInNothing.kt | 8 ++--- .../notNullConstraintOnNullableType.kt | 2 +- .../subtypeConstraintOnNullableType.kt | 6 ++-- .../supertypeConstraintOnNullableType.kt | 6 ++-- .../tests/inference/dependOnExpectedType.kt | 22 ++++++------ .../inference/functionPlaceholderError.kt | 4 ++- .../tests/inference/listConstructor.kt | 8 +++-- .../tests/inference/mapFunction.kt | 10 +++--- .../inference/mostSpecificAfterInference.kt | 6 ++-- .../inferenceForNestedBinaryCall.kt | 4 ++- .../tests/inference/regressions/kt1029.kt | 4 ++- .../tests/inference/regressions/kt1031.kt | 6 ++-- .../tests/inference/regressions/kt1145.kt | 4 ++- .../tests/inference/regressions/kt1410.kt | 4 ++- .../tests/inference/regressions/kt1718.kt | 6 ++-- .../tests/inference/regressions/kt1944.kt | 4 ++- .../tests/inference/regressions/kt2179.kt | 8 +++-- .../tests/inference/regressions/kt2200.kt | 6 ++-- .../tests/inference/regressions/kt2294.kt | 4 ++- .../tests/inference/regressions/kt2324.kt | 6 ++-- .../tests/inference/regressions/kt2407.kt | 6 ++-- .../tests/inference/regressions/kt2505.kt | 4 ++- .../tests/inference/regressions/kt731.kt | 4 ++- .../tests/inference/regressions/kt943.kt | 4 ++- .../tests/inference/regressions/kt948.kt | 6 ++-- .../conflictingSubstitutionsFromUpperBound.kt | 4 ++- .../upperBounds/intersectUpperBounds.kt | 6 ++-- .../diagnostics/tests/inline/parenthesized.kt | 6 ++-- .../diagnostics/tests/inline/recursion.kt | 3 +- .../diagnostics/tests/inline/typed.kt | 21 ----------- .../diagnostics/tests/inline/typed.txt | 5 --- ...gumentsNullability-NotNull-SpecialTypes.kt | 3 +- ...eArgumentsNullability-NotNull-UserTypes.kt | 3 +- .../testData/diagnostics/tests/j+k/kt2394.kt | 12 ++++--- .../testData/diagnostics/tests/j+k/kt2641.kt | 4 ++- .../tests/jdk-annotations/ArrayListAndMap.kt | 15 ++++---- .../tests/jdk-annotations/ArrayListClone.kt | 4 ++- .../tests/jdk-annotations/ArrayListToArray.kt | 3 +- .../jdk-annotations/sql/DriverManager.kt | 14 ++++---- .../tests/jdk-annotations/sql/ResultSet.kt | 4 ++- .../tests/jdk-annotations/sql/Statement.kt | 6 ++-- .../nullabilityAndSmartCasts/AssertNotNull.kt | 6 ++-- .../tests/nullabilityAndSmartCasts/kt1778.kt | 3 +- .../tests/nullabilityAndSmartCasts/kt2176.kt | 14 ++++---- .../tests/nullabilityAndSmartCasts/kt2234.kt | 10 +++--- .../numbers/doublesInSimpleConstraints.kt | 8 +++-- .../numbers/numbersInSimpleConstraints.kt | 16 ++++----- .../tests/objects/localObjectInsideObject.kt | 4 ++- .../commonSupertype/withNothing.kt | 4 +-- .../tests/platformTypes/dereference.kt | 4 ++- .../explicitFlexibleNoPackage.kt | 4 +-- .../explicitFlexibleWithPackage.kt | 4 +-- .../tests/platformTypes/inference.kt | 4 ++- .../platformTypes/intVsIntegerAmbiguity.kt | 7 ++-- .../tests/platformTypes/intersection/map.kt | 1 + .../platformTypes/methodCall/objectArray.kt | 1 + .../nullabilityWarnings/expectedType.kt | 14 ++++---- .../tests/platformTypes/safeCall.kt | 2 +- .../diagnostics/tests/regressions/Jet53.kt | 3 +- .../diagnostics/tests/regressions/kt334.kt | 6 ++-- .../senselessComparison/parenthesized.kt | 8 ----- .../smartCasts/inference/intersectionTypes.kt | 16 +++++---- .../diagnostics/tests/smartCasts/kt5455.kt | 8 ++--- .../loops/assignWhenInsideWhileTrue.kt | 4 ++- .../loops/plusAssignWhenInsideDoWhile.kt | 6 ++-- .../tests/substitutions/starProjections.kt | 8 ++--- .../diagnostics/tests/subtyping/kt-1457.kt | 4 ++- .../tests/suppress/manyWarnings/mixed.kt | 2 +- .../tests/suppress/manyWarnings/onClass.kt | 2 +- .../suppress/manyWarnings/onClassObject.kt | 2 +- .../suppress/manyWarnings/onExpression.kt | 2 +- .../tests/suppress/manyWarnings/onFunction.kt | 2 +- .../tests/suppress/manyWarnings/onObject.kt | 2 +- .../suppress/manyWarnings/onParameter.kt | 2 +- .../tests/suppress/manyWarnings/onProperty.kt | 2 +- .../manyWarnings/onPropertyAccessor.kt | 2 +- .../thisAndSuper/thisInFunctionLiterals.kt | 18 +++++----- .../tests/thisAndSuper/thisInInnerClasses.kt | 10 +++--- .../tests/varargs/varargsAndOut1.kt | 6 ++-- .../tests/varargs/varargsAndPair.kt | 4 ++- .../dynamicTypes/dynamicCallsWithLambdas.kt | 4 ++- .../dynamicTypes/extensionVals.kt | 17 ++++----- .../dynamicTypes/extensionVars.kt | 17 ++++----- .../dynamicTypes/extensions.kt | 9 ++--- .../dynamicTypes/overloading.kt | 10 +++--- .../function/ambiguityTopLevelVsTopLevel.kt | 6 ++-- .../function/constructorFromClass.kt | 6 ++-- .../function/constructorFromExtension.kt | 6 ++-- .../constructorFromExtensionInClass.kt | 10 +++--- .../function/constructorFromTopLevel.kt | 4 ++- .../function/differentPackageClass.kt | 7 ++-- .../function/differentPackageExtension.kt | 3 +- .../function/differentPackageTopLevel.kt | 7 ++-- .../function/extensionFromClass.kt | 8 +++-- .../function/extensionFromExtension.kt | 8 +++-- .../function/extensionFromExtensionInClass.kt | 8 +++-- .../function/extensionFromTopLevel.kt | 8 +++-- .../function/extensionOnNullable.kt | 6 ++-- .../function/genericClassFromTopLevel.kt | 4 ++- .../function/innerConstructorFromClass.kt | 9 ++--- .../function/innerConstructorFromExtension.kt | 7 ++-- .../function/innerConstructorFromTopLevel.kt | 3 +- .../function/javaStaticMethod.kt | 3 +- .../function/localConstructor.kt | 4 ++- ...calConstructorFromExtensionInLocalClass.kt | 6 ++-- .../localConstructorFromLocalExtension.kt | 6 ++-- .../function/localNamedFun.kt | 8 +++-- .../localNamedFunFromExtensionInLocalClass.kt | 8 +++-- .../function/localNamedFunFromLocalClass.kt | 8 +++-- .../localNamedFunFromLocalExtension.kt | 8 +++-- .../function/longQualifiedName.kt | 3 +- .../function/longQualifiedNameGeneric.kt | 3 +- .../function/memberFromClass.kt | 8 +++-- .../function/memberFromExtension.kt | 8 +++-- .../function/memberFromExtensionInClass.kt | 8 +++-- .../function/memberFromTopLevel.kt | 8 +++-- .../function/nestedConstructorFromClass.kt | 9 ++--- .../nestedConstructorFromExtension.kt | 5 +-- .../function/nestedConstructorFromTopLevel.kt | 4 ++- .../function/noAmbiguityMemberVsExtension.kt | 4 ++- .../function/noAmbiguityMemberVsTopLevel.kt | 4 ++- .../function/renameOnImport.kt | 7 ++-- .../function/topLevelFromClass.kt | 8 +++-- .../function/topLevelFromExtension.kt | 8 +++-- .../function/topLevelFromExtensionInClass.kt | 8 +++-- .../function/topLevelFromTopLevel.kt | 8 +++-- .../property/abstractPropertyViaSubclasses.kt | 20 ++++++----- .../property/accessViaSubclass.kt | 6 ++-- .../property/classFromClass.kt | 6 ++-- .../property/extensionFromClass.kt | 6 ++-- .../property/extensionFromTopLevel.kt | 20 ++++++----- .../property/extensionPropertyOnNullable.kt | 6 ++-- .../property/genericClass.kt | 8 +++-- .../property/javaInstanceField.kt | 13 +++---- .../property/javaStaticFieldViaImport.kt | 14 ++++---- .../property/memberFromExtension.kt | 8 +++-- .../property/memberFromTopLevel.kt | 14 ++++---- .../samePriorityForFunctionsAndProperties.kt | 2 +- .../property/topLevelFromTopLevel.kt | 36 ++++++++++--------- .../inference/arrayConstructor.kt | 8 +++-- .../testsWithStdLib/inference/kt1558.kt | 12 ++++--- .../testsWithStdLib/varargs/kt3213.kt | 2 +- .../kotlin/checkers/BaseDiagnosticsTest.java | 6 ++-- .../checkers/JetDiagnosticsTestGenerated.java | 6 ---- .../kotlin/idea/JetBundle.properties | 1 - .../kotlin/idea/j2k/J2kPostProcessor.kt | 2 +- .../idea/quickfix/QuickFixRegistrar.java | 9 ++--- .../RemoveRightPartOfBinaryExpressionFix.java | 4 +-- ...ReplaceOperationInBinaryExpressionFix.java | 20 ----------- idea/testData/checker/Casts.kt | 22 ++++++------ idea/testData/checker/Constants.kt | 8 +++-- idea/testData/checker/ForRangeConventions.kt | 4 ++- .../checker/QualifiedThisInClosures.kt | 22 ++++++------ idea/testData/checker/ResolveToJava.kt | 6 ++-- idea/testData/checker/Unused.kt | 1 - idea/testData/checker/regression/Jet53.kt | 4 ++- .../ScopeForSecondaryConstructors.kt | 32 +++++++++-------- .../afterRemoveStaticTypeAssertion.kt | 4 +++ ...afterReplaceUselessCastWithStaticAssert.kt | 4 --- .../beforeRemoveStaticTypeAssertion.kt | 4 +++ ...eforeReplaceUselessCastWithStaticAssert.kt | 4 --- .../typeMismatch/casts/beforeTypeMismatch5.kt | 5 --- .../beforeChangeFunctionParameterType4.kt | 3 +- .../idea/quickfix/QuickFixTestGenerated.java | 18 ++++------ 268 files changed, 1055 insertions(+), 769 deletions(-) delete mode 100644 compiler/testData/diagnostics/tests/inline/typed.kt delete mode 100644 compiler/testData/diagnostics/tests/inline/typed.txt create mode 100644 idea/testData/quickfix/expressions/afterRemoveStaticTypeAssertion.kt delete mode 100644 idea/testData/quickfix/expressions/afterReplaceUselessCastWithStaticAssert.kt create mode 100644 idea/testData/quickfix/expressions/beforeRemoveStaticTypeAssertion.kt delete mode 100644 idea/testData/quickfix/expressions/beforeReplaceUselessCastWithStaticAssert.kt delete mode 100644 idea/testData/quickfix/typeMismatch/casts/beforeTypeMismatch5.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index ea4daf612f3..6a738ebe9b3 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -569,7 +569,7 @@ public interface Errors { DiagnosticFactory1 CANNOT_CHECK_FOR_ERASED = DiagnosticFactory1.create(ERROR); DiagnosticFactory2 UNCHECKED_CAST = DiagnosticFactory2.create(WARNING); - DiagnosticFactory0 USELESS_CAST_STATIC_ASSERT_IS_FINE = DiagnosticFactory0.create(WARNING, AS_TYPE); + DiagnosticFactory0 DEPRECATED_STATIC_ASSERT = DiagnosticFactory0.create(WARNING, AS_TYPE); DiagnosticFactory0 USELESS_CAST = DiagnosticFactory0.create(WARNING, AS_TYPE); DiagnosticFactory0 CAST_NEVER_SUCCEEDS = DiagnosticFactory0.create(WARNING); DiagnosticFactory0 DYNAMIC_NOT_ALLOWED = DiagnosticFactory0.create(ERROR); @@ -673,7 +673,7 @@ public interface Errors { INVISIBLE_MEMBER, INVISIBLE_MEMBER_FROM_INLINE, INVISIBLE_REFERENCE, INVISIBLE_SETTER); ImmutableSet> UNUSED_ELEMENT_DIAGNOSTICS = ImmutableSet.of( UNUSED_VARIABLE, UNUSED_PARAMETER, ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE, VARIABLE_WITH_REDUNDANT_INITIALIZER, - UNUSED_FUNCTION_LITERAL, USELESS_CAST, USELESS_CAST_STATIC_ASSERT_IS_FINE); + UNUSED_FUNCTION_LITERAL, USELESS_CAST); ImmutableSet> TYPE_INFERENCE_ERRORS = ImmutableSet.of( TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER, TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS, TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH, TYPE_INFERENCE_UPPER_BOUND_VIOLATED, TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java index b996c98e725..13e975d5fa4 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -291,7 +291,7 @@ public class DefaultErrorMessages { MAP.put(ABSTRACT_SUPER_CALL, "Abstract member cannot be accessed directly"); MAP.put(NOT_A_SUPERTYPE, "Not a supertype"); MAP.put(TYPE_ARGUMENTS_REDUNDANT_IN_SUPER_QUALIFIER, "Type arguments do not need to be specified in a 'super' qualifier"); - MAP.put(USELESS_CAST_STATIC_ASSERT_IS_FINE, "No cast needed. You can use ':' if you need a cast to a super type"); + MAP.put(DEPRECATED_STATIC_ASSERT, "Static type assertions are deprecated, consider using a cast instead"); MAP.put(USELESS_CAST, "No cast needed"); MAP.put(CAST_NEVER_SUCCEEDS, "This cast can never succeed"); MAP.put(DYNAMIC_NOT_ALLOWED, "Dynamic types are not allowed in this position"); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java index 5a647c2c9a6..a2b7db1d10d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java @@ -212,6 +212,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { JetSimpleNameExpression operationSign = expression.getOperationReference(); IElementType operationType = operationSign.getReferencedNameElementType(); if (operationType == JetTokens.COLON) { + context.trace.report(DEPRECATED_STATIC_ASSERT.on(expression)); return; } if (operationType != JetTokens.AS_KEYWORD && operationType != JetTokens.AS_SAFE) { @@ -250,7 +251,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { expression.getLeft(), context.dataFlowInfo, actualType, context); for (JetType possibleType : possibleTypes) { if (typeChecker.isSubtypeOf(possibleType, targetType)) { - context.trace.report(USELESS_CAST_STATIC_ASSERT_IS_FINE.on(expression)); + context.trace.report(USELESS_CAST.on(expression)); return; } } diff --git a/compiler/testData/diagnostics/tests/Casts.kt b/compiler/testData/diagnostics/tests/Casts.kt index 31f02d508c8..45ef14d8a22 100644 --- a/compiler/testData/diagnostics/tests/Casts.kt +++ b/compiler/testData/diagnostics/tests/Casts.kt @@ -1,16 +1,18 @@ +// !CHECK_TYPE + fun test() : Unit { var x : Int? = 0 var y : Int = 0 - x : Int? - y : Int - x as Int : Int - y as Int : Int - x as Int? : Int? - y as Int? : Int? - x as? Int : Int? - y as? Int : Int? - x as? Int? : Int? - y as? Int? : Int? + checkSubtype(x) + checkSubtype(y) + checkSubtype(x as Int) + checkSubtype(y as Int) + checkSubtype(x as Int?) + checkSubtype(y as Int?) + checkSubtype(x as? Int) + checkSubtype(y as? Int) + checkSubtype(x as? Int?) + checkSubtype(y as? Int?) Unit } diff --git a/compiler/testData/diagnostics/tests/Constants.kt b/compiler/testData/diagnostics/tests/Constants.kt index f7a469b2944..ee10f8ba03e 100644 --- a/compiler/testData/diagnostics/tests/Constants.kt +++ b/compiler/testData/diagnostics/tests/Constants.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + fun varargByte(vararg v: Byte) = v fun varargShort(vararg v: Short) = v @@ -13,29 +15,29 @@ fun varargDouble(vararg v: Double) = v fun testFun(p: T) {} fun test() { - 1: Byte - 1: Short - 1: Int - 1: Long + checkSubtype(1) + checkSubtype(1) + checkSubtype(1) + checkSubtype(1) - 0x001: Long - 0b001: Int + checkSubtype(0x001) + checkSubtype(0b001) - 0.1: Double - 0.1.toFloat(): Float + checkSubtype(0.1) + checkSubtype(0.1.toFloat()) - 1e5: Double - 1e-5.toFloat(): Float + checkSubtype(1e5) + checkSubtype(1e-5.toFloat()) - 1: Double - 1: Float + checkSubtype(1) + checkSubtype(1) 1 as Byte 1 as Int 0xff as Long 1.1 as Int - 1.1: Int + checkSubtype(1.1) varargByte(0x77, 1, 3, 200, 0b111) varargShort(0x777, 1, 2, 3, 200000, 0b111) diff --git a/compiler/testData/diagnostics/tests/ForRangeConventions.kt b/compiler/testData/diagnostics/tests/ForRangeConventions.kt index 531c41b8104..f955f79ed6f 100644 --- a/compiler/testData/diagnostics/tests/ForRangeConventions.kt +++ b/compiler/testData/diagnostics/tests/ForRangeConventions.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + import java.util.*; class NotRange1() { @@ -87,5 +89,5 @@ fun test(notRange1: NotRange1, notRange2: NotRange2, notRange3: NotRange3, notRa for (i in range0); for (i in range1); - for (i in (ArrayList() : List)); + for (i in (checkSubtype>(ArrayList()))); } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.kt b/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.kt index 6673a17efb7..a107ef7196e 100644 --- a/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.kt +++ b/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + package foo fun Any.foo() : () -> Unit { @@ -38,10 +40,10 @@ fun main(args : Array) { foo2()({x -> }) val a = fooT1(1)() - a : Int + checkSubtype(a) val b = fooT2()(1) - b : Int + checkSubtype(b) fooT2()(1) // : Any? 1() diff --git a/compiler/testData/diagnostics/tests/GenericFunctionIsLessSpecific.kt b/compiler/testData/diagnostics/tests/GenericFunctionIsLessSpecific.kt index d7963a672d7..bc7ea2d0b1b 100644 --- a/compiler/testData/diagnostics/tests/GenericFunctionIsLessSpecific.kt +++ b/compiler/testData/diagnostics/tests/GenericFunctionIsLessSpecific.kt @@ -1,8 +1,10 @@ +// !CHECK_TYPE + // A generic funciton is always less specific than a non-generic one fun foo(t : T) : Unit {} fun foo(i : Int) : Int = 1 fun test() { - foo(1) : Int - foo("s") : Unit + checkSubtype(foo(1)) + checkSubtype(foo("s")) } diff --git a/compiler/testData/diagnostics/tests/LValueAssignment.kt b/compiler/testData/diagnostics/tests/LValueAssignment.kt index 22a6cc0711c..b9b6d5c165c 100644 --- a/compiler/testData/diagnostics/tests/LValueAssignment.kt +++ b/compiler/testData/diagnostics/tests/LValueAssignment.kt @@ -53,11 +53,9 @@ fun cannotBe() { fun canBe(i0: Int, j: Int) { var i = i0 - (i: Int) = 36 (label@ i) = 34 - (j: Int) = 36 - (label@ j) = 34 //repeat for j + (label@ j) = 34 //repeat for j val a = A() (l@ a.a) = 3894 @@ -74,20 +72,16 @@ class A() { class Test() { fun testIllegalValues() { 1 += 23 - (1 : Int) += 43 (l@ 1) += 23 getInt() += 343 (f@ getInt()) += 343 - (getInt() : Int) += 343 1++ (r@ 1)++ - (1 : Int)++ getInt()++ (m@ getInt())++ - (getInt() : Int)++ this++ @@ -103,13 +97,11 @@ class Test() { a += 34 (l@ a) += 34 - (a : Int) += 34 b += 34 a++ (l@ a)++ - (a : Int)++ (a)++ } @@ -118,7 +110,6 @@ class Test() { (l@ b) += 34 //repeat for b - (b : Int) += 34 (b) += 3 } @@ -131,8 +122,6 @@ class Test() { ab.getArray()[54]++ (f@ a)[3] = 4 - (a : Array)[4]++ - (ab.getArray() : Array)[54] += 43 this[54] = 34 } diff --git a/compiler/testData/diagnostics/tests/ResolveToJava.kt b/compiler/testData/diagnostics/tests/ResolveToJava.kt index 52a62db2613..cc583a3b7eb 100644 --- a/compiler/testData/diagnostics/tests/ResolveToJava.kt +++ b/compiler/testData/diagnostics/tests/ResolveToJava.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + // FILE: f.kt import java.* @@ -24,7 +26,7 @@ fun test(l : java.util Collections.emptyList() Collections.emptyList() - Collections.singleton(1) : Set? + checkSubtype?>(Collections.singleton(1)) Collections.singleton(1.0) List @@ -43,7 +45,7 @@ fun test(l : java.util val c : Com? = null - c : java.lang.Comparable? + checkSubtype<java.lang.Comparable?>(c) // Collections.sort(ArrayList()) xxx.Class() diff --git a/compiler/testData/diagnostics/tests/UnitValue.kt b/compiler/testData/diagnostics/tests/UnitValue.kt index d61e28efb25..b4d92bc704a 100644 --- a/compiler/testData/diagnostics/tests/UnitValue.kt +++ b/compiler/testData/diagnostics/tests/UnitValue.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + fun test() { - return Unit : Unit + return checkSubtype(Unit) } diff --git a/compiler/testData/diagnostics/tests/annotations/kt1860-negative.kt b/compiler/testData/diagnostics/tests/annotations/kt1860-negative.kt index 30c980161dc..a97b9c33187 100644 --- a/compiler/testData/diagnostics/tests/annotations/kt1860-negative.kt +++ b/compiler/testData/diagnostics/tests/annotations/kt1860-negative.kt @@ -3,7 +3,7 @@ fun foo(varargs f : Int) {} var bar : Int = 1 set(varargs v) {} -val x : (Int) -> Int = {[varargs] x : Int -> x} +val x : (Int) -> Int = {[varargs] x : Int -> x} class Hello(varargs args: Any) { } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/kt1860-positive.kt b/compiler/testData/diagnostics/tests/annotations/kt1860-positive.kt index ef085470b05..18694b06f0c 100644 --- a/compiler/testData/diagnostics/tests/annotations/kt1860-positive.kt +++ b/compiler/testData/diagnostics/tests/annotations/kt1860-positive.kt @@ -5,7 +5,7 @@ fun foo(test f : Int) {} var bar : Int = 1 set(test v) {} -val x : (Int) -> Int = {[test] x : Int -> x} // todo fix parser annotation on lambda parameter +val x : (Int) -> Int = {[test] x : Int -> x} // todo fix parser annotation on lambda parameter class Hello(test args: Any) { } diff --git a/compiler/testData/diagnostics/tests/cast/bare/AsNullable.kt b/compiler/testData/diagnostics/tests/cast/bare/AsNullable.kt index 5f4a50757e4..87602183923 100644 --- a/compiler/testData/diagnostics/tests/cast/bare/AsNullable.kt +++ b/compiler/testData/diagnostics/tests/cast/bare/AsNullable.kt @@ -1,8 +1,10 @@ +// !CHECK_TYPE + trait Tr trait G : Tr fun test(tr: Tr) { val v = tr as G? // If v is not nullable, there will be a warning on this line: - v!!: G + checkSubtype>(v!!) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/cast/bare/AsNullableNotEnough.kt b/compiler/testData/diagnostics/tests/cast/bare/AsNullableNotEnough.kt index b64e30082ff..9069dbbbe10 100644 --- a/compiler/testData/diagnostics/tests/cast/bare/AsNullableNotEnough.kt +++ b/compiler/testData/diagnostics/tests/cast/bare/AsNullableNotEnough.kt @@ -1,8 +1,10 @@ +// !CHECK_TYPE + trait Tr trait G fun test(tr: Tr) { val v = tr as G? // If v is not nullable, there will be a warning on this line: - v!!: G<*> + checkSubtype>(v!!) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/cast/bare/EitherAs.kt b/compiler/testData/diagnostics/tests/cast/bare/EitherAs.kt index 968faf96531..4aa276049bd 100644 --- a/compiler/testData/diagnostics/tests/cast/bare/EitherAs.kt +++ b/compiler/testData/diagnostics/tests/cast/bare/EitherAs.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + trait Either trait Left: Either trait Right: Either @@ -7,10 +9,10 @@ class C2(val v2: Int) fun _as_left(e: Either): Any { val v = e as Left - return v: Left + return checkSubtype>(v) } fun _as_right(e: Either): Any { val v = e as Right - return v: Right + return checkSubtype>(v) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/cast/bare/EitherSafeAs.kt b/compiler/testData/diagnostics/tests/cast/bare/EitherSafeAs.kt index 8424a6e003a..3d018404418 100644 --- a/compiler/testData/diagnostics/tests/cast/bare/EitherSafeAs.kt +++ b/compiler/testData/diagnostics/tests/cast/bare/EitherSafeAs.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + trait Either trait Left: Either trait Right: Either @@ -7,10 +9,10 @@ class C2(val v2: Int) fun _as_left(e: Either): Any? { val v = e as? Left - return v: Left? + return checkSubtype?>(v) } fun _as_right(e: Either): Any? { val v = e as? Right - return v: Right? + return checkSubtype?>(v) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/cast/bare/ErrorsInSubstitution.kt b/compiler/testData/diagnostics/tests/cast/bare/ErrorsInSubstitution.kt index da98c968b35..7ab2e12040e 100644 --- a/compiler/testData/diagnostics/tests/cast/bare/ErrorsInSubstitution.kt +++ b/compiler/testData/diagnostics/tests/cast/bare/ErrorsInSubstitution.kt @@ -1,7 +1,9 @@ +// !CHECK_TYPE + trait B trait G: B fun f(p: B<Foo>): Any { val v = p as G - return v: G<*> + return checkSubtype>(v) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/cast/bare/FromErrorType.kt b/compiler/testData/diagnostics/tests/cast/bare/FromErrorType.kt index 2bf731e5a27..0a76ce0445c 100644 --- a/compiler/testData/diagnostics/tests/cast/bare/FromErrorType.kt +++ b/compiler/testData/diagnostics/tests/cast/bare/FromErrorType.kt @@ -1,6 +1,8 @@ +// !CHECK_TYPE + class G fun foo(p: P) { - val v = p as G? - v!!: G<*> + val v = p as G? + checkSubtype>(v!!) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/cast/bare/NullableAs.kt b/compiler/testData/diagnostics/tests/cast/bare/NullableAs.kt index 717bdc8627c..6b629938e4b 100644 --- a/compiler/testData/diagnostics/tests/cast/bare/NullableAs.kt +++ b/compiler/testData/diagnostics/tests/cast/bare/NullableAs.kt @@ -1,7 +1,9 @@ +// !CHECK_TYPE + trait Tr trait G : Tr fun test(tr: Tr?) { val v = tr as G - v: G + checkSubtype>(v) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/cast/bare/NullableAsNotEnough.kt b/compiler/testData/diagnostics/tests/cast/bare/NullableAsNotEnough.kt index a9ef3a458bf..97245e159ee 100644 --- a/compiler/testData/diagnostics/tests/cast/bare/NullableAsNotEnough.kt +++ b/compiler/testData/diagnostics/tests/cast/bare/NullableAsNotEnough.kt @@ -1,7 +1,9 @@ +// !CHECK_TYPE + trait Tr trait G fun test(tr: Tr?) { val v = tr as G - v: G<*> + checkSubtype>(v) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/cast/bare/NullableAsNullable.kt b/compiler/testData/diagnostics/tests/cast/bare/NullableAsNullable.kt index e48f070ccb5..fad623e937b 100644 --- a/compiler/testData/diagnostics/tests/cast/bare/NullableAsNullable.kt +++ b/compiler/testData/diagnostics/tests/cast/bare/NullableAsNullable.kt @@ -1,8 +1,10 @@ +// !CHECK_TYPE + trait Tr trait G : Tr fun test(tr: Tr?) { val v = tr as G? // If v is not nullable, there will be a warning on this line: - v!!: G + checkSubtype>(v!!) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/cast/bare/NullableAsNullableNotEnough.kt b/compiler/testData/diagnostics/tests/cast/bare/NullableAsNullableNotEnough.kt index a27bcbbef21..e144b0b6e0d 100644 --- a/compiler/testData/diagnostics/tests/cast/bare/NullableAsNullableNotEnough.kt +++ b/compiler/testData/diagnostics/tests/cast/bare/NullableAsNullableNotEnough.kt @@ -1,7 +1,9 @@ +// !CHECK_TYPE + trait Tr trait G fun test(tr: Tr?) { val v = tr as G? - v!!: G<*> + checkSubtype>(v!!) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/cast/bare/UnrelatedAs.kt b/compiler/testData/diagnostics/tests/cast/bare/UnrelatedAs.kt index 159aaca6d21..540732d157f 100644 --- a/compiler/testData/diagnostics/tests/cast/bare/UnrelatedAs.kt +++ b/compiler/testData/diagnostics/tests/cast/bare/UnrelatedAs.kt @@ -1,7 +1,9 @@ +// !CHECK_TYPE + trait Tr trait G fun test(tr: Tr) { val v = tr as G - v: G<*> + checkSubtype>(v) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/cast/bare/UnrelatedColon.kt b/compiler/testData/diagnostics/tests/cast/bare/UnrelatedColon.kt index 521d280cb1d..de85372d101 100644 --- a/compiler/testData/diagnostics/tests/cast/bare/UnrelatedColon.kt +++ b/compiler/testData/diagnostics/tests/cast/bare/UnrelatedColon.kt @@ -1,4 +1,6 @@ +// !CHECK_TYPE + trait Tr trait G -fun test(tr: Tr) = tr: G \ No newline at end of file +fun test(tr: Tr) = checkSubtype<G>(tr) \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/checkArguments/SpreadVarargs.kt b/compiler/testData/diagnostics/tests/checkArguments/SpreadVarargs.kt index 1c1ef66583f..783a1951a2c 100644 --- a/compiler/testData/diagnostics/tests/checkArguments/SpreadVarargs.kt +++ b/compiler/testData/diagnostics/tests/checkArguments/SpreadVarargs.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + fun array1(vararg a : T) = a fun main(args : Array) { @@ -52,23 +54,23 @@ fun main(args : Array) { joinG(a = *a, x = 1) val x1 = joinT(1, "2") - x1 : String? + checkSubtype(x1) val x2 = joinT(*1, "2") - x2 : String? + checkSubtype(x2) val x6 = joinT(1, *a) - x6 : String? + checkSubtype(x6) val x7 = joinT(1, *a, "3") - x7 : String? + checkSubtype(x7) val x8 = joinT(1, "4", *a, "3") - x8 : String? + checkSubtype(x8) val x9 = joinT(1, "4", *a) - x9 : String? + checkSubtype(x9) val x10 = joinT(1, "4", *a, *a, "3") - x10 : String? + checkSubtype(x10) val x11 = joinT(a = *a, x = 1) - x11 : String? + checkSubtype(x11) val x12 = joinT(x = 1, a = *a) - x12 : String? + checkSubtype(x12) } fun join(x : Int, vararg a : String) : String { diff --git a/compiler/testData/diagnostics/tests/checkType.kt b/compiler/testData/diagnostics/tests/checkType.kt index e9dc7d6ce1e..fb9ef7ae1e6 100644 --- a/compiler/testData/diagnostics/tests/checkType.kt +++ b/compiler/testData/diagnostics/tests/checkType.kt @@ -5,7 +5,7 @@ trait B : A trait C : B fun test(b: B) { - b checkType { it : _ } - b checkType { it : _ } - b checkType { it : _ } + b checkType { _() } + b checkType { _() } + b checkType { _() } } diff --git a/compiler/testData/diagnostics/tests/classObjects/kt3866.kt b/compiler/testData/diagnostics/tests/classObjects/kt3866.kt index f5e88e734f6..cfc76d155ca 100644 --- a/compiler/testData/diagnostics/tests/classObjects/kt3866.kt +++ b/compiler/testData/diagnostics/tests/classObjects/kt3866.kt @@ -15,7 +15,6 @@ fun bar() { val x = X x.foo() X.foo() - (X : C).foo() - (X as C).foo() - ((if (1<2) X else Y) : C).foo() + (X as C).foo() + ((if (1<2) X else Y) as C).foo() } diff --git a/compiler/testData/diagnostics/tests/controlStructures/typeInferenceForExclExcl.kt b/compiler/testData/diagnostics/tests/controlStructures/typeInferenceForExclExcl.kt index ebf365b3cd8..79ee9129ff9 100644 --- a/compiler/testData/diagnostics/tests/controlStructures/typeInferenceForExclExcl.kt +++ b/compiler/testData/diagnostics/tests/controlStructures/typeInferenceForExclExcl.kt @@ -11,10 +11,10 @@ fun exclExcl(t: T?): T = t!! fun test11() { // not 'String!' - exclExcl(A.foo()) checkType { it : _ } - exclExcl(A.foo()) checkType { it : _ } + exclExcl(A.foo()) checkType { _() } + exclExcl(A.foo()) checkType { _() } // not 'String!' - A.foo()!! checkType { it : _ } - A.foo()!! checkType { it : _ } + A.foo()!! checkType { _() } + A.foo()!! checkType { _() } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/dataClasses/componentFunctionInSubClass.kt b/compiler/testData/diagnostics/tests/dataClasses/componentFunctionInSubClass.kt index c57b6469d6f..0542c22cedc 100644 --- a/compiler/testData/diagnostics/tests/dataClasses/componentFunctionInSubClass.kt +++ b/compiler/testData/diagnostics/tests/dataClasses/componentFunctionInSubClass.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + open data class A(private val x: Int) class B : A(1) { @@ -6,6 +8,6 @@ class B : A(1) { fun foo() { val b = B() - b.component1() : String - (b : A).component1() : Int + checkSubtype(b.component1()) + checkSubtype((checkSubtype(b)).component1()) } diff --git a/compiler/testData/diagnostics/tests/dataClasses/firstParamIsVal.kt b/compiler/testData/diagnostics/tests/dataClasses/firstParamIsVal.kt index 0d5c4c0ad3f..881ddc7460d 100644 --- a/compiler/testData/diagnostics/tests/dataClasses/firstParamIsVal.kt +++ b/compiler/testData/diagnostics/tests/dataClasses/firstParamIsVal.kt @@ -1,6 +1,8 @@ +// !CHECK_TYPE + data class A(val x: Int, y: String) fun foo(a: A) { - a.component1() : Int + checkSubtype(a.component1()) a.component2() } diff --git a/compiler/testData/diagnostics/tests/dataClasses/firstParamIsVar.kt b/compiler/testData/diagnostics/tests/dataClasses/firstParamIsVar.kt index b64f6384ad9..4e66f1b80c0 100644 --- a/compiler/testData/diagnostics/tests/dataClasses/firstParamIsVar.kt +++ b/compiler/testData/diagnostics/tests/dataClasses/firstParamIsVar.kt @@ -1,6 +1,8 @@ +// !CHECK_TYPE + data class A(var x: Int, y: String) fun foo(a: A) { - a.component1() : Int + checkSubtype(a.component1()) a.component2() } diff --git a/compiler/testData/diagnostics/tests/dataClasses/multiDeclaration.kt b/compiler/testData/diagnostics/tests/dataClasses/multiDeclaration.kt index c9a8f39c3d0..803873a0464 100644 --- a/compiler/testData/diagnostics/tests/dataClasses/multiDeclaration.kt +++ b/compiler/testData/diagnostics/tests/dataClasses/multiDeclaration.kt @@ -1,7 +1,9 @@ +// !CHECK_TYPE + data class A(val x: Int, val y: String) fun foo(a: A) { val (b, c) = a - b : Int - c : String + checkSubtype(b) + checkSubtype(c) } diff --git a/compiler/testData/diagnostics/tests/dataClasses/multiDeclarationFor.kt b/compiler/testData/diagnostics/tests/dataClasses/multiDeclarationFor.kt index 415335c5ca8..ce7a01130e6 100644 --- a/compiler/testData/diagnostics/tests/dataClasses/multiDeclarationFor.kt +++ b/compiler/testData/diagnostics/tests/dataClasses/multiDeclarationFor.kt @@ -1,8 +1,10 @@ +// !CHECK_TYPE + data class A(val x: Int, val y: String) fun foo(arr: Array) { for ((b, c) in arr) { - b : Int - c : String + checkSubtype(b) + checkSubtype(c) } } diff --git a/compiler/testData/diagnostics/tests/dataClasses/oneValParam.kt b/compiler/testData/diagnostics/tests/dataClasses/oneValParam.kt index db488601a98..6b9054c630b 100644 --- a/compiler/testData/diagnostics/tests/dataClasses/oneValParam.kt +++ b/compiler/testData/diagnostics/tests/dataClasses/oneValParam.kt @@ -1,6 +1,8 @@ +// !CHECK_TYPE + data class A(val x: Int) fun foo(a: A) { - a.component1() : Int + checkSubtype(a.component1()) a.component2() } diff --git a/compiler/testData/diagnostics/tests/dataClasses/secondParamIsVal.kt b/compiler/testData/diagnostics/tests/dataClasses/secondParamIsVal.kt index cef2651808b..a4202f6b91b 100644 --- a/compiler/testData/diagnostics/tests/dataClasses/secondParamIsVal.kt +++ b/compiler/testData/diagnostics/tests/dataClasses/secondParamIsVal.kt @@ -1,6 +1,8 @@ +// !CHECK_TYPE + data class A(x: Int, val y: String) fun foo(a: A) { - a.component1() : String + checkSubtype(a.component1()) a.component2() } diff --git a/compiler/testData/diagnostics/tests/dataClasses/secondParamIsVar.kt b/compiler/testData/diagnostics/tests/dataClasses/secondParamIsVar.kt index 974d16a53f3..28effe82887 100644 --- a/compiler/testData/diagnostics/tests/dataClasses/secondParamIsVar.kt +++ b/compiler/testData/diagnostics/tests/dataClasses/secondParamIsVar.kt @@ -1,6 +1,8 @@ +// !CHECK_TYPE + data class A(x: Int, var y: String) fun foo(a: A) { - a.component1() : String + checkSubtype(a.component1()) a.component2() } diff --git a/compiler/testData/diagnostics/tests/dataClasses/twoValParams.kt b/compiler/testData/diagnostics/tests/dataClasses/twoValParams.kt index f6a1910fbc7..53228d514ad 100644 --- a/compiler/testData/diagnostics/tests/dataClasses/twoValParams.kt +++ b/compiler/testData/diagnostics/tests/dataClasses/twoValParams.kt @@ -1,6 +1,8 @@ +// !CHECK_TYPE + data class A(val x: Int, val y: String) fun foo(a: A) { - a.component1() : Int - a.component2() : String + checkSubtype(a.component1()) + checkSubtype(a.component2()) } diff --git a/compiler/testData/diagnostics/tests/dataClasses/twoVarParams.kt b/compiler/testData/diagnostics/tests/dataClasses/twoVarParams.kt index 459e9803734..d7d038aabc3 100644 --- a/compiler/testData/diagnostics/tests/dataClasses/twoVarParams.kt +++ b/compiler/testData/diagnostics/tests/dataClasses/twoVarParams.kt @@ -1,6 +1,8 @@ +// !CHECK_TYPE + data class A(var x: Int, var y: String) fun foo(a: A) { - a.component1() : Int - a.component2() : String + checkSubtype(a.component1()) + checkSubtype(a.component2()) } diff --git a/compiler/testData/diagnostics/tests/dataFlow/EmptyIf.kt b/compiler/testData/diagnostics/tests/dataFlow/EmptyIf.kt index 577933a818e..203d46f8e9c 100644 --- a/compiler/testData/diagnostics/tests/dataFlow/EmptyIf.kt +++ b/compiler/testData/diagnostics/tests/dataFlow/EmptyIf.kt @@ -1,18 +1,20 @@ +// !CHECK_TYPE + fun f1(s: String?) { if (s!! == ""); - s : String + checkSubtype(s) } fun f2(s: Number?) { if (s is Int); - s : Int + checkSubtype(s) if (s as Int == 42); - s : Int + checkSubtype(s) } fun f3(s: Number?) { - if (s is Int && s as Int == 42); - s : Int + if (s is Int && s as Int == 42); + checkSubtype(s) } fun f4(s: Int?) { diff --git a/compiler/testData/diagnostics/tests/dataFlow/assignment/kt6118.kt b/compiler/testData/diagnostics/tests/dataFlow/assignment/kt6118.kt index d281770dbfc..9f1f0d3b629 100644 --- a/compiler/testData/diagnostics/tests/dataFlow/assignment/kt6118.kt +++ b/compiler/testData/diagnostics/tests/dataFlow/assignment/kt6118.kt @@ -2,7 +2,7 @@ fun foo(o: Any) { if (o is String) { - val s = o as String + val s = o as String s.length() } } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayExpression.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayExpression.kt index 572fcaab3fa..afca19bc7fb 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayExpression.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayExpression.kt @@ -1,5 +1,7 @@ +// !CHECK_TYPE + fun foo(arr: Array): Int { val result = (arr as Array)[0] - arr : Array + checkSubtype>(arr) return result } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayGetSetConvention.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayGetSetConvention.kt index 56d4ea0f722..d1ed5a0eb2f 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayGetSetConvention.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayGetSetConvention.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + trait G { fun get(x: Int, y: Int): Int = x + y fun set(x: Int, y: Int, value: Int) {} @@ -5,22 +7,22 @@ trait G { fun foo1(a: Int?, b: G) { b[a!!, a!!] = a - a : Int + checkSubtype(a) } fun foo2(a: Int?, b: G) { b[0, a!!] = a - a : Int + checkSubtype(a) } fun foo3(a: Int?, b: G) { val r = b[a!!, a] - a : Int - r : Int + checkSubtype(a) + checkSubtype(r) } fun foo4(a: Int?, b: G) { val r = b[0, a!!] - a : Int - r : Int + checkSubtype(a) + checkSubtype(r) } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayIndices.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayIndices.kt index 59d3aaea55f..448975a5d4e 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayIndices.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayIndices.kt @@ -1,9 +1,11 @@ +// !CHECK_TYPE + fun foo1(a: Int?, b: Array>) { b[a!!][a!!] = a - a : Int + checkSubtype(a) } fun foo2(a: Int?, b: Array>) { b[0][a!!] = a - a : Int + checkSubtype(a) } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AssignmentOperation.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AssignmentOperation.kt index 0b34ad4bc3a..49de1b1b215 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AssignmentOperation.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AssignmentOperation.kt @@ -1,15 +1,17 @@ +// !CHECK_TYPE + fun bar1(x: Number, y: Int) { var yy = y yy += x as Int - x : Int + checkSubtype(x) } fun bar2(x: Number) { y += x as Int - x : Int + checkSubtype(x) } fun bar3(x: Number, y: Array) { y[0] += x as Int - x : Int + checkSubtype(x) } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AssignmentToArrayElement.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AssignmentToArrayElement.kt index 405104251a0..c2902af019e 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AssignmentToArrayElement.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AssignmentToArrayElement.kt @@ -1,10 +1,12 @@ +// !CHECK_TYPE + fun arrayAccessRHS(a: Int?, b: Array) { b[0] = a!! - a : Int + checkSubtype(a) } fun arrayAccessLHS(a: Int?, b: Array) { b[a!!] = a - a : Int + checkSubtype(a) } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionBooleanOperations.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionBooleanOperations.kt index 39068da4f01..df2a2d7d03c 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionBooleanOperations.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionBooleanOperations.kt @@ -1,23 +1,25 @@ +// !CHECK_TYPE + fun foo1(x: Number, cond: Boolean): Boolean { val result = cond && ((x as Int) == 42) - x : Int + checkSubtype(x) return result } fun foo2(x: Number, cond: Boolean): Boolean { val result = ((x as Int) == 42) && cond - x : Int + checkSubtype(x) return result } fun foo3(x: Number, cond: Boolean): Boolean { val result = cond || ((x as Int) == 42) - x : Int + checkSubtype(x) return result } fun foo4(x: Number, cond: Boolean): Boolean { val result = ((x as Int) == 42) || cond - x : Int + checkSubtype(x) return result } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionCompareToConvention.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionCompareToConvention.kt index b4fece49f41..e4d901c387f 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionCompareToConvention.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionCompareToConvention.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + trait A trait B : A @@ -5,12 +7,12 @@ fun B.compareTo(b: B) = if (this == b) 0 else 1 fun foo(a: A): Boolean { val result = (a as B) < a - a : B + checkSubtype(a) return result } fun bar(a: A, b: B): Boolean { val result = b < (a as B) - a : B + checkSubtype(a) return result } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionContainsConvention.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionContainsConvention.kt index 3680c265b1f..7c7fa0b7ffa 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionContainsConvention.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionContainsConvention.kt @@ -1,5 +1,7 @@ +// !CHECK_TYPE + fun foo(x: Number): Boolean { val result = (x as Int) in 1..5 - x : Int + checkSubtype(x) return result } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionElvis.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionElvis.kt index 14227f0a67e..feb5ed4bb0f 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionElvis.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionElvis.kt @@ -1,14 +1,16 @@ +// !CHECK_TYPE + fun foo(x: Int?): Int = x!! fun elvis(x: Number?): Int { val result = (x as Int?) ?: foo(x) - x : Int? + checkSubtype(x) return result } fun elvisWithRHSTypeInfo(x: Number?): Any? { val result = x ?: x!! - x : Int? + checkSubtype(x) return result } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionEqualsConvention.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionEqualsConvention.kt index 4adddf691f5..312009ea0a0 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionEqualsConvention.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionEqualsConvention.kt @@ -1,14 +1,16 @@ +// !CHECK_TYPE + trait A trait B : A fun foo1(a: A, b: B): Boolean { val result = (a as B) == b - a : B + checkSubtype(a) return result } fun foo2(a: A, b: B): Boolean { val result = b == (a as B) - a : B + checkSubtype(a) return result } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionIdentifier.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionIdentifier.kt index 943152a0bcf..8e4be6efa34 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionIdentifier.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionIdentifier.kt @@ -1,11 +1,13 @@ +// !CHECK_TYPE + fun foo(a: Number): Int { val result = (a as Int) compareTo a - a : Int + checkSubtype(a) return result } fun bar(a: Number): Int { val result = 42 compareTo (a as Int) - a : Int + checkSubtype(a) return result } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionPlusConvention.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionPlusConvention.kt index b7b92b21f11..36551a1ca38 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionPlusConvention.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionPlusConvention.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + trait A trait B : A @@ -5,12 +7,12 @@ fun B.plus(b: B) = if (this == b) b else this fun foo(a: A): B { val result = (a as B) + a - a : B + checkSubtype(a) return result } fun bar(a: A, b: B): B { val result = b + (a as B) - a : B + checkSubtype(a) return result } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Condition.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Condition.kt index 64cb0b8e5ce..e83a9da3dda 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Condition.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Condition.kt @@ -1,5 +1,7 @@ +// !CHECK_TYPE + fun foo(x: Int?): Boolean { - val result = ((x!! == 0) && ((x : Int) == 0)) - x : Int + val result = ((x!! == 0) && (checkSubtype(x) == 0)) + checkSubtype(x) return result } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ContinueOuterLoop.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ContinueOuterLoop.kt index 4ca5193eb55..ae0036f268c 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ContinueOuterLoop.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ContinueOuterLoop.kt @@ -1,11 +1,13 @@ +// !CHECK_TYPE + fun whileLoop(x: Int?) { outer@ while (x != 0) { while (x != 1) { if (x == 2) continue@outer } - x : Int + checkSubtype(x) } - x : Int + checkSubtype(x) } fun doWhileLoop(x: Int?) { @@ -13,9 +15,9 @@ fun doWhileLoop(x: Int?) { do { if (x == 2) continue@outer } while (x == null) - x : Int + checkSubtype(x) } - x : Int + checkSubtype(x) } fun whileLoopContinueInnerOuter(x: Int?) { @@ -24,9 +26,9 @@ fun whileLoopContinueInnerOuter(x: Int?) { while (x != 2) { if (x == 3) continue@inner } - x : Int + checkSubtype(x) } - x : Int + checkSubtype(x) } - x : Int + checkSubtype(x) } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/DoWhileCondition.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/DoWhileCondition.kt index 6d85cb19179..8e26f02b1ca 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/DoWhileCondition.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/DoWhileCondition.kt @@ -1,18 +1,20 @@ +// !CHECK_TYPE + fun simpleDoWhile(x: Int?, y0: Int) { var y = y0 do { - x : Int? + checkSubtype(x) y++ } while (x!! == y) - x : Int + checkSubtype(x) } fun doWhileWithBreak(x: Int?, y0: Int) { var y = y0 do { - x : Int? + checkSubtype(x) y++ if (y > 0) break } while (x!! == y) - x : Int + checkSubtype(x) } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ForLoopRange.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ForLoopRange.kt index 5b32726f253..27419fccd29 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ForLoopRange.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ForLoopRange.kt @@ -1,6 +1,8 @@ +// !CHECK_TYPE + fun foo(arr: Array?) { for (x in arr!!) { - arr : Array + checkSubtype>(arr) } - arr : Array + checkSubtype>(arr) } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IfStatement.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IfStatement.kt index b8f5a43301c..13cafc48518 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IfStatement.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IfStatement.kt @@ -1,29 +1,31 @@ +// !CHECK_TYPE + fun ifThen(x: Int?) { if (x!! == 0) { - x : Int + checkSubtype(x) } - x : Int + checkSubtype(x) } fun ifElse(x: Int?) { if (x!! == 0) else { - x : Int + checkSubtype(x) } - x : Int + checkSubtype(x) } fun ifThenElse(x: Int?) { if (x!! == 0) { - x : Int + checkSubtype(x) } else { - x : Int + checkSubtype(x) } - x : Int + checkSubtype(x) } fun ifIs(x: Int?, cond: Boolean) { if ((x is Int) == cond) { - x : Int + checkSubtype(x) } - x : Int + checkSubtype(x) } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IsExpression.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IsExpression.kt index ee120013df8..e011bce3a25 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IsExpression.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IsExpression.kt @@ -1,6 +1,8 @@ +// !CHECK_TYPE + fun foo(x: Number) { if ((x as Int) is Int) { - x : Int + checkSubtype(x) } - x : Int + checkSubtype(x) } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ManyIfs.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ManyIfs.kt index a655e41ce4d..495fc431acc 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ManyIfs.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ManyIfs.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + fun noUselessDataFlowInfoCreation(x: Number) { if (x is Int) { if (x is Int) { if (x is Int) { if (x is Int) { if (x is Int) { if (x is Int) { if (x is Int) { if (x is Int) { if (x is Int) { if (x is Int) { @@ -14,7 +16,7 @@ fun dataFlowInfoAnd(a: Array) { if (a[15] is Int) { if (a[16] is Int) { if (a[17] is Int) { if (a[18] is Int) { if (a[19] is Int) { if (a[20] is Int) { if (a[21] is Int) { if (a[22] is Int) { if (a[23] is Int) { if (a[24] is Int) { if (a[25] is Int) { if (a[26] is Int) { if (a[27] is Int) { if (a[28] is Int) { if (a[29] is Int) { - a[0] : Int + checkSubtype(a[0]) } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } @@ -25,6 +27,6 @@ fun dataFlowInfoOr(a: Array) { a[30] is Int || a[31] is Int || a[32] is Int || a[33] is Int || a[34] is Int || a[35] is Int || a[36] is Int || a[37] is Int || a[38] is Int || a[39] is Int || a[40] is Int || a[41] is Int || a[42] is Int || a[43] is Int || a[44] is Int || a[45] is Int || a[46] is Int || a[47] is Int || a[48] is Int || a[49] is Int || a[50] is Int || a[51] is Int || a[52] is Int || a[53] is Int || a[54] is Int || a[55] is Int || a[56] is Int || a[57] is Int || a[58] is Int || a[59] is Int) { - a[0] : Int + checkSubtype(a[0]) } } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/MultiDeclaration.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/MultiDeclaration.kt index a28ebfe7470..4fb155a6dbf 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/MultiDeclaration.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/MultiDeclaration.kt @@ -1,7 +1,9 @@ +// !CHECK_TYPE + fun Int.component1() = "a" fun foo(a: Number) { val (x) = a as Int - a : Int - x : String + checkSubtype(a) + checkSubtype(x) } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/StringTemplate.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/StringTemplate.kt index 0f5474db069..d111d58de90 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/StringTemplate.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/StringTemplate.kt @@ -1,6 +1,8 @@ +// !CHECK_TYPE + fun foo(x: Number, y: String?): String { val result = "abcde $x ${x as Int} ${y!!} $x $y" - x : Int - y : String + checkSubtype(x) + checkSubtype(y) return result } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/TryFinally.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/TryFinally.kt index 3f6a229abd8..942b277301c 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/TryFinally.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/TryFinally.kt @@ -1,9 +1,11 @@ +// !CHECK_TYPE + fun tryFinally(x: Int?) { try { } finally { x!! } - x : Int + checkSubtype(x) } fun tryCatchFinally(x: Int?) { @@ -12,8 +14,8 @@ fun tryCatchFinally(x: Int?) { } catch (e: Exception) { x!! } finally { - x : Int + checkSubtype(x) x!! } - x : Int + checkSubtype(x) } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenEntryAs.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenEntryAs.kt index 6f866247204..c58cbaf51c9 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenEntryAs.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenEntryAs.kt @@ -1,24 +1,26 @@ +// !CHECK_TYPE + fun foo(x: Number, y: Int) { when (x) { - x as Int -> x : Int + x as Int -> checkSubtype(x) y -> {} else -> {} } - x : Int + checkSubtype(x) } fun bar(x: Number) { when (x) { - x as Int -> x : Int + x as Int -> checkSubtype(x) else -> {} } - x : Int + checkSubtype(x) } fun whenWithoutSubject(x: Number) { when { - (x as Int) == 42 -> x : Int + (x as Int) == 42 -> checkSubtype(x) else -> {} } - x : Int + checkSubtype(x) } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenEntryIs.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenEntryIs.kt index 03e51598f51..87e7a1afcdf 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenEntryIs.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenEntryIs.kt @@ -1,24 +1,26 @@ +// !CHECK_TYPE + fun foo(x: Number, y: Int) { when (x) { - is Int -> x : Int + is Int -> checkSubtype(x) y -> {} else -> {} } - x : Int + checkSubtype(x) } fun bar(x: Number) { when (x) { - is Int -> x : Int + is Int -> checkSubtype(x) else -> {} } - x : Int + checkSubtype(x) } fun whenWithoutSubject(x: Number) { when { - (x is Int) -> x : Int + (x is Int) -> checkSubtype(x) else -> {} } - x : Int + checkSubtype(x) } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenIn.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenIn.kt index 3575b724e14..fecc317132c 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenIn.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenIn.kt @@ -1,13 +1,15 @@ +// !CHECK_TYPE + fun foo(x: Int, list: List?) { when (x) { - in list!! -> list : List + in list!! -> checkSubtype>(list) else -> {} } } fun whenWithoutSubject(x: Int, list: List?) { when { - x in list!! -> list : List + x in list!! -> checkSubtype>(list) else -> {} } } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenSubject.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenSubject.kt index aa44561114d..5ee1f4b0b77 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenSubject.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenSubject.kt @@ -1,6 +1,8 @@ +// !CHECK_TYPE + fun foo(x: Number) { when (x as Int) { - else -> x : Int + else -> checkSubtype(x) } - x : Int + checkSubtype(x) } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhileCondition.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhileCondition.kt index d91467a51a2..aab06479c25 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhileCondition.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhileCondition.kt @@ -1,24 +1,26 @@ +// !CHECK_TYPE + fun simpleWhile(x: Int?, y0: Int) { var y = y0 while (x!! == y) { - x : Int + checkSubtype(x) y++ } - x : Int + checkSubtype(x) } fun whileWithBreak(x: Int?, y0: Int) { var y = y0 while (x!! == y) { - x : Int + checkSubtype(x) break } - x : Int + checkSubtype(x) } fun whileWithNoCondition(x: Int?) { while () { x!! } - x : Int + checkSubtype(x) } diff --git a/compiler/testData/diagnostics/tests/declarationChecks/kt2631_MultipleDeclaration.kt b/compiler/testData/diagnostics/tests/declarationChecks/kt2631_MultipleDeclaration.kt index b1a7426ccc3..ffdb4c3963e 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/kt2631_MultipleDeclaration.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/kt2631_MultipleDeclaration.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + //KT-2631 Check multiple assignment package a @@ -12,14 +14,14 @@ fun MyClass2.component1() = 1.2 fun test(mc1: MyClass, mc2: MyClass2) { val (a, b) = mc1 - a : Int - b : String + checkSubtype(a) + checkSubtype(b) val (c) = mc2 - c : Double + checkSubtype(c) //check no error types - a : Boolean - b : Boolean - c : Boolean + checkSubtype(a) + checkSubtype(b) + checkSubtype(c) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/inference/useCompleterWithoutExpectedType.kt b/compiler/testData/diagnostics/tests/delegatedProperty/inference/useCompleterWithoutExpectedType.kt index 1c54cf3159a..b5d3ad8167b 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/inference/useCompleterWithoutExpectedType.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/inference/useCompleterWithoutExpectedType.kt @@ -1,8 +1,10 @@ +// !CHECK_TYPE + class A { val a by MyProperty() fun test() { - a: Int + checkSubtype(a) } } diff --git a/compiler/testData/diagnostics/tests/deparenthesize/checkDeparenthesizedType.kt b/compiler/testData/diagnostics/tests/deparenthesize/checkDeparenthesizedType.kt index a5752076b26..138537e348f 100644 --- a/compiler/testData/diagnostics/tests/deparenthesize/checkDeparenthesizedType.kt +++ b/compiler/testData/diagnostics/tests/deparenthesize/checkDeparenthesizedType.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + package m fun test(i: Int?) { @@ -10,14 +12,14 @@ fun test(i: Int?) { val a: Int = l4@ "" val b: Int = ("") - val c: Int = "": Int - val d: Int = "": Long + val c: Int = checkSubtype("") + val d: Int = checkSubtype("") foo(l4@ "") foo(("")) - foo("": Int) - foo("": Long) + foo(checkSubtype("")) + foo(checkSubtype("")) use(a, b, c, d) } diff --git a/compiler/testData/diagnostics/tests/enum/javaEnumValueOfMethod.kt b/compiler/testData/diagnostics/tests/enum/javaEnumValueOfMethod.kt index aef7c30e4e6..971bb3fec1e 100644 --- a/compiler/testData/diagnostics/tests/enum/javaEnumValueOfMethod.kt +++ b/compiler/testData/diagnostics/tests/enum/javaEnumValueOfMethod.kt @@ -1,3 +1,4 @@ +// !CHECK_TYPE // FILE: A.java public enum A { ENTRY; @@ -5,5 +6,5 @@ public enum A { // FILE: test.kt fun main() { - A.valueOf("ENTRY"): A + checkSubtype(A.valueOf("ENTRY")) } diff --git a/compiler/testData/diagnostics/tests/enum/javaEnumValuesMethod.kt b/compiler/testData/diagnostics/tests/enum/javaEnumValuesMethod.kt index 57ea1b043bd..6089eef7c3c 100644 --- a/compiler/testData/diagnostics/tests/enum/javaEnumValuesMethod.kt +++ b/compiler/testData/diagnostics/tests/enum/javaEnumValuesMethod.kt @@ -1,3 +1,4 @@ +// !CHECK_TYPE // FILE: A.java public enum A { ENTRY, @@ -6,5 +7,5 @@ public enum A { // FILE: test.kt fun main() { - A.values(): Array + checkSubtype>(A.values()) } diff --git a/compiler/testData/diagnostics/tests/enum/javaEnumWithAbstractFun.kt b/compiler/testData/diagnostics/tests/enum/javaEnumWithAbstractFun.kt index 4eba037009e..1caca2c1e0d 100644 --- a/compiler/testData/diagnostics/tests/enum/javaEnumWithAbstractFun.kt +++ b/compiler/testData/diagnostics/tests/enum/javaEnumWithAbstractFun.kt @@ -1,3 +1,4 @@ +// !CHECK_TYPE // FILE: A.java public enum A { @@ -11,5 +12,5 @@ public enum A { // FILE: test.kt fun main() { - A.ENTRY.s(): String? + checkSubtype(A.ENTRY.s()) } diff --git a/compiler/testData/diagnostics/tests/extensions/GenericIterator2.kt b/compiler/testData/diagnostics/tests/extensions/GenericIterator2.kt index ca37d4b8b4f..2b8f42bee80 100644 --- a/compiler/testData/diagnostics/tests/extensions/GenericIterator2.kt +++ b/compiler/testData/diagnostics/tests/extensions/GenericIterator2.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + import java.util.Enumeration fun java.util.Enumeration.iterator() = object : Iterator { @@ -8,6 +10,6 @@ fun java.util.Enumeration.iterator() = object : Iterator { fun a(e : java.util.Enumeration) { for (i in e) { - i : Int + checkSubtype(i) } } diff --git a/compiler/testData/diagnostics/tests/functionAsExpression/Common.kt b/compiler/testData/diagnostics/tests/functionAsExpression/Common.kt index 134b0e17edf..61aea2fed72 100644 --- a/compiler/testData/diagnostics/tests/functionAsExpression/Common.kt +++ b/compiler/testData/diagnostics/tests/functionAsExpression/Common.kt @@ -1,3 +1,4 @@ +// !CHECK_TYPE // !DIAGNOSTICS: -UNUSED_PARAMETER annotation class ann(val name: String) @@ -16,5 +17,5 @@ val withExpression = fun() = 5 val funfun = fun() = fun() = 5 val parentesized = (fun () {}) -val parentesizedWithType = (fun () {}) : () -> Unit -val withType = (fun () {}) : () -> Unit +val parentesizedWithType = checkSubtype<() -> Unit>((fun () {})) +val withType = checkSubtype<() -> Unit>((fun () {})) diff --git a/compiler/testData/diagnostics/tests/functionAsExpression/FunctionType.kt b/compiler/testData/diagnostics/tests/functionAsExpression/FunctionType.kt index d354d56b6ef..cf530e25af0 100644 --- a/compiler/testData/diagnostics/tests/functionAsExpression/FunctionType.kt +++ b/compiler/testData/diagnostics/tests/functionAsExpression/FunctionType.kt @@ -4,7 +4,7 @@ fun testReturnType(foo: String) { val bar = fun () = foo - bar.checkType { it : _<() -> String> } + bar.checkType { _<() -> String>() } val bas: () -> String = fun () = foo @@ -14,7 +14,7 @@ fun testReturnType(foo: String) { fun testParamType() { val bar = fun (bal: String){} - bar.checkType { it : _<(String) -> Unit> } + bar.checkType { _<(String) -> Unit>() } val bas: (String) -> Unit = fun (param: String) {} val bag: (Int) -> Unit = fun (param: String) {} @@ -23,7 +23,7 @@ fun testParamType() { fun testReceiverType() { val bar = fun String.() {} - bar.checkType { it : _ Unit> } + bar.checkType { _ Unit>() } val bas: String.() -> Unit = fun String.() {} diff --git a/compiler/testData/diagnostics/tests/functionAsExpression/InferenceParametersTypes.kt b/compiler/testData/diagnostics/tests/functionAsExpression/InferenceParametersTypes.kt index c55cc070498..092a6cd0a81 100644 --- a/compiler/testData/diagnostics/tests/functionAsExpression/InferenceParametersTypes.kt +++ b/compiler/testData/diagnostics/tests/functionAsExpression/InferenceParametersTypes.kt @@ -1,3 +1,4 @@ +// !CHECK_TYPE // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE fun listOf(): List = null!! @@ -6,13 +7,13 @@ fun test(a: (Int) -> Int) { test(fun (x) = x) - test(fun (x): Int { x: Int; return 4 }) + test(fun (x): Int { checkSubtype(x); return 4 }) } fun test2(a: () -> List) { test2(fun () = listOf()) } -val a: (Int) -> Unit = fun(x) { x: Int } +val a: (Int) -> Unit = fun(x) { checkSubtype(x) } val b: (Int) -> Unit = fun(x: String) {} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/functionAsExpression/MissingParameterTypes.kt b/compiler/testData/diagnostics/tests/functionAsExpression/MissingParameterTypes.kt index 15ef022f0ac..bf88e014f19 100644 --- a/compiler/testData/diagnostics/tests/functionAsExpression/MissingParameterTypes.kt +++ b/compiler/testData/diagnostics/tests/functionAsExpression/MissingParameterTypes.kt @@ -1,3 +1,4 @@ +// !CHECK_TYPE // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE val a = fun (x) = x @@ -13,7 +14,7 @@ val e: (Int, String) -> Int = fun Int = fun (x: String) = 3 fun test1(a: (Int) -> Unit) { - test1(fun (x) { x : Int}) + test1(fun (x) { checkSubtype(x)}) } fun test2(a: (Int) -> Unit) { diff --git a/compiler/testData/diagnostics/tests/functionLiterals/assignmentOperationInLambda.kt b/compiler/testData/diagnostics/tests/functionLiterals/assignmentOperationInLambda.kt index 2661582261b..8f57632a957 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/assignmentOperationInLambda.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/assignmentOperationInLambda.kt @@ -1,16 +1,18 @@ +// !CHECK_TYPE + fun test(bal: Array) { var bar = 4 val a = { bar += 4 } - a : () -> Unit + checkSubtype<() -> Unit>(a) val b = { bar = 4 } - b : () -> Unit + checkSubtype<() -> Unit>(b) val c = { bal[2] = 3 } - c : () -> Unit + checkSubtype<() -> Unit>(c) val d = run { bar += 4 } - d : Unit + checkSubtype(d) } fun run(f: () -> T): T = f() \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/functionLiterals/functionLIteralInBlockInIf.kt b/compiler/testData/diagnostics/tests/functionLiterals/functionLIteralInBlockInIf.kt index c658d0c01e3..678ab68bc0c 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/functionLIteralInBlockInIf.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/functionLIteralInBlockInIf.kt @@ -6,5 +6,5 @@ fun test() { } else { { 2 } } - a checkType { it : _<() -> Int> } + a checkType { _<() -> Int>() } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/functionLiterals/functionLiteralWithoutArgumentList.kt b/compiler/testData/diagnostics/tests/functionLiterals/functionLiteralWithoutArgumentList.kt index 78190d17a22..ac3e89990a2 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/functionLiteralWithoutArgumentList.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/functionLiteralWithoutArgumentList.kt @@ -3,5 +3,5 @@ fun id(t: T) = t fun foo() { val i = id { 22 } //type inference error: no information for parameter - i checkType { it : _<()->Int> } + i checkType { _<()->Int>() } } diff --git a/compiler/testData/diagnostics/tests/functionLiterals/return/LocalAndNonLocalReturnInLambda.kt b/compiler/testData/diagnostics/tests/functionLiterals/return/LocalAndNonLocalReturnInLambda.kt index d09348af221..efe549ecc8b 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/return/LocalAndNonLocalReturnInLambda.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/return/LocalAndNonLocalReturnInLambda.kt @@ -1,9 +1,11 @@ +// !CHECK_TYPE + fun test2(a: Int) { val x = run f@{ if (a > 0) return return@f 1 } - x: Int + checkSubtype(x) } fun run(f: () -> T): T { return f() } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnExplicitLabelNoParens.kt b/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnExplicitLabelNoParens.kt index cef4371f341..8ec0f192f28 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnExplicitLabelNoParens.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnExplicitLabelNoParens.kt @@ -1,6 +1,8 @@ +// !CHECK_TYPE + fun test2() { val x = run f@{return@f 1} - x: Int + checkSubtype(x) } fun run(f: () -> T): T { return f() } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnExplicitLabelParens.kt b/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnExplicitLabelParens.kt index e341f7f9795..a2f5e58160e 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnExplicitLabelParens.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnExplicitLabelParens.kt @@ -1,12 +1,14 @@ +// !CHECK_TYPE + fun test() { val x = run(f@{return@f 1}) - x: Int + checkSubtype(x) } fun test1() { val x = run(l@{return@l 1}) - x: Int + checkSubtype(x) } fun run(f: () -> T): T { return f() } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnHasTypeNothing.kt b/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnHasTypeNothing.kt index 0f50172add9..b4bd539624f 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnHasTypeNothing.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnHasTypeNothing.kt @@ -1,6 +1,8 @@ +// !CHECK_TYPE + fun test() { run1 f@{ - (return@f 1): Nothing + checkSubtype(return@f 1) } } diff --git a/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnInNestedFunction.kt b/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnInNestedFunction.kt index ecbeb658bcf..ba5b786706d 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnInNestedFunction.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnInNestedFunction.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + fun test() { val x = run f@{ fun local(a: Int): String { @@ -6,7 +8,7 @@ fun test() { } return@f 1 } - x: Int + checkSubtype(x) } fun run(f: () -> T): T { return f() } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnInNestedLambda.kt b/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnInNestedLambda.kt index adae2dda1a1..1d2c596ee31 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnInNestedLambda.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnInNestedLambda.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + fun test() { val x = run f@{ run ff@ { @@ -5,7 +7,7 @@ fun test() { } return@f 1 } - x: Int + checkSubtype(x) } fun run(f: () -> T): T { return f() } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnUnit.kt b/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnUnit.kt index 7190ae4196d..00770c745ac 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnUnit.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnUnit.kt @@ -1,9 +1,11 @@ +// !CHECK_TYPE + fun test(a: Int) { val x = run f@{ if (a > 0) return@f else return@f Unit } - x: Unit + checkSubtype(x) } fun run(f: () -> T): T { return f() } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/functionLiterals/return/MixedReturnsFromLambda.kt b/compiler/testData/diagnostics/tests/functionLiterals/return/MixedReturnsFromLambda.kt index dff00a22525..6db7f204afb 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/return/MixedReturnsFromLambda.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/return/MixedReturnsFromLambda.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + trait A trait B: A trait C: A @@ -8,7 +10,7 @@ fun test(a: C, b: B) { if (a != b) return@f a b } - x: A + checkSubtype(x) } fun run(f: () -> T): T { return f() } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/generics/Projections.kt b/compiler/testData/diagnostics/tests/generics/Projections.kt index abb986a4a7a..d7dd8d9253d 100644 --- a/compiler/testData/diagnostics/tests/generics/Projections.kt +++ b/compiler/testData/diagnostics/tests/generics/Projections.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + class In() { fun f(t : T) : Unit {} fun f(t : Int) : Int = 1 @@ -43,7 +45,7 @@ fun testInOut() { (null as Inv<*>).inf(1) // !! Inv().outf() - (null as Inv).outf() : Int // Type mismatch + checkSubtype((null as Inv).outf()) // Type mismatch (null as Inv).outf() (null as Inv<*>).outf() diff --git a/compiler/testData/diagnostics/tests/generics/varProjection/setterNotProjectedOutAssign.kt b/compiler/testData/diagnostics/tests/generics/varProjection/setterNotProjectedOutAssign.kt index 4aa9cad51af..ad1faefeef0 100644 --- a/compiler/testData/diagnostics/tests/generics/varProjection/setterNotProjectedOutAssign.kt +++ b/compiler/testData/diagnostics/tests/generics/varProjection/setterNotProjectedOutAssign.kt @@ -5,5 +5,5 @@ trait Tr { fun test(t: Tr<*>) { t.v = t - t.v checkType { it : _> } + t.v checkType { _>() } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/generics/varProjection/setterProjectedOutAssign.kt b/compiler/testData/diagnostics/tests/generics/varProjection/setterProjectedOutAssign.kt index 0f2c6b5b154..781c69c09cc 100644 --- a/compiler/testData/diagnostics/tests/generics/varProjection/setterProjectedOutAssign.kt +++ b/compiler/testData/diagnostics/tests/generics/varProjection/setterProjectedOutAssign.kt @@ -7,5 +7,5 @@ trait Tr { fun test(t: Tr<*>) { t.v = null!! - t.v checkType { it : _ } + t.v checkType { _() } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/capturedTypes/captureForNullableTypes.kt b/compiler/testData/diagnostics/tests/inference/capturedTypes/captureForNullableTypes.kt index 32c88fd9626..b23a9f47b76 100644 --- a/compiler/testData/diagnostics/tests/inference/capturedTypes/captureForNullableTypes.kt +++ b/compiler/testData/diagnostics/tests/inference/capturedTypes/captureForNullableTypes.kt @@ -6,7 +6,7 @@ fun bar(a: Array): Array = null!! fun test1(a: Array) { val r: Array = bar(a) val t = bar(a) - t checkType { it : _> } + t checkType { _>() } } fun foo(l: Array): Array> = null!! @@ -14,5 +14,5 @@ fun foo(l: Array): Array> = null!! fun test2(a: Array) { val r: Array> = foo(a) val t = foo(a) - t checkType { it : _>> } + t checkType { _>>() } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/capturedTypes/captureForPlatformTypes.kt b/compiler/testData/diagnostics/tests/inference/capturedTypes/captureForPlatformTypes.kt index 5fc463b5d0a..bf9bdc4a1bd 100644 --- a/compiler/testData/diagnostics/tests/inference/capturedTypes/captureForPlatformTypes.kt +++ b/compiler/testData/diagnostics/tests/inference/capturedTypes/captureForPlatformTypes.kt @@ -15,15 +15,15 @@ public class A { fun test1(clazz: Class) { val foo0: Class = A.foo(clazz) val foo1 = A.foo(clazz) - foo1 checkType { it: _< Class > } + foo1 checkType { _< Class >() } // should be ok - foo1 checkType { it: _< Class > } + foo1 checkType { _< Class >() } } fun tes2t(clazz: Class) { val foo0: Class> = A.bar(clazz) val foo1 = A.bar(clazz) - foo1 checkType { it: _< Class> > } + foo1 checkType { _< Class> >() } // should be ok - foo1 checkType { it: _< Class> > } + foo1 checkType { _< Class> >() } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/capturedTypes/captureFromNullableTypeVariable.kt b/compiler/testData/diagnostics/tests/inference/capturedTypes/captureFromNullableTypeVariable.kt index 90bfdf8b7b3..02da1063d49 100644 --- a/compiler/testData/diagnostics/tests/inference/capturedTypes/captureFromNullableTypeVariable.kt +++ b/compiler/testData/diagnostics/tests/inference/capturedTypes/captureFromNullableTypeVariable.kt @@ -4,10 +4,10 @@ fun Array.filterNotNull(): List = throw Exception() fun test1(a: Array) { val list = a.filterNotNull() - list checkType { it : _> } + list checkType { _>() } } fun test2(vararg a: Int?) { val list = a.filterNotNull() - list checkType { it : _> } + list checkType { _>() } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/capturedTypes/capturedType.kt b/compiler/testData/diagnostics/tests/inference/capturedTypes/capturedType.kt index a3b06dddff0..1cee3fe84e8 100644 --- a/compiler/testData/diagnostics/tests/inference/capturedTypes/capturedType.kt +++ b/compiler/testData/diagnostics/tests/inference/capturedTypes/capturedType.kt @@ -6,11 +6,11 @@ fun foo(array: Array): Array = array fun test1(a1: Array) { val b1: Array = foo(a1) val c1 = foo(a1) - c1 checkType { it : _> } + c1 checkType { _>() } } fun test2(a2: Array) { val b2: Array = foo(a2) val c2 = foo(a2) - c2 checkType { it : _> } + c2 checkType { _>() } } diff --git a/compiler/testData/diagnostics/tests/inference/capturedTypes/capturedTypeAndApproximation.kt b/compiler/testData/diagnostics/tests/inference/capturedTypes/capturedTypeAndApproximation.kt index 669d7db8b8c..42689ae47fb 100644 --- a/compiler/testData/diagnostics/tests/inference/capturedTypes/capturedTypeAndApproximation.kt +++ b/compiler/testData/diagnostics/tests/inference/capturedTypes/capturedTypeAndApproximation.kt @@ -6,11 +6,11 @@ fun foo(a: Array): Array> = throw Exception() fun test1(a1: Array) { val b1: Array> = foo(a1) val c1 = foo(a1) - c1 checkType { it : _>> } + c1 checkType { _>>() } } fun test2(a2: Array) { val b2: Array> = foo(a2) val c2 = foo(a2) - c2 checkType { it : _>> } + c2 checkType { _>>() } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/capturedTypes/capturedTypeSubstitutedIntoOppositeProjection.kt b/compiler/testData/diagnostics/tests/inference/capturedTypes/capturedTypeSubstitutedIntoOppositeProjection.kt index e64ae9c4613..42a2080473b 100644 --- a/compiler/testData/diagnostics/tests/inference/capturedTypes/capturedTypeSubstitutedIntoOppositeProjection.kt +++ b/compiler/testData/diagnostics/tests/inference/capturedTypes/capturedTypeSubstitutedIntoOppositeProjection.kt @@ -4,11 +4,11 @@ fun foo1(a1: Array, a2: Array): T = null!! fun test1(a1: Array, a2: Array) { - foo1(a1, a2) checkType { it : _ } + foo1(a1, a2) checkType { _() } } fun foo2(a1: Array, a2: Array): T = null!! fun test2(a1: Array, a2: Array) { - foo2(a1, a2) checkType { it : _} + foo2(a1, a2) checkType { _() } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/capturedTypes/kt2570.kt b/compiler/testData/diagnostics/tests/inference/capturedTypes/kt2570.kt index 9f65199bb2d..30e3508c4fb 100644 --- a/compiler/testData/diagnostics/tests/inference/capturedTypes/kt2570.kt +++ b/compiler/testData/diagnostics/tests/inference/capturedTypes/kt2570.kt @@ -5,5 +5,5 @@ fun foo(l: MutableList): MutableList = l fun test(l: MutableList) { val a: MutableList = foo(l) val b = foo(l) - b checkType { it: _< MutableList > } + b checkType { _< MutableList >() } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/capturedTypes/overApproximationForInCaptured.kt b/compiler/testData/diagnostics/tests/inference/capturedTypes/overApproximationForInCaptured.kt index 139f01f98b6..5d69f03f96e 100644 --- a/compiler/testData/diagnostics/tests/inference/capturedTypes/overApproximationForInCaptured.kt +++ b/compiler/testData/diagnostics/tests/inference/capturedTypes/overApproximationForInCaptured.kt @@ -4,5 +4,5 @@ fun foo(a: Array): T = null!! fun test(a: Array) { - foo(a) checkType { it : _ } + foo(a) checkType { _() } } diff --git a/compiler/testData/diagnostics/tests/inference/capturedTypes/overApproximationForOutCaptured.kt b/compiler/testData/diagnostics/tests/inference/capturedTypes/overApproximationForOutCaptured.kt index 4efbf29e4a7..33a5f8da396 100644 --- a/compiler/testData/diagnostics/tests/inference/capturedTypes/overApproximationForOutCaptured.kt +++ b/compiler/testData/diagnostics/tests/inference/capturedTypes/overApproximationForOutCaptured.kt @@ -4,5 +4,5 @@ fun foo(a: Array): T = null!! fun test(a: Array) { - foo(a) checkType { it : _ } + foo(a) checkType { _() } } diff --git a/compiler/testData/diagnostics/tests/inference/completeInferenceIfManyFailed.kt b/compiler/testData/diagnostics/tests/inference/completeInferenceIfManyFailed.kt index b20162b20d9..e6a4dff7637 100644 --- a/compiler/testData/diagnostics/tests/inference/completeInferenceIfManyFailed.kt +++ b/compiler/testData/diagnostics/tests/inference/completeInferenceIfManyFailed.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + package d fun joinT(x: Int, vararg a: T): T? { @@ -10,6 +12,6 @@ fun joinT(x: Any, y: T): fun test() { val x2 = joinT(*1, "2") - x2 : String? + checkSubtype(x2) } diff --git a/compiler/testData/diagnostics/tests/inference/constraints/equalityConstraintOnNullableType.kt b/compiler/testData/diagnostics/tests/inference/constraints/equalityConstraintOnNullableType.kt index b458c7e80a9..b85f61691c5 100644 --- a/compiler/testData/diagnostics/tests/inference/constraints/equalityConstraintOnNullableType.kt +++ b/compiler/testData/diagnostics/tests/inference/constraints/equalityConstraintOnNullableType.kt @@ -8,13 +8,13 @@ fun doA(a: A): T = throw Exception("$a") fun test(a: A, aN: A) { val aa = doA(aN) - aa checkType { it : _ } + aa checkType { _() } val nullable = foo(aN, aN) //T = Int?, T? = Int? => T = Int? - nullable checkType { it : _ } + nullable checkType { _() } val notNullable = foo(a, aN) //T = Int, T? = Int? => T = Int - notNullable checkType { it : _ } + notNullable checkType { _() } } diff --git a/compiler/testData/diagnostics/tests/inference/constraints/ignoreConstraintFromImplicitInNothing.kt b/compiler/testData/diagnostics/tests/inference/constraints/ignoreConstraintFromImplicitInNothing.kt index 8a53fcbb03a..8adaa83b7eb 100644 --- a/compiler/testData/diagnostics/tests/inference/constraints/ignoreConstraintFromImplicitInNothing.kt +++ b/compiler/testData/diagnostics/tests/inference/constraints/ignoreConstraintFromImplicitInNothing.kt @@ -7,9 +7,9 @@ fun foo1(f: (T) -> Unit): Foo = Foo() inline fun foo2(f: (T) -> Unit): Foo = Foo() fun test1() { - val f1: Foo = foo1 { it checkType { it : _ } } - val f2: Foo = foo1 { it checkType { it : _ } } + val f1: Foo = foo1 { it checkType { _() } } + val f2: Foo = foo1 { it checkType { _() } } - val f3: Foo = foo2 { it checkType { it : _ } } - val f4: Foo = foo2 { it checkType { it : _ } } + val f3: Foo = foo2 { it checkType { _() } } + val f4: Foo = foo2 { it checkType { _() } } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/constraints/notNullConstraintOnNullableType.kt b/compiler/testData/diagnostics/tests/inference/constraints/notNullConstraintOnNullableType.kt index 4691a4e3e27..901e59115a4 100644 --- a/compiler/testData/diagnostics/tests/inference/constraints/notNullConstraintOnNullableType.kt +++ b/compiler/testData/diagnostics/tests/inference/constraints/notNullConstraintOnNullableType.kt @@ -14,7 +14,7 @@ fun test(out: Out, i: In, inv: A) { // T? >: Int => T = Int doT(1) val r = doOut(out) - r checkType { it : _ } + r checkType { _() } // T? <: Int => error doIn(i) diff --git a/compiler/testData/diagnostics/tests/inference/constraints/subtypeConstraintOnNullableType.kt b/compiler/testData/diagnostics/tests/inference/constraints/subtypeConstraintOnNullableType.kt index 1f12fd4ba8a..20e5c1b5d74 100644 --- a/compiler/testData/diagnostics/tests/inference/constraints/subtypeConstraintOnNullableType.kt +++ b/compiler/testData/diagnostics/tests/inference/constraints/subtypeConstraintOnNullableType.kt @@ -11,13 +11,13 @@ fun doOut(o: Out): T = throw Exception("$o") fun test(a: A, aN: A, o: Out) { val out = doOut(o) //T? >: Int? => T >: Int - out checkType { it : _ } + out checkType { _() } val nullable = foo(aN, o) //T = Int?, T? >: Int? => T = Int? - nullable checkType { it : _ } + nullable checkType { _() } val notNullable = foo(a, o) //T = Int, T? >: Int? => T = Int - notNullable checkType { it : _ } + notNullable checkType { _() } } diff --git a/compiler/testData/diagnostics/tests/inference/constraints/supertypeConstraintOnNullableType.kt b/compiler/testData/diagnostics/tests/inference/constraints/supertypeConstraintOnNullableType.kt index 982f67e8f6d..f7c98c3d87f 100644 --- a/compiler/testData/diagnostics/tests/inference/constraints/supertypeConstraintOnNullableType.kt +++ b/compiler/testData/diagnostics/tests/inference/constraints/supertypeConstraintOnNullableType.kt @@ -11,13 +11,13 @@ fun doIn(i: In): T = throw Exception("$i") fun test(a: A, aN: A, i: In) { val _in = doIn(i) //T? <: Int? => T <: Int? - _in checkType { it : _ } + _in checkType { _() } val notNullable = foo(a, i) //T = Int, T? <: Int? => T = Int - notNullable checkType { it : _ } + notNullable checkType { _() } val nullable = foo(aN, i) //T = Int?, T? <: Int? => T = Int? - nullable checkType { it : _ } + nullable checkType { _() } } diff --git a/compiler/testData/diagnostics/tests/inference/dependOnExpectedType.kt b/compiler/testData/diagnostics/tests/inference/dependOnExpectedType.kt index 74473c7f38f..623df7913b3 100644 --- a/compiler/testData/diagnostics/tests/inference/dependOnExpectedType.kt +++ b/compiler/testData/diagnostics/tests/inference/dependOnExpectedType.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + package h //+JDK import java.util.* @@ -16,28 +18,28 @@ fun test1() { val a = elem(list(2)) val b = id(elem(list(2))) val c = id(id1(id(id1(list(33))))) - a : Int - b : Int - c : List + checkSubtype(a) + checkSubtype(b) + checkSubtype>(c) val d : ArrayList = newList() val e : ArrayList = id(newList()) val f : ArrayList = id(id1(id(id1(newList())))) - d : List - e : List - f : List + checkSubtype>(d) + checkSubtype>(e) + checkSubtype>(f) val g = elemAndList("", newList()) val h = elemAndList(1, newList()) - g : String - h : Long + checkSubtype(g) + checkSubtype(h) val i = both(1, "") val j = both(id(1), id("")) - i : Comparable<*> - j : Comparable<*> + checkSubtype>(i) + checkSubtype>(j) } fun list(value: T) : ArrayList { diff --git a/compiler/testData/diagnostics/tests/inference/functionPlaceholderError.kt b/compiler/testData/diagnostics/tests/inference/functionPlaceholderError.kt index 015f6815e29..d2298231f37 100644 --- a/compiler/testData/diagnostics/tests/inference/functionPlaceholderError.kt +++ b/compiler/testData/diagnostics/tests/inference/functionPlaceholderError.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + package a fun emptyList(): List = throw Exception() @@ -6,7 +8,7 @@ fun foo(f: T.() -> Unit, l: List): T = throw Exception("$f$l") fun test() { val q = foo(fun Int.() {}, emptyList()) //type inference no information for parameter error - q: Int + checkSubtype(q) foo({}, emptyList()) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/listConstructor.kt b/compiler/testData/diagnostics/tests/inference/listConstructor.kt index 56f8232819b..29ab0f0a477 100644 --- a/compiler/testData/diagnostics/tests/inference/listConstructor.kt +++ b/compiler/testData/diagnostics/tests/inference/listConstructor.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + package a //+JDK import java.util.* @@ -11,9 +13,9 @@ fun test() { val xs1 = cons("", nil()) val xs2 = cons(1, nil()) - xs : List - xs1 : List - xs2 : List + checkSubtype>(xs) + checkSubtype>(xs1) + checkSubtype>(xs2) } diff --git a/compiler/testData/diagnostics/tests/inference/mapFunction.kt b/compiler/testData/diagnostics/tests/inference/mapFunction.kt index 6c60d680482..002afc39a71 100644 --- a/compiler/testData/diagnostics/tests/inference/mapFunction.kt +++ b/compiler/testData/diagnostics/tests/inference/mapFunction.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + package a //+JDK @@ -8,17 +10,17 @@ fun foo() { val u = v map { it * 2 } - u : List + checkSubtype>(u) val a = 1..5 val b = a.map { it * 2 } - b : List + checkSubtype>(b) //check for non-error types - u : String - b : String + checkSubtype(u) + checkSubtype(b) } diff --git a/compiler/testData/diagnostics/tests/inference/mostSpecificAfterInference.kt b/compiler/testData/diagnostics/tests/inference/mostSpecificAfterInference.kt index 4772d4665d7..8296c47e6b5 100644 --- a/compiler/testData/diagnostics/tests/inference/mostSpecificAfterInference.kt +++ b/compiler/testData/diagnostics/tests/inference/mostSpecificAfterInference.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + package i //+JDK @@ -9,7 +11,7 @@ fun java.lang.Iterable.map1() { val res = list.map1 { it } //check res is not of error type - res : String + checkSubtype(res) } fun Collection.foo() {} @@ -18,5 +20,5 @@ fun java.lang.Iterable.foo() {} fun test1(list: List) { val res = list.foo() //check res is not of error type - res : String + checkSubtype(res) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/nestedCalls/inferenceForNestedBinaryCall.kt b/compiler/testData/diagnostics/tests/inference/nestedCalls/inferenceForNestedBinaryCall.kt index 560f9ad66bf..f9d04233648 100644 --- a/compiler/testData/diagnostics/tests/inference/nestedCalls/inferenceForNestedBinaryCall.kt +++ b/compiler/testData/diagnostics/tests/inference/nestedCalls/inferenceForNestedBinaryCall.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + package aaa fun T.foo(t: T) = t @@ -6,5 +8,5 @@ fun id(t: T) = t fun a() { val i = id(2 foo 3) - i : Int // i shouldn't be resolved to error element + checkSubtype(i) // i shouldn't be resolved to error element } diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt1029.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt1029.kt index 04a6f3880ab..62d6662f1d0 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt1029.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt1029.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + //KT-1029 Wrong type inference package i @@ -11,5 +13,5 @@ fun a() { val x = 0..200 val odd = from (x where {it%2==0}) // I believe it should infer here - odd : Iterable + checkSubtype>(odd) } diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt1031.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt1031.kt index 8c41d427093..6240a70a77a 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt1031.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt1031.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + //KT-1031 Can't infer type of `it` with two lambdas package i @@ -14,6 +16,6 @@ fun a() { val z = x where { i: Int -> i % 2 == 0 } val yielder = select(x where { it%2==0 }, { it.toString() }) - z : () -> Iterable - yielder : () -> Iterable + checkSubtype<() -> Iterable>(z) + checkSubtype<() -> Iterable>(yielder) } diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt1145.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt1145.kt index 6bb167ed719..2a4961ab24e 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt1145.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt1145.kt @@ -1,10 +1,12 @@ +// !CHECK_TYPE + //KT-1145 removing explicit generics on a call to Iterable.map(...) seems to generate an odd bytecode/runtime error package d fun test(numbers: Iterable) { val s = numbers.map{it.toString()}.fold(""){it, it2 -> it + it2} - s: Int + checkSubtype(s) } //from library diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt1410.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt1410.kt index 623409b3a04..bd566d78ae6 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt1410.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt1410.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + // KT-1410 Compiler does automatically infer type argument when using variance //+JDK package d @@ -17,7 +19,7 @@ fun foo(result: MutableList, collection: MutableCollection, p fun test(result: MutableList, collection: MutableCollection, prefix : String){ val c = collection.filterToMy(result, {it.startsWith(prefix)}) - c: MutableCollection + checkSubtype>(c) } //from library diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt1718.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt1718.kt index 8f8a5211fc0..ff96866612d 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt1718.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt1718.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + //KT-1718 compiler error when not using temporary variable package n @@ -5,9 +7,9 @@ import java.util.ArrayList fun test() { val list = arrayList("foo", "bar") + arrayList("cheese", "wine") - list: List + checkSubtype>(list) //check it's not an error type - list: Int + checkSubtype(list) } //from library diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt1944.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt1944.kt index 9c8df897074..adca39bc9e2 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt1944.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt1944.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + //KT-1944 Inference fails on run() package j @@ -7,7 +9,7 @@ class P { fun foo() { val r = run {x = 5} // ERROR - r : Unit + checkSubtype(r) } } diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2179.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2179.kt index ae09d44a874..29b043835a1 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt2179.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2179.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + //KT-2179 Nested function literal breaks compiler package i @@ -9,16 +11,16 @@ fun test() { //breaks compiler val sample2 = sample1.map({it.map({it})}) - sample2 : List> + checkSubtype>>(sample2) //breaks compiler val sample3 = sample1.map({row -> row.map({column -> column})}) - sample3 : List> + checkSubtype>>(sample3) //doesn't break compiler val identity: (Int?) -> Int? = {column -> column} val sample4 = sample1.map({row -> row.map(identity)}) - sample4 : List> + checkSubtype>>(sample4) } //------------ diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2200.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2200.kt index 628c798adce..ba518ebc253 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt2200.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2200.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + //KT-2200 array(array()) breaks compiler package n @@ -5,9 +7,9 @@ fun main(args: Array) { val a = array(array()) val a0 : Array> = array(array()) val a1 = array(array()) - a1 : Array> + checkSubtype>>(a1) val a2 = array>(array()) - a2 : Array> + checkSubtype>>(a2) } //from library diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2294.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2294.kt index 45156c79ea7..53822ed8ddc 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt2294.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2294.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + //KT-2294 Type inference infers DONT_CARE instead of correct type package a @@ -8,7 +10,7 @@ public fun test() val x = foo(array(1, 2, 3, 4, 5)) // Should infer type 'Int' // ^--- public final fun array(vararg t : DONT_CARE) : kotlin.Array defined in Kotlin // ^--- public final fun foo(items t : kotlin.Array) : kotlin.Array defined in root package - x : Array + checkSubtype>(x) } //-------------------- diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2324.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2324.kt index 0227decc730..b49d9066c1a 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt2324.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2324.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + //KT-2324 Can't resolve generic by type of function result package i @@ -13,11 +15,11 @@ fun someFunction(list: List, transform: (T) -> K): List { } fun testSomeFunction() { - val result1 = someFunction(arrayList(1, 2), {it : Int}) //type of result1 is List + val result1 = someFunction(arrayList(1, 2), {checkSubtype(it)}) //type of result1 is List assertEquals(1, result1.get(0)); //OK val result2 = someFunction(arrayList(1, 2), {it}) // type of result2 is List - result2 : List + checkSubtype>(result2) assertEquals(1, result2.get(0)); //resolved to error element } diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2407.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2407.kt index cf1e05c1aa3..806ddde19ae 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt2407.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2407.kt @@ -1,11 +1,13 @@ +// !CHECK_TYPE + package n import java.util.* fun test() { val foo = arrayList("").map { it -> it.length() }.fold(0, { x, y -> Math.max(x, y) }) - foo : Int - foo : String + checkSubtype(foo) + checkSubtype(foo) } //from library diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2505.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2505.kt index 8fce2b698a7..c29cc4de561 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt2505.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2505.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + //KT-2505 Type mismatch: inferred type is T but T was expected package a @@ -16,5 +18,5 @@ public open class HttpResponse() { fun test (httpResponse: HttpResponse, rtype: MyClass) { val res = httpResponse.parseAs( rtype ) - res : R //type mismatch: required R, found T + checkSubtype(res) //type mismatch: required R, found T } diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt731.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt731.kt index 70e3b95199b..cfca4026897 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt731.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt731.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + //KT-731 Missing error from type inference package a @@ -12,5 +14,5 @@ fun A.foo(x: (T)-> G): G { fun main(args: Array) { val a = A(1) val t: String = a.foo({p -> p}) - t : String + checkSubtype(t) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt943.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt943.kt index 30f27a96271..21606fd366c 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt943.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt943.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + //KT-943 Type inference failed package maze @@ -11,7 +13,7 @@ fun foo(lines: List) { val l2 = o2.length() l1 - l2 }).sure() - w : String + checkSubtype(w) } //standard library diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt948.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt948.kt index 6cd13e611ca..d74ad11e5f7 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt948.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt948.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + //KT-948 Make type inference work with sure()/!! package a @@ -11,8 +13,8 @@ fun foo() { val l : List = emptyList()!! val l1 = emptyList()!! - emptyList()!! : List - emptyList() : List? + checkSubtype>(emptyList()!!) + checkSubtype?>(emptyList()) doWithList(emptyList()!!) } diff --git a/compiler/testData/diagnostics/tests/inference/upperBounds/conflictingSubstitutionsFromUpperBound.kt b/compiler/testData/diagnostics/tests/inference/upperBounds/conflictingSubstitutionsFromUpperBound.kt index 9e7bf3636a4..091243b2b07 100644 --- a/compiler/testData/diagnostics/tests/inference/upperBounds/conflictingSubstitutionsFromUpperBound.kt +++ b/compiler/testData/diagnostics/tests/inference/upperBounds/conflictingSubstitutionsFromUpperBound.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + package g import java.util.HashSet @@ -6,5 +8,5 @@ fun > convert(src: Collection, dest: C): C = throw Except fun test(l: List) { //todo should be inferred val r = convert(l, HashSet()) - r: Int + checkSubtype(r) } diff --git a/compiler/testData/diagnostics/tests/inference/upperBounds/intersectUpperBounds.kt b/compiler/testData/diagnostics/tests/inference/upperBounds/intersectUpperBounds.kt index df1f2c96524..7a340945d98 100644 --- a/compiler/testData/diagnostics/tests/inference/upperBounds/intersectUpperBounds.kt +++ b/compiler/testData/diagnostics/tests/inference/upperBounds/intersectUpperBounds.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + package s trait In @@ -13,7 +15,7 @@ fun test(inA: In, inB: In, inC: In) { foo(inA, inB) val r = foo(inA, inC) - r: C + checkSubtype(r) val c: C = foo(inA, inB) @@ -24,7 +26,7 @@ fun bar(in1: In): T = throw Exception("$in1") fun test(inA: In) { val r = bar(inA) - r: C + checkSubtype(r) } fun use(vararg a: Any?) = a \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inline/parenthesized.kt b/compiler/testData/diagnostics/tests/inline/parenthesized.kt index 316215cf069..eadaa818410 100644 --- a/compiler/testData/diagnostics/tests/inline/parenthesized.kt +++ b/compiler/testData/diagnostics/tests/inline/parenthesized.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + inline fun inlineFunWithInvoke(s: (p: Int) -> Unit) { (s)(11) (s).invoke(11) @@ -20,6 +22,6 @@ inline fun inlineFunWithInvoke2(s: (p: Int) -> Unit) { } inline fun propagation(s: (p: Int) -> Unit) { - inlineFunWithInvoke((label@ (s: (p: Int) -> Unit))) - inlineFunWithInvoke((label2@ label@ (s: (p: Int) -> Unit))) + inlineFunWithInvoke((label@ s)) + inlineFunWithInvoke((label2@ label@ s)) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inline/recursion.kt b/compiler/testData/diagnostics/tests/inline/recursion.kt index 58fde2562b3..02dff244c3b 100644 --- a/compiler/testData/diagnostics/tests/inline/recursion.kt +++ b/compiler/testData/diagnostics/tests/inline/recursion.kt @@ -1,3 +1,4 @@ +// !CHECK_TYPE // !DIAGNOSTICS: -NOTHING_TO_INLINE -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -VARIABLE_EXPECTED inline fun inlineFun(s: (p: Int) -> Unit) { @@ -10,7 +11,7 @@ inline fun inlineFun(s: T) { inline fun Function0.inlineExt() { - ({11}:Function0).inlineExt(); + (checkSubtype>({11})).inlineExt(); {11}.inlineExt() } diff --git a/compiler/testData/diagnostics/tests/inline/typed.kt b/compiler/testData/diagnostics/tests/inline/typed.kt deleted file mode 100644 index 9faf006aa97..00000000000 --- a/compiler/testData/diagnostics/tests/inline/typed.kt +++ /dev/null @@ -1,21 +0,0 @@ -inline fun inlineFunWithInvoke(s: (p: Int) -> Unit) { - (s: (p: Int) -> Unit)(11) - (s: (p: Int) -> Unit).invoke(11) - (s: (p: Int) -> Unit) invoke 11 - (s) -} - -inline fun Function1.inlineExt() { - (this: Function1).invoke(11) - (this: Function1) invoke 11 - (this: Function1)(11) - (this: Function1) -} - -inline fun inlineFunWithInvoke2(s: (p: Int) -> Unit) { - (((s: (p: Int) -> Unit)))(11) - (((s: (p: Int) -> Unit): (p: Int) -> Unit): (p: Int) -> Unit)(11) - (((s: (p: Int) -> Unit): (p: Int) -> Unit): (p: Int) -> Unit).invoke(11) - (((s: (p: Int) -> Unit): (p: Int) -> Unit): (p: Int) -> Unit) invoke 11 - (((s: (p: Int) -> Unit))) -} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inline/typed.txt b/compiler/testData/diagnostics/tests/inline/typed.txt deleted file mode 100644 index 8b98c40ed5c..00000000000 --- a/compiler/testData/diagnostics/tests/inline/typed.txt +++ /dev/null @@ -1,5 +0,0 @@ -package - -kotlin.inline() internal fun inlineFunWithInvoke(/*0*/ s: (kotlin.Int) -> kotlin.Unit): kotlin.Unit -kotlin.inline() internal fun inlineFunWithInvoke2(/*0*/ s: (kotlin.Int) -> kotlin.Unit): kotlin.Unit -kotlin.inline() internal fun ((kotlin.Int) -> kotlin.Unit).inlineExt(): kotlin.Unit diff --git a/compiler/testData/diagnostics/tests/j+k/SupertypeArgumentsNullability-NotNull-SpecialTypes.kt b/compiler/testData/diagnostics/tests/j+k/SupertypeArgumentsNullability-NotNull-SpecialTypes.kt index 15969902cd8..205bc4f0ca3 100644 --- a/compiler/testData/diagnostics/tests/j+k/SupertypeArgumentsNullability-NotNull-SpecialTypes.kt +++ b/compiler/testData/diagnostics/tests/j+k/SupertypeArgumentsNullability-NotNull-SpecialTypes.kt @@ -1,3 +1,4 @@ +// !CHECK_TYPE // FILE: A.java public class A {} @@ -17,7 +18,7 @@ public class Y extends X { // FILE: test.kt fun main() { - Y().fooN() : Any + checkSubtype(Y().fooN()) Y().barN(null); } diff --git a/compiler/testData/diagnostics/tests/j+k/SupertypeArgumentsNullability-NotNull-UserTypes.kt b/compiler/testData/diagnostics/tests/j+k/SupertypeArgumentsNullability-NotNull-UserTypes.kt index 6b0992f9dfb..1c9610d9195 100644 --- a/compiler/testData/diagnostics/tests/j+k/SupertypeArgumentsNullability-NotNull-UserTypes.kt +++ b/compiler/testData/diagnostics/tests/j+k/SupertypeArgumentsNullability-NotNull-UserTypes.kt @@ -1,3 +1,4 @@ +// !CHECK_TYPE // FILE: A.java public class A {} @@ -17,7 +18,7 @@ public class Y extends X { // FILE: test.kt fun main() { - Y().fooN() : Any + checkSubtype(Y().fooN()) Y().barN(null); } diff --git a/compiler/testData/diagnostics/tests/j+k/kt2394.kt b/compiler/testData/diagnostics/tests/j+k/kt2394.kt index 481d55e0309..877f140f272 100644 --- a/compiler/testData/diagnostics/tests/j+k/kt2394.kt +++ b/compiler/testData/diagnostics/tests/j+k/kt2394.kt @@ -1,13 +1,15 @@ +// !CHECK_TYPE + //KT-2394 java.lang.Iterable should be visible as kotlin.Iterable package d fun foo(iterable: Iterable, iterator: Iterator, comparable: Comparable) { - iterable : Iterable - iterator : Iterator - comparable : Comparable + checkSubtype>(iterable) + checkSubtype>(iterator) + checkSubtype>(comparable) } fun bar(c: Collection) { - c : Iterable - c.iterator() : Iterator + checkSubtype>(c) + checkSubtype>(c.iterator()) } diff --git a/compiler/testData/diagnostics/tests/j+k/kt2641.kt b/compiler/testData/diagnostics/tests/j+k/kt2641.kt index e5f53fff152..022be5d88ed 100644 --- a/compiler/testData/diagnostics/tests/j+k/kt2641.kt +++ b/compiler/testData/diagnostics/tests/j+k/kt2641.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + package a import java.util.Iterator @@ -9,7 +11,7 @@ fun bar(any: Any): java.lang.Iterable val c : Iterator? = null if (any is Iterator<*>) { - any : Iterator<*> + checkSubtype<Iterator<*>>(any) } any as Iterator<*> return null diff --git a/compiler/testData/diagnostics/tests/jdk-annotations/ArrayListAndMap.kt b/compiler/testData/diagnostics/tests/jdk-annotations/ArrayListAndMap.kt index afd98c48ada..147aa66e090 100644 --- a/compiler/testData/diagnostics/tests/jdk-annotations/ArrayListAndMap.kt +++ b/compiler/testData/diagnostics/tests/jdk-annotations/ArrayListAndMap.kt @@ -1,3 +1,4 @@ +// !CHECK_TYPE package kotlin1 @@ -10,13 +11,13 @@ fun main(args : Array) { // // } val al2 = ArrayList(ArrayList()) - al : RandomAccess - al.clear() : Unit - al.add(1) : Boolean - al.add(0, 1) : Unit - al.addAll(al1) : Boolean - al.addAll(0, al1) : Boolean - al.get(0) : Int + checkSubtype(al) + checkSubtype(al.clear()) + checkSubtype(al.add(1)) + checkSubtype(al.add(0, 1)) + checkSubtype(al.addAll(al1)) + checkSubtype(al.addAll(0, al1)) + checkSubtype(al.get(0)) val m = HashMap() m.put("", 1) test(al, m) diff --git a/compiler/testData/diagnostics/tests/jdk-annotations/ArrayListClone.kt b/compiler/testData/diagnostics/tests/jdk-annotations/ArrayListClone.kt index f6837fa6174..2fb96ea1c96 100644 --- a/compiler/testData/diagnostics/tests/jdk-annotations/ArrayListClone.kt +++ b/compiler/testData/diagnostics/tests/jdk-annotations/ArrayListClone.kt @@ -1,8 +1,10 @@ +// !CHECK_TYPE + package kotlin1 import java.util.* fun main(args : Array) { val al : ArrayList = ArrayList() - al.clone() : Any // A type mismatch on this line means that jdk-annotations were not loaded + checkSubtype(al.clone()) // A type mismatch on this line means that jdk-annotations were not loaded } diff --git a/compiler/testData/diagnostics/tests/jdk-annotations/ArrayListToArray.kt b/compiler/testData/diagnostics/tests/jdk-annotations/ArrayListToArray.kt index ccbbf427807..4628190c218 100644 --- a/compiler/testData/diagnostics/tests/jdk-annotations/ArrayListToArray.kt +++ b/compiler/testData/diagnostics/tests/jdk-annotations/ArrayListToArray.kt @@ -1,3 +1,4 @@ +// !CHECK_TYPE // !DIAGNOSTICS: -UNUSED_PARAMETER package kotlin1 import java.util.* @@ -9,5 +10,5 @@ fun main(args : Array) { val al : ArrayList = ArrayList() // A type mismatch on this line means that jdk-annotations were not loaded - al.toArray(Array(3, {1})) : Array + checkSubtype>(al.toArray(Array(3, {1}))) } diff --git a/compiler/testData/diagnostics/tests/jdk-annotations/sql/DriverManager.kt b/compiler/testData/diagnostics/tests/jdk-annotations/sql/DriverManager.kt index 32b0ae40ca6..3aad04ed2f6 100644 --- a/compiler/testData/diagnostics/tests/jdk-annotations/sql/DriverManager.kt +++ b/compiler/testData/diagnostics/tests/jdk-annotations/sql/DriverManager.kt @@ -1,25 +1,27 @@ +// !CHECK_TYPE + import java.sql.DriverManager fun getConnection(url: String?) { DriverManager.getConnection(url) - DriverManager.getConnection(url!!) : java.sql.Connection + checkSubtype(DriverManager.getConnection(url!!)) } fun getConnection(url: String?, props: java.util.Properties?) { DriverManager.getConnection(url, props) - DriverManager.getConnection(url!!, props) : java.sql.Connection + checkSubtype(DriverManager.getConnection(url!!, props)) } fun getConnection(url: String?, user: String?, password: String?) { DriverManager.getConnection(url, user!!, password!!) DriverManager.getConnection(url!!, user, password!!) DriverManager.getConnection(url!!, user!!, password) - DriverManager.getConnection(url!!, user!!, password!!) : java.sql.Connection + checkSubtype(DriverManager.getConnection(url!!, user!!, password!!)) } fun getDriver(url: String?) { DriverManager.getDriver(url) - DriverManager.getDriver(url!!) : java.sql.Driver + checkSubtype(DriverManager.getDriver(url!!)) } fun registerDriver(driver: java.sql.Driver?) { @@ -28,5 +30,5 @@ fun registerDriver(driver: java.sql.Driver?) { } fun getDrivers() { - DriverManager.getDrivers() : java.util.Enumeration -} + checkSubtype>(DriverManager.getDrivers()) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/jdk-annotations/sql/ResultSet.kt b/compiler/testData/diagnostics/tests/jdk-annotations/sql/ResultSet.kt index 1be885f2a39..6ba9af2eddb 100644 --- a/compiler/testData/diagnostics/tests/jdk-annotations/sql/ResultSet.kt +++ b/compiler/testData/diagnostics/tests/jdk-annotations/sql/ResultSet.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + fun getMetaData(rs: java.sql.ResultSet) { - rs.getMetaData() : java.sql.ResultSetMetaData + checkSubtype(rs.getMetaData()) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/jdk-annotations/sql/Statement.kt b/compiler/testData/diagnostics/tests/jdk-annotations/sql/Statement.kt index addd0b73cc6..738d729ecf5 100644 --- a/compiler/testData/diagnostics/tests/jdk-annotations/sql/Statement.kt +++ b/compiler/testData/diagnostics/tests/jdk-annotations/sql/Statement.kt @@ -1,10 +1,12 @@ +// !CHECK_TYPE + fun executeQuery(statement: java.sql.Statement, cmd: String?) { statement.executeQuery(cmd) - statement.executeQuery(cmd!!) : java.sql.ResultSet + checkSubtype(statement.executeQuery(cmd!!)) } fun executeQuery(statement: java.sql.PreparedStatement) { - statement.executeQuery() : java.sql.ResultSet + checkSubtype(statement.executeQuery()) } fun executeUpdate(statement: java.sql.Statement, cmd: String?) { diff --git a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/AssertNotNull.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/AssertNotNull.kt index 261ca466eaa..e95599614d2 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/AssertNotNull.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/AssertNotNull.kt @@ -1,7 +1,9 @@ +// !CHECK_TYPE + fun main(args : Array) { val a : Int? = null val b : Int? = null - a!! : Int + checkSubtype(a!!) a!! + 2 a!!.plus(2) a!!.plus(b!!) @@ -32,5 +34,5 @@ fun main(args : Array) { } val f : String = a!! - a!! : String + checkSubtype(a!!) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt1778.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt1778.kt index 518fae9409c..9c170fe3d52 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt1778.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt1778.kt @@ -1,8 +1,9 @@ +// !CHECK_TYPE //KT-1778 Automatically cast error package kt1778 fun main(args : Array) { - val x = args[0]: Any + val x = checkSubtype(args[0]) if(x is java.lang.CharSequence) { if ("a" == x) x.length() else x.length() // OK if ("a" == x || "b" == x) x.length() else x.length() // <– THEN ERROR diff --git a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2176.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2176.kt index 379fa66225f..e346432dc10 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2176.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2176.kt @@ -1,27 +1,29 @@ +// !CHECK_TYPE + //KT-2176 non-nullability is not inferred after !! or "as" package kt2176 fun f1(a: String?) { a!! - a: String + checkSubtype(a) } fun f2(a: String) { a!! - a: String + checkSubtype(a) } fun f3(a: Any?) { a as String - a: String + checkSubtype(a) } fun f4(a: Any) { a as String - a: String + checkSubtype(a) } fun f5(a: String) { - a as Any? - a: String + a as Any? + checkSubtype(a) } diff --git a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2234.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2234.kt index 3a5b237e393..742164f5c12 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2234.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2234.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + package a //KT-2234 'period!!' has type Int? @@ -7,15 +9,15 @@ class Pair(val a: A, val b: B) fun main(args : Array) { val d : Long = 1 val period : Int? = null - if (period != null) Pair(d, period!! : Int) else Pair(d, 1) - if (period != null) Pair(d, period : Int) else Pair(d, 1) + if (period != null) Pair(d, checkSubtype(period!!)) else Pair(d, 1) + if (period != null) Pair(d, checkSubtype(period)) else Pair(d, 1) } fun foo() { val x : Int? = 3 if (x != null) { - val u = x!! : Int - val y = x : Int + val u = checkSubtype(x!!) + val y = checkSubtype(x) val z : Int = y } } diff --git a/compiler/testData/diagnostics/tests/numbers/doublesInSimpleConstraints.kt b/compiler/testData/diagnostics/tests/numbers/doublesInSimpleConstraints.kt index 7fd40ca0c72..afc39d73c97 100644 --- a/compiler/testData/diagnostics/tests/numbers/doublesInSimpleConstraints.kt +++ b/compiler/testData/diagnostics/tests/numbers/doublesInSimpleConstraints.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + package a fun id(t: T): T = t @@ -8,13 +10,13 @@ fun test() { val a: Float = id(2.0.toFloat()) val b = id(2.0) - b: Double + checkSubtype(b) val c = either(1, 2.3) - c: Number + checkSubtype(c) val d = either(11, 2.3) - d: Any + checkSubtype(d) val e: Float = id(1) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/numbers/numbersInSimpleConstraints.kt b/compiler/testData/diagnostics/tests/numbers/numbersInSimpleConstraints.kt index be29bca7ba2..181a152ecb4 100644 --- a/compiler/testData/diagnostics/tests/numbers/numbersInSimpleConstraints.kt +++ b/compiler/testData/diagnostics/tests/numbers/numbersInSimpleConstraints.kt @@ -17,10 +17,10 @@ fun test() { val c: Int = id(9223372036854775807) val d = id(22) - d: Int + checkSubtype(d) val e = id(9223372036854775807) - e checkType { it : _ } + e checkType { _() } val f: Byte = either(1, 2) @@ -31,7 +31,7 @@ fun test() { otherGeneric(1) val r = either(1, "") - r checkType { it : _> } + r checkType { _>() } use(a, b, c, d, e, f, g, r) } @@ -47,7 +47,7 @@ fun testExactBound(invS: Inv, invI: Inv, invB: Inv) { exactBound(1, invI) val b = exactBound(1, invB) - b checkType { it : _ } + b checkType { _() } } trait Cov @@ -56,10 +56,10 @@ fun lowerBound(t: T, l : Cov): T = throw Exception("$t $l") fun testLowerBound(cov: Cov, covN: Cov) { val r = lowerBound(1, cov) - r checkType { it : _> } + r checkType { _>() } val n = lowerBound(1, covN) - n checkType { it : _ } + n checkType { _() } } trait Contr @@ -70,8 +70,8 @@ fun testUpperBound(contrS: Contr, contrB: Contr, contrN: ContrupperBound(1, contrS) val n = upperBound(1, contrN) - n checkType { it : _ } + n checkType { _() } val b = upperBound(1, contrB) - b checkType { it : _ } + b checkType { _() } } diff --git a/compiler/testData/diagnostics/tests/objects/localObjectInsideObject.kt b/compiler/testData/diagnostics/tests/objects/localObjectInsideObject.kt index 4eef911ecef..6a593b39d65 100644 --- a/compiler/testData/diagnostics/tests/objects/localObjectInsideObject.kt +++ b/compiler/testData/diagnostics/tests/objects/localObjectInsideObject.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + fun foo() { val a = object { val b = object { @@ -5,5 +7,5 @@ fun foo() { } } - a.b.c : Int + checkSubtype(a.b.c) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/platformTypes/commonSupertype/withNothing.kt b/compiler/testData/diagnostics/tests/platformTypes/commonSupertype/withNothing.kt index 71fcbb0ea12..3e6f24548a3 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/commonSupertype/withNothing.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/commonSupertype/withNothing.kt @@ -19,6 +19,6 @@ fun out(t: T): Out> = null!! fun test(a: Out, b: Out>) { val v = f(a, b, out(J.j())) - v checkType { it : _>} - v checkType { it : _>} + v checkType { _>() } + v checkType { _>() } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/platformTypes/dereference.kt b/compiler/testData/diagnostics/tests/platformTypes/dereference.kt index 6240acdb6e5..9a2af0559b2 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/dereference.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/dereference.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + // FILE: p/J.java package p; @@ -14,7 +16,7 @@ public class J { import p.* fun test(j: J) { - j.j() : J + checkSubtype(j.j()) j.j().j() j.j()!!.j() diff --git a/compiler/testData/diagnostics/tests/platformTypes/explicitFlexibleNoPackage.kt b/compiler/testData/diagnostics/tests/platformTypes/explicitFlexibleNoPackage.kt index a4ffd2a0567..ccacc81d250 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/explicitFlexibleNoPackage.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/explicitFlexibleNoPackage.kt @@ -3,6 +3,6 @@ // !CHECK_TYPE fun foo(f: ft) { - f.checkType { it : _ } - f.checkType { it : _ } + f.checkType { _() } + f.checkType { _() } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/platformTypes/explicitFlexibleWithPackage.kt b/compiler/testData/diagnostics/tests/platformTypes/explicitFlexibleWithPackage.kt index 6082d7b856e..63f650fc139 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/explicitFlexibleWithPackage.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/explicitFlexibleWithPackage.kt @@ -4,6 +4,6 @@ package ppp fun foo(f: ft) { - f.checkType { it : _ } - f.checkType { it : _ } + f.checkType { _() } + f.checkType { _() } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/platformTypes/inference.kt b/compiler/testData/diagnostics/tests/platformTypes/inference.kt index e6d92367cbc..a5fc0a7ff4d 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/inference.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/inference.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + // FILE: foo/Base.java package foo; @@ -20,5 +22,5 @@ fun > convert(src: HS, dest: C): C = throw Exception("$src $des fun test(l: HS) { //todo should be inferred val r = convert(l, HS()) - r: Int + checkSubtype(r) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/platformTypes/intVsIntegerAmbiguity.kt b/compiler/testData/diagnostics/tests/platformTypes/intVsIntegerAmbiguity.kt index 5955ac3bf7b..82334f62dcf 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/intVsIntegerAmbiguity.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/intVsIntegerAmbiguity.kt @@ -1,3 +1,4 @@ +// !CHECK_TYPE // !DIAGNOSTICS: -UNUSED_PARAMETER // FILE: p/J.java @@ -23,9 +24,9 @@ class C fun foo(i: Int?) : C = null!! fun test(i: Int, ni: Int?) { - foo(2) : J.A - foo(i) : J.A - J.foo(ni) : J.B + checkSubtype(foo(2)) + checkSubtype(foo(i)) + checkSubtype(J.foo(ni)) foo(ni) foo(J.getInteger()) diff --git a/compiler/testData/diagnostics/tests/platformTypes/intersection/map.kt b/compiler/testData/diagnostics/tests/platformTypes/intersection/map.kt index 7781837573a..5edcc2d090d 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/intersection/map.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/intersection/map.kt @@ -1,3 +1,4 @@ +// !CHECK_TYPE // !EXPLICIT_FLEXIBLE_TYPES fun foo( diff --git a/compiler/testData/diagnostics/tests/platformTypes/methodCall/objectArray.kt b/compiler/testData/diagnostics/tests/platformTypes/methodCall/objectArray.kt index fd300ac62ea..64ac5f084cf 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/methodCall/objectArray.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/methodCall/objectArray.kt @@ -1,3 +1,4 @@ +// !CHECK_TYPE // FILE: p/J.java package p; diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/expectedType.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/expectedType.kt index 67de74a347c..0cdc5c96fce 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/expectedType.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/expectedType.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + // FILE: p/J.java package p; @@ -23,11 +25,11 @@ fun test() { // platform type with no annotation val platformJ = J.staticJ - platformNN : J - platformN : J - platformJ : J + checkSubtype(platformNN) + checkSubtype(platformN) + checkSubtype(platformJ) - platformNN : J? - platformN : J? - platformJ : J? + checkSubtype(platformNN) + checkSubtype(platformN) + checkSubtype(platformJ) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/platformTypes/safeCall.kt b/compiler/testData/diagnostics/tests/platformTypes/safeCall.kt index 6fc9a05a8d5..5cfe19ee5bd 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/safeCall.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/safeCall.kt @@ -11,5 +11,5 @@ public class J { import p.* fun test(j: J) { - j.s()?.length().checkType { it : _ } + j.s()?.length().checkType { _() } } diff --git a/compiler/testData/diagnostics/tests/regressions/Jet53.kt b/compiler/testData/diagnostics/tests/regressions/Jet53.kt index 0a24a6acda6..0703aa50dd6 100644 --- a/compiler/testData/diagnostics/tests/regressions/Jet53.kt +++ b/compiler/testData/diagnostics/tests/regressions/Jet53.kt @@ -1,4 +1,5 @@ +// !CHECK_TYPE import java.util.Collections -val ab = Collections.emptyList() : List? +val ab = checkSubtype?>(Collections.emptyList()) diff --git a/compiler/testData/diagnostics/tests/regressions/kt334.kt b/compiler/testData/diagnostics/tests/regressions/kt334.kt index 9990e57d126..3451af4ed2b 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt334.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt334.kt @@ -1,6 +1,8 @@ +// !CHECK_TYPE + import java.lang.Comparable as Comparable fun f(c: Comparable<*>) { - c: kotlin.Comparable<*> - c: java.lang.Comparable<*> + checkSubtype>(c) + checkSubtype<java.lang.Comparable<*>>(c) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/senselessComparison/parenthesized.kt b/compiler/testData/diagnostics/tests/senselessComparison/parenthesized.kt index 084740d87c0..1d3b5f73d77 100644 --- a/compiler/testData/diagnostics/tests/senselessComparison/parenthesized.kt +++ b/compiler/testData/diagnostics/tests/senselessComparison/parenthesized.kt @@ -1,31 +1,23 @@ fun testEquals(x: Int) { if (x == null) {} if (x == (null)) {} - if (x == null: Nothing?) {} - if (x == null: Nothing?) {} if (x == foo@ null) {} } fun testEqualsFlipped(x: Int) { if (null == x) {} if ((null) == x) {} - if (null: Nothing? == x) {} - if (null: Nothing? == x) {} if (foo@ null == x) {} } fun testNotEquals(x: Int) { if (x != null) {} if (x != (null)) {} - if (x != null: Nothing?) {} - if (x != null: Nothing?) {} if (x != foo@ null) {} } fun testNotEqualsFlipped(x: Int) { if (null != x) {} if ((null) != x) {} - if (null: Nothing? != x) {} - if (null: Nothing? != x) {} if (foo@ null != x) {} } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/smartCasts/inference/intersectionTypes.kt b/compiler/testData/diagnostics/tests/smartCasts/inference/intersectionTypes.kt index eed8b42a215..f7a08cacea8 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/inference/intersectionTypes.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/inference/intersectionTypes.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + package a fun id(t: T): T = t @@ -15,17 +17,17 @@ fun test(a: A, b: B, c: C) { val d: C = id(a) val e: Any = id(a) val f = id(a) - f: A + checkSubtype(f) val g = two(a, b) - g: B - g: A + checkSubtype(g) + checkSubtype(g) // smart cast isn't needed, but is reported due to KT-4294 val h: Any = two(a, b) val k = three(a, b, c) - k: A - k: B + checkSubtype(k) + checkSubtype(k) val l: Int = three(a, b, c) use(d, e, f, g, h, k, l) @@ -47,8 +49,8 @@ fun testErrorMessages(a: A, ml: MutableList) { fun rr(s: String?) { if (s != null) { val l = arrayListOf("", s) - l: MutableList - l: MutableList + checkSubtype>(l) + checkSubtype>(l) } } diff --git a/compiler/testData/diagnostics/tests/smartCasts/kt5455.kt b/compiler/testData/diagnostics/tests/smartCasts/kt5455.kt index 2c3e2a06d33..8df70b6ee7d 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/kt5455.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/kt5455.kt @@ -1,7 +1,7 @@ //KT-5455 Need warning about redundant type cast fun foo(o: Any): Int { if (o is String) { - return (o as String).length() + return (o as String).length() } return -1 } @@ -13,16 +13,16 @@ class B: A() fun test(a: Any?) { if (a is B) { - (a as A).foo() + (a as A).foo() } } fun test1(a: B) { - (a as A?)?.foo() + (a as A?)?.foo() } fun test2(b: B?) { if (b != null) { - (b as A).foo() + (b as A).foo() } } diff --git a/compiler/testData/diagnostics/tests/smartCasts/loops/assignWhenInsideWhileTrue.kt b/compiler/testData/diagnostics/tests/smartCasts/loops/assignWhenInsideWhileTrue.kt index d77efc83366..4b1a967af17 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/loops/assignWhenInsideWhileTrue.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/loops/assignWhenInsideWhileTrue.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + public fun foo(x: String?): Int { var y: Any loop@ while (true) { @@ -8,7 +10,7 @@ public fun foo(x: String?): Int { else -> x.length() } // y is always Int after when - y: Int + checkSubtype(y) } // x is null because of the break return x.length() diff --git a/compiler/testData/diagnostics/tests/smartCasts/loops/plusAssignWhenInsideDoWhile.kt b/compiler/testData/diagnostics/tests/smartCasts/loops/plusAssignWhenInsideDoWhile.kt index ae65a87926c..58ea8171145 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/loops/plusAssignWhenInsideDoWhile.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/loops/plusAssignWhenInsideDoWhile.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + fun bar(): Boolean { return true } public fun foo(x: String?): Int { @@ -11,10 +13,10 @@ public fun foo(x: String?): Int { else -> x.length() } // y is always Int after when - y: Int + checkSubtype(y) } while (bar()) // y is always Int even here - y: Int + checkSubtype(y) // x is null because of the break return x.length() } diff --git a/compiler/testData/diagnostics/tests/substitutions/starProjections.kt b/compiler/testData/diagnostics/tests/substitutions/starProjections.kt index 30a15c5390a..dc7de4f934f 100644 --- a/compiler/testData/diagnostics/tests/substitutions/starProjections.kt +++ b/compiler/testData/diagnostics/tests/substitutions/starProjections.kt @@ -6,8 +6,8 @@ trait A> { } fun testA(a: A<*, *>) { - a.r().checkType { it : _ } - a.t().checkType { it : _> } + a.r().checkType { _() } + a.t().checkType { _>() } } trait B, T>> { @@ -16,8 +16,8 @@ trait B, T>> { } fun testB(b: B<*, *>) { - b.r().checkType { it : _ } - b.t().checkType { it : _, *>> } + b.r().checkType { _() } + b.t().checkType { _, *>>() } b.t().r().size() } diff --git a/compiler/testData/diagnostics/tests/subtyping/kt-1457.kt b/compiler/testData/diagnostics/tests/subtyping/kt-1457.kt index 88d34e3f63c..6d2e490717e 100644 --- a/compiler/testData/diagnostics/tests/subtyping/kt-1457.kt +++ b/compiler/testData/diagnostics/tests/subtyping/kt-1457.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + import java.util.ArrayList class Pair(val a: A, val b: B) @@ -5,5 +7,5 @@ class Pair(val a: A, val b: B) class MyListOfPairs : ArrayList>() { } fun test() { - MyListOfPairs() : ArrayList> + checkSubtype>>(MyListOfPairs()) } diff --git a/compiler/testData/diagnostics/tests/suppress/manyWarnings/mixed.kt b/compiler/testData/diagnostics/tests/suppress/manyWarnings/mixed.kt index 9cdd00f8df1..46d2e4d4190 100644 --- a/compiler/testData/diagnostics/tests/suppress/manyWarnings/mixed.kt +++ b/compiler/testData/diagnostics/tests/suppress/manyWarnings/mixed.kt @@ -1,5 +1,5 @@ suppress("REDUNDANT_NULLABLE") class C { suppress("UNNECESSARY_NOT_NULL_ASSERTION") - fun foo(): String?? = ""!! as String?? + fun foo(): String?? = ""!! as String?? } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/suppress/manyWarnings/onClass.kt b/compiler/testData/diagnostics/tests/suppress/manyWarnings/onClass.kt index 9861434d5fe..37182a9130d 100644 --- a/compiler/testData/diagnostics/tests/suppress/manyWarnings/onClass.kt +++ b/compiler/testData/diagnostics/tests/suppress/manyWarnings/onClass.kt @@ -1,4 +1,4 @@ suppress("REDUNDANT_NULLABLE", "UNNECESSARY_NOT_NULL_ASSERTION") class C { - fun foo(): String?? = ""!! as String?? + fun foo(): String?? = ""!! as String?? } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/suppress/manyWarnings/onClassObject.kt b/compiler/testData/diagnostics/tests/suppress/manyWarnings/onClassObject.kt index 3e56fe04b26..6c269882b8e 100644 --- a/compiler/testData/diagnostics/tests/suppress/manyWarnings/onClassObject.kt +++ b/compiler/testData/diagnostics/tests/suppress/manyWarnings/onClassObject.kt @@ -1,6 +1,6 @@ class C { suppress("REDUNDANT_NULLABLE", "UNNECESSARY_NOT_NULL_ASSERTION") companion object { - val foo: String?? = ""!! as String?? + val foo: String?? = ""!! as String?? } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/suppress/manyWarnings/onExpression.kt b/compiler/testData/diagnostics/tests/suppress/manyWarnings/onExpression.kt index 01097f7e450..c6c62c4941d 100644 --- a/compiler/testData/diagnostics/tests/suppress/manyWarnings/onExpression.kt +++ b/compiler/testData/diagnostics/tests/suppress/manyWarnings/onExpression.kt @@ -1,4 +1,4 @@ fun foo(): Any? { [suppress("REDUNDANT_NULLABLE", "UNNECESSARY_NOT_NULL_ASSERTION")] - return ""!! as String?? + return ""!! as String?? } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/suppress/manyWarnings/onFunction.kt b/compiler/testData/diagnostics/tests/suppress/manyWarnings/onFunction.kt index a8105aa7466..eebf597f4c2 100644 --- a/compiler/testData/diagnostics/tests/suppress/manyWarnings/onFunction.kt +++ b/compiler/testData/diagnostics/tests/suppress/manyWarnings/onFunction.kt @@ -1,4 +1,4 @@ class C { suppress("REDUNDANT_NULLABLE", "UNNECESSARY_NOT_NULL_ASSERTION") - fun foo(): String?? = ""!! as String?? + fun foo(): String?? = ""!! as String?? } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/suppress/manyWarnings/onObject.kt b/compiler/testData/diagnostics/tests/suppress/manyWarnings/onObject.kt index 46b417e7005..c52a6b19796 100644 --- a/compiler/testData/diagnostics/tests/suppress/manyWarnings/onObject.kt +++ b/compiler/testData/diagnostics/tests/suppress/manyWarnings/onObject.kt @@ -1,4 +1,4 @@ suppress("REDUNDANT_NULLABLE", "UNNECESSARY_NOT_NULL_ASSERTION") object C { - fun foo(): String?? = ""!! as String?? + fun foo(): String?? = ""!! as String?? } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/suppress/manyWarnings/onParameter.kt b/compiler/testData/diagnostics/tests/suppress/manyWarnings/onParameter.kt index e068b5ba5e5..afc547f3999 100644 --- a/compiler/testData/diagnostics/tests/suppress/manyWarnings/onParameter.kt +++ b/compiler/testData/diagnostics/tests/suppress/manyWarnings/onParameter.kt @@ -1,3 +1,3 @@ class C { - fun foo(suppress("REDUNDANT_NULLABLE", "UNNECESSARY_NOT_NULL_ASSERTION") p: String?? = ""!! as String??) = p + fun foo(suppress("REDUNDANT_NULLABLE", "UNNECESSARY_NOT_NULL_ASSERTION") p: String?? = ""!! as String??) = p } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/suppress/manyWarnings/onProperty.kt b/compiler/testData/diagnostics/tests/suppress/manyWarnings/onProperty.kt index 4e733c514c7..a04110c3eda 100644 --- a/compiler/testData/diagnostics/tests/suppress/manyWarnings/onProperty.kt +++ b/compiler/testData/diagnostics/tests/suppress/manyWarnings/onProperty.kt @@ -1,4 +1,4 @@ class C { suppress("REDUNDANT_NULLABLE", "UNNECESSARY_NOT_NULL_ASSERTION") - val foo: String?? = ""!! as String?? + val foo: String?? = ""!! as String?? } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/suppress/manyWarnings/onPropertyAccessor.kt b/compiler/testData/diagnostics/tests/suppress/manyWarnings/onPropertyAccessor.kt index 481e56456b2..a8f717b2366 100644 --- a/compiler/testData/diagnostics/tests/suppress/manyWarnings/onPropertyAccessor.kt +++ b/compiler/testData/diagnostics/tests/suppress/manyWarnings/onPropertyAccessor.kt @@ -1,5 +1,5 @@ class C { val foo: String? [suppress("REDUNDANT_NULLABLE", "UNNECESSARY_NOT_NULL_ASSERTION")] - get(): String?? = ""!! as String?? + get(): String?? = ""!! as String?? } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/thisAndSuper/thisInFunctionLiterals.kt b/compiler/testData/diagnostics/tests/thisAndSuper/thisInFunctionLiterals.kt index 8343fe5ef06..73ae5bd5ee5 100644 --- a/compiler/testData/diagnostics/tests/thisAndSuper/thisInFunctionLiterals.kt +++ b/compiler/testData/diagnostics/tests/thisAndSuper/thisInFunctionLiterals.kt @@ -1,16 +1,18 @@ +// !CHECK_TYPE + class A(val a:Int) { inner class B() { fun Char.xx() : Double.() -> Any { - this : Char + checkSubtype(this) val a: Double.() -> Unit = { - this : Double - this@xx : Char - this@B : B - this@A : A + checkSubtype(this) + checkSubtype(this@xx) + checkSubtype(this@B) + checkSubtype(this@A) } - val b: Double.() -> Unit = a@{ this@a : Double + this@xx : Char} - val c = a@{ -> this@a + this@xx : Char} - return (a@{this@a : Double + this@xx : Char}) + val b: Double.() -> Unit = a@{ checkSubtype(this@a) + checkSubtype(this@xx) } + val c = a@{ -> this@a + checkSubtype(this@xx) } + return (a@{checkSubtype(this@a) + checkSubtype(this@xx)}) } } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/thisAndSuper/thisInInnerClasses.kt b/compiler/testData/diagnostics/tests/thisAndSuper/thisInInnerClasses.kt index 8691aa32a93..37894b81581 100644 --- a/compiler/testData/diagnostics/tests/thisAndSuper/thisInInnerClasses.kt +++ b/compiler/testData/diagnostics/tests/thisAndSuper/thisInInnerClasses.kt @@ -1,9 +1,11 @@ +// !CHECK_TYPE + class A(val a:Int) { inner class B() { - val x = this@B : B - val y = this@A : A - val z = this : B - val Int.xx : Int get() = this : Int + val x = checkSubtype(this@B) + val y = checkSubtype(this@A) + val z = checkSubtype(this) + val Int.xx : Int get() = checkSubtype(this) } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/varargs/varargsAndOut1.kt b/compiler/testData/diagnostics/tests/varargs/varargsAndOut1.kt index b5ea82abc39..4a3277928a8 100644 --- a/compiler/testData/diagnostics/tests/varargs/varargsAndOut1.kt +++ b/compiler/testData/diagnostics/tests/varargs/varargsAndOut1.kt @@ -1,13 +1,13 @@ // !CHECK_TYPE fun test(vararg a: String) { - a checkType { it : _> } + a checkType { _>() } - foo(a) checkType { it : _> } + foo(a) checkType { _>() } } fun test1(vararg t: T) { - t checkType { it : _> } + t checkType { _>() } } fun foo(a: Array): Array = a \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/varargs/varargsAndPair.kt b/compiler/testData/diagnostics/tests/varargs/varargsAndPair.kt index 3d080e591f7..6126b2c7ba8 100644 --- a/compiler/testData/diagnostics/tests/varargs/varargsAndPair.kt +++ b/compiler/testData/diagnostics/tests/varargs/varargsAndPair.kt @@ -1,8 +1,10 @@ +// !CHECK_TYPE + fun foo(vararg ts: T): T? = null class Pair(a: A) fun test() { val v = foo(Pair(1)) - v: Int // check that it is not error type + checkSubtype(v) // check that it is not error type } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/dynamicCallsWithLambdas.kt b/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/dynamicCallsWithLambdas.kt index 49901df6609..041fce0ae2f 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/dynamicCallsWithLambdas.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/dynamicCallsWithLambdas.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + fun test(d: dynamic) { d.foo {} @@ -21,7 +23,7 @@ fun test(d: dynamic) { d.foo({ x -> }) - d.foo({ x -> } : (Int) -> Unit) + d.foo(checkSubtype<(Int) -> Unit>({ x -> })) d.foo(label@ { x -> }) diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/extensionVals.kt b/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/extensionVals.kt index 76f5d05ca31..e97d2c10900 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/extensionVals.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/extensionVals.kt @@ -1,3 +1,4 @@ +// !DIAGNOSTICS:-USELESS_CAST // !MARK_DYNAMIC_CALLS fun test(d: dynamic) { @@ -20,10 +21,10 @@ fun test(d: dynamic) { d.onDynamicVal = 1 - (d: String).onStringVal - (d: Any).onAnyVal - (d: Any?).onNullableAnyVal - (d: Any).onDynamicVal + (d as String).onStringVal + (d as Any).onAnyVal + (d as Any?).onNullableAnyVal + (d as Any).onDynamicVal } fun testReassignmentWithSafeCall(d: dynamic) { @@ -31,10 +32,10 @@ fun testReassignmentWithSafeCall(d: dynamic) { } fun testReassignmentWithStaticCalls(d: dynamic) { - (d: String).onStringVal = 1 - (d: Any).onAnyVal = 1 - (d: Any?).onNullableAnyVal = 1 - (d: Any).onDynamicVal = 1 + (d as String).onStringVal = 1 + (d as Any).onAnyVal = 1 + (d as Any?).onNullableAnyVal = 1 + (d as Any).onDynamicVal = 1 } val Any.onAnyVal: Int get() = 1 diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/extensionVars.kt b/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/extensionVars.kt index 07589348d9c..2698a9a9772 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/extensionVars.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/extensionVars.kt @@ -1,4 +1,5 @@ // !MARK_DYNAMIC_CALLS +// !DIAGNOSTICS:-USELESS_CAST fun test(d: dynamic) { d.onAnyVar @@ -23,15 +24,15 @@ fun test(d: dynamic) { d?.onDynamicVar = 1 - (d: String).onStringVar - (d: Any).onAnyVar - (d: Any?).onNullableAnyVar - (d: Any).onDynamicVar + (d as String).onStringVar + (d as Any).onAnyVar + (d as Any?).onNullableAnyVar + (d as Any).onDynamicVar - (d: String).onStringVar = 1 - (d: Any).onAnyVar = 1 - (d: Any?).onNullableAnyVar = 1 - (d: Any).onDynamicVar = 1 + (d as String).onStringVar = 1 + (d as Any).onAnyVar = 1 + (d as Any?).onNullableAnyVar = 1 + (d as Any).onDynamicVar = 1 } var Any.onAnyVar: Int diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/extensions.kt b/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/extensions.kt index cd71691ce52..570a8aa0fe2 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/extensions.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/extensions.kt @@ -1,3 +1,4 @@ +// !DIAGNOSTICS:-USELESS_CAST // !MARK_DYNAMIC_CALLS fun test(d: dynamic) { @@ -15,10 +16,10 @@ fun test(d: dynamic) { d.onDynamic() d?.onDynamic() - (d: String).onString() - (d: Any).onAny() - (d: Any?).onNullableAny() - (d: Any).onDynamic() + (d as String).onString() + (d as Any).onAny() + (d as Any?).onNullableAny() + (d as Any).onDynamic() } fun Any.onAny() {} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/overloading.kt b/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/overloading.kt index eb0e726e5bc..9ad15efcb6f 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/overloading.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/overloading.kt @@ -13,11 +13,11 @@ fun test(d: dynamic) { dyn(1) dyn("") - foo(1).checkType { it : _ } - foo("").checkType { it : _ } + foo(1).checkType { _() } + foo("").checkType { _() } // Checking specificity of `dynamic` vs `Nothing` - nothing(d).checkType { it : _ } - nothing("").checkType { it : _ } - [suppress("UNREACHABLE_CODE")] nothing(null!!).checkType { it : _ } + nothing(d).checkType { _() } + nothing("").checkType { _() } + [suppress("UNREACHABLE_CODE")] nothing(null!!).checkType { _() } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/ambiguityTopLevelVsTopLevel.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/ambiguityTopLevelVsTopLevel.kt index 56f505bec6a..94f12524c7f 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/ambiguityTopLevelVsTopLevel.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/ambiguityTopLevelVsTopLevel.kt @@ -1,9 +1,9 @@ -// !DIAGNOSTICS: -UNUSED_EXPRESSION +// !DIAGNOSTICS: -UNUSED_EXPRESSION,-UNUSED_VARIABLE fun foo(x: Int, y: Any) = x fun foo(x: Any, y: Int) = y fun main() { ::foo - ::foo : (Int, Any) -> Unit -} \ No newline at end of file + val fooRef: (Int, Any) -> Unit = ::foo +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/constructorFromClass.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/constructorFromClass.kt index 462064ebe54..fef4ee7ca36 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/constructorFromClass.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/constructorFromClass.kt @@ -1,10 +1,12 @@ +// !CHECK_TYPE + import kotlin.reflect.KFunction0 class A { fun main() { val x = ::A - x : KFunction0 + checkSubtype>(x) } } @@ -12,6 +14,6 @@ class SomeOtherClass { fun main() { val x = ::A - x : KFunction0 + checkSubtype>(x) } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/constructorFromExtension.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/constructorFromExtension.kt index fcbf938987f..07c789acecf 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/constructorFromExtension.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/constructorFromExtension.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + import kotlin.reflect.KFunction0 class A @@ -7,6 +9,6 @@ fun A.ext() { val x = ::A val y = ::B - x : KFunction0 - y : KFunction0 + checkSubtype>(x) + checkSubtype>(y) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/constructorFromExtensionInClass.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/constructorFromExtensionInClass.kt index 3b8fe60c2ba..56af7cecad4 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/constructorFromExtensionInClass.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/constructorFromExtensionInClass.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + import kotlin.reflect.KFunction0 class A @@ -7,15 +9,15 @@ class B { val x = ::A val y = ::B - x : KFunction0 - y : KFunction0 + checkSubtype>(x) + checkSubtype>(y) } fun B.ext() { val x = ::A val y = ::B - x : KFunction0 - y : KFunction0 + checkSubtype>(x) + checkSubtype>(y) } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/constructorFromTopLevel.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/constructorFromTopLevel.kt index 8ce80f50e2b..4417c6fdef1 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/constructorFromTopLevel.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/constructorFromTopLevel.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + import kotlin.reflect.KFunction0 class A @@ -5,5 +7,5 @@ class A fun main() { val x = ::A - x : KFunction0 + checkSubtype>(x) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/differentPackageClass.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/differentPackageClass.kt index 52f172c7abf..593a279e949 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/differentPackageClass.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/differentPackageClass.kt @@ -1,3 +1,4 @@ +// !CHECK_TYPE // FILE: a.kt package first @@ -21,7 +22,7 @@ fun main() { val y = first.A::bar val z = A::baz - x : KMemberFunction0 - y : KMemberFunction1 - z : KMemberFunction0 + checkSubtype>(x) + checkSubtype>(y) + checkSubtype>(z) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/differentPackageExtension.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/differentPackageExtension.kt index 28ad3f4a0bd..96b8072ed12 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/differentPackageExtension.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/differentPackageExtension.kt @@ -1,3 +1,4 @@ +// !CHECK_TYPE // !DIAGNOSTICS: -UNUSED_EXPRESSION // FILE: a.kt @@ -23,5 +24,5 @@ fun main() { first.A::bar A::baz - x : KExtensionFunction0 + checkSubtype>(x) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/differentPackageTopLevel.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/differentPackageTopLevel.kt index 9ae2ffb4b6f..b1d196fd7e2 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/differentPackageTopLevel.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/differentPackageTopLevel.kt @@ -1,3 +1,4 @@ +// !CHECK_TYPE // FILE: a.kt package first @@ -21,7 +22,7 @@ fun main() { val y = ::bar val z = ::baz - x : KFunction0 - y : KFunction1 - z : KFunction0 + checkSubtype>(x) + checkSubtype>(y) + checkSubtype>(z) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/extensionFromClass.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/extensionFromClass.kt index 28a873e4de2..7429eb453e2 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/extensionFromClass.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/extensionFromClass.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + import kotlin.reflect.* class A { @@ -6,9 +8,9 @@ class A { val y = ::bar val z = ::baz - x : KExtensionFunction0 - y : KExtensionFunction1 - z : KExtensionFunction0 + checkSubtype>(x) + checkSubtype>(y) + checkSubtype>(z) } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/extensionFromExtension.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/extensionFromExtension.kt index 14c0c8d8e07..a6d251a97ed 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/extensionFromExtension.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/extensionFromExtension.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + import kotlin.reflect.* class A @@ -7,9 +9,9 @@ fun A.main() { val y = ::bar val z = ::baz - x : KExtensionFunction0 - y : KExtensionFunction1 - z : KExtensionFunction0 + checkSubtype>(x) + checkSubtype>(y) + checkSubtype>(z) } fun A.foo() {} diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/extensionFromExtensionInClass.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/extensionFromExtensionInClass.kt index c3007c9c8d1..b45cfba2230 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/extensionFromExtensionInClass.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/extensionFromExtensionInClass.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + import kotlin.reflect.* class B @@ -8,9 +10,9 @@ class A { val y = ::bar val z = ::baz - x : KExtensionFunction0 - y : KExtensionFunction1 - z : KExtensionFunction0 + checkSubtype>(x) + checkSubtype>(y) + checkSubtype>(z) } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/extensionFromTopLevel.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/extensionFromTopLevel.kt index 65b9ae17169..aa54f7a1125 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/extensionFromTopLevel.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/extensionFromTopLevel.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + import kotlin.reflect.* class A @@ -11,7 +13,7 @@ fun main() { val y = A::bar val z = A::baz - x : KExtensionFunction0 - y : KExtensionFunction1 - z : KExtensionFunction0 + checkSubtype>(x) + checkSubtype>(y) + checkSubtype>(z) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/extensionOnNullable.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/extensionOnNullable.kt index 2651906c74d..aa4f0ba464a 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/extensionOnNullable.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/extensionOnNullable.kt @@ -1,3 +1,5 @@ +// !DIAGNOSTICS:-UNUSED_VARIABLE + import kotlin.reflect.* class A { @@ -6,5 +8,5 @@ class A { fun A?.foo() {} -val f = A::foo : KMemberFunction0 -val g = A?::foo : KExtensionFunction0 +val f: KMemberFunction0 = A::foo +val g: KExtensionFunction0 = A?::foo diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/genericClassFromTopLevel.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/genericClassFromTopLevel.kt index 2d8d3ebcb59..17447b9cc58 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/genericClassFromTopLevel.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/genericClassFromTopLevel.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + import kotlin.reflect.KMemberFunction0 class A(val t: T) { @@ -7,5 +9,5 @@ class A(val t: T) { fun bar() { val x = A::foo - x : KMemberFunction0, String> + checkSubtype, String>>(x) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/innerConstructorFromClass.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/innerConstructorFromClass.kt index 516b004dcec..8d1a6dce2eb 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/innerConstructorFromClass.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/innerConstructorFromClass.kt @@ -1,3 +1,4 @@ +// !CHECK_TYPE // !DIAGNOSTICS: -UNUSED_EXPRESSION import kotlin.reflect.KMemberFunction0 @@ -8,8 +9,8 @@ class A { val x = ::Inner val y = A::Inner - x : KMemberFunction0 - y : KMemberFunction0 + checkSubtype>(x) + checkSubtype>(y) } companion object { @@ -17,7 +18,7 @@ class A { ::Inner val y = A::Inner - y : KMemberFunction0 + checkSubtype>(y) } } } @@ -27,6 +28,6 @@ class B { ::Inner val y = A::Inner - y : KMemberFunction0 + checkSubtype>(y) } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/innerConstructorFromExtension.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/innerConstructorFromExtension.kt index 159ddefae5b..c89325b538e 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/innerConstructorFromExtension.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/innerConstructorFromExtension.kt @@ -1,3 +1,4 @@ +// !CHECK_TYPE // !DIAGNOSTICS: -UNUSED_EXPRESSION import kotlin.reflect.KMemberFunction0 @@ -9,13 +10,13 @@ fun A.main() { val x = ::Inner val y = A::Inner - x : KMemberFunction0 - y : KMemberFunction0 + checkSubtype>(x) + checkSubtype>(y) } fun Int.main() { ::Inner val y = A::Inner - y : KMemberFunction0 + checkSubtype>(y) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/innerConstructorFromTopLevel.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/innerConstructorFromTopLevel.kt index 681ed603574..ad744c2c321 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/innerConstructorFromTopLevel.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/innerConstructorFromTopLevel.kt @@ -1,3 +1,4 @@ +// !CHECK_TYPE // !DIAGNOSTICS: -UNUSED_EXPRESSION import kotlin.reflect.KMemberFunction0 @@ -9,5 +10,5 @@ fun main() { ::Inner val y = A::Inner - y : KMemberFunction0 + checkSubtype>(y) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/javaStaticMethod.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/javaStaticMethod.kt index 09149c11656..428d927f687 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/javaStaticMethod.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/javaStaticMethod.kt @@ -1,3 +1,4 @@ +// !CHECK_TYPE // FILE: test/A.java package test @@ -17,7 +18,7 @@ import test.A fun foo(args: Array) { val main2 = A::main - main2 : KFunction1, Unit> + checkSubtype, Unit>>(main2) main2(args) (A::main)(args) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/localConstructor.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/localConstructor.kt index 68c1740041f..d42785c511b 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/localConstructor.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/localConstructor.kt @@ -1,8 +1,10 @@ +// !CHECK_TYPE + import kotlin.reflect.KFunction0 fun main() { class A val x = ::A - x : KFunction0 + checkSubtype>(x) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/localConstructorFromExtensionInLocalClass.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/localConstructorFromExtensionInLocalClass.kt index 4ef1b50c476..28dcb81eeaa 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/localConstructorFromExtensionInLocalClass.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/localConstructorFromExtensionInLocalClass.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + import kotlin.reflect.KFunction0 fun main() { @@ -6,11 +8,11 @@ fun main() { class B { fun Int.foo() { val x = ::A - x : KFunction0 + checkSubtype>(x) } fun A.foo() { val x = ::A - x : KFunction0 + checkSubtype>(x) } } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/localConstructorFromLocalExtension.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/localConstructorFromLocalExtension.kt index 3f14d265479..9fd725f079d 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/localConstructorFromLocalExtension.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/localConstructorFromLocalExtension.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + import kotlin.reflect.KFunction0 fun main() { @@ -5,11 +7,11 @@ fun main() { fun A.foo() { val x = ::A - x : KFunction0 + checkSubtype>(x) } fun Int.foo() { val x = ::A - x : KFunction0 + checkSubtype>(x) } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/localNamedFun.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/localNamedFun.kt index 14620b7956e..ea909dfafe8 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/localNamedFun.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/localNamedFun.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + import kotlin.reflect.* fun main() { @@ -9,7 +11,7 @@ fun main() { val y = ::bar val z = ::baz - x : KFunction0 - y : KFunction1 - z : KFunction0 + checkSubtype>(x) + checkSubtype>(y) + checkSubtype>(z) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/localNamedFunFromExtensionInLocalClass.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/localNamedFunFromExtensionInLocalClass.kt index bdcd5d1a5ff..4c75130d2de 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/localNamedFunFromExtensionInLocalClass.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/localNamedFunFromExtensionInLocalClass.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + import kotlin.reflect.* class A @@ -13,9 +15,9 @@ fun main() { val y = ::bar val z = ::baz - x : KFunction0 - y : KFunction1 - z : KFunction0 + checkSubtype>(x) + checkSubtype>(y) + checkSubtype>(z) } } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/localNamedFunFromLocalClass.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/localNamedFunFromLocalClass.kt index 63bda446c3a..13b5f74b54c 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/localNamedFunFromLocalClass.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/localNamedFunFromLocalClass.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + import kotlin.reflect.* fun main() { @@ -11,9 +13,9 @@ fun main() { val z = ::baz fun main() { - x : KFunction0 - y : KFunction1 - z : KFunction0 + checkSubtype>(x) + checkSubtype>(y) + checkSubtype>(z) } } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/localNamedFunFromLocalExtension.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/localNamedFunFromLocalExtension.kt index 38f840c4c01..2d5c83671ba 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/localNamedFunFromLocalExtension.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/localNamedFunFromLocalExtension.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + import kotlin.reflect.* class A @@ -12,8 +14,8 @@ fun main() { val y = ::bar val z = ::baz - x : KFunction0 - y : KFunction1 - z : KFunction0 + checkSubtype>(x) + checkSubtype>(y) + checkSubtype>(z) } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/longQualifiedName.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/longQualifiedName.kt index 0ab329ba58b..bade88299a3 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/longQualifiedName.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/longQualifiedName.kt @@ -1,3 +1,4 @@ +// !CHECK_TYPE // FILE: a.kt package a.b.c @@ -13,5 +14,5 @@ import kotlin.reflect.KMemberFunction0 fun main() { val x = a.b.c.D::foo - x : KMemberFunction0 + checkSubtype>(x) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/longQualifiedNameGeneric.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/longQualifiedNameGeneric.kt index 2c7a0a4113d..4fdbc8db48a 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/longQualifiedNameGeneric.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/longQualifiedNameGeneric.kt @@ -1,3 +1,4 @@ +// !CHECK_TYPE // FILE: a.kt package a.b.c @@ -13,5 +14,5 @@ import kotlin.reflect.KMemberFunction2 fun main() { val x = a.b.c.D::foo - x : KMemberFunction2, String, Int, a.b.c.D> + checkSubtype, String, Int, a.b.c.D>>(x) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/memberFromClass.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/memberFromClass.kt index ff31682084e..da7cdb14875 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/memberFromClass.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/memberFromClass.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + import kotlin.reflect.* class A { @@ -10,8 +12,8 @@ class A { val y = ::bar val z = ::baz - x : KMemberFunction0 - y : KMemberFunction1 - z : KMemberFunction0 + checkSubtype>(x) + checkSubtype>(y) + checkSubtype>(z) } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/memberFromExtension.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/memberFromExtension.kt index 548a84bf43b..307e5edcdd2 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/memberFromExtension.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/memberFromExtension.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + import kotlin.reflect.* class A { @@ -11,7 +13,7 @@ fun A.main() { val y = ::bar val z = ::baz - x : KMemberFunction0 - y : KMemberFunction1 - z : KMemberFunction0 + checkSubtype>(x) + checkSubtype>(y) + checkSubtype>(z) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/memberFromExtensionInClass.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/memberFromExtensionInClass.kt index 83705355ae4..90b04455703 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/memberFromExtensionInClass.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/memberFromExtensionInClass.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + import kotlin.reflect.* class A { @@ -12,8 +14,8 @@ class B { val y = ::bar val z = ::baz - x : KMemberFunction0 - y : KMemberFunction1 - z : KMemberFunction0 + checkSubtype>(x) + checkSubtype>(y) + checkSubtype>(z) } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/memberFromTopLevel.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/memberFromTopLevel.kt index 22162d65a52..61be0dfb129 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/memberFromTopLevel.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/memberFromTopLevel.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + import kotlin.reflect.* class A { @@ -11,7 +13,7 @@ fun main() { val y = A::bar val z = A::baz - x : KMemberFunction0 - y : KMemberFunction1 - z : KMemberFunction0 + checkSubtype>(x) + checkSubtype>(y) + checkSubtype>(z) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/nestedConstructorFromClass.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/nestedConstructorFromClass.kt index 7e99d54b9df..8fa9274b0ee 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/nestedConstructorFromClass.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/nestedConstructorFromClass.kt @@ -1,3 +1,4 @@ +// !CHECK_TYPE // !DIAGNOSTICS: -UNUSED_EXPRESSION import kotlin.reflect.KFunction0 @@ -8,8 +9,8 @@ class A { val x = ::Nested val y = A::Nested - x : KFunction0 - y : KFunction0 + checkSubtype>(x) + checkSubtype>(y) } companion object { @@ -17,7 +18,7 @@ class A { ::Nested val y = A::Nested - y : KFunction0 + checkSubtype>(y) } } } @@ -27,6 +28,6 @@ class B { ::Nested val y = A::Nested - y : KFunction0 + checkSubtype>(y) } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/nestedConstructorFromExtension.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/nestedConstructorFromExtension.kt index 0a0df534b29..b2f1b654908 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/nestedConstructorFromExtension.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/nestedConstructorFromExtension.kt @@ -1,3 +1,4 @@ +// !CHECK_TYPE // !DIAGNOSTICS: -UNUSED_EXPRESSION import kotlin.reflect.KFunction0 @@ -9,12 +10,12 @@ fun A.main() { ::Nested val y = A::Nested - y : KFunction0 + checkSubtype>(y) } fun Int.main() { ::Nested val y = A::Nested - y : KFunction0 + checkSubtype>(y) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/nestedConstructorFromTopLevel.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/nestedConstructorFromTopLevel.kt index d464aa9de07..1a7e3240ca9 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/nestedConstructorFromTopLevel.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/nestedConstructorFromTopLevel.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + import kotlin.reflect.KFunction0 class A { @@ -7,5 +9,5 @@ class A { fun main() { val x = A::Nested - x : KFunction0 + checkSubtype>(x) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/noAmbiguityMemberVsExtension.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/noAmbiguityMemberVsExtension.kt index b3e8a6756af..773833fcc44 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/noAmbiguityMemberVsExtension.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/noAmbiguityMemberVsExtension.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + import kotlin.reflect.KMemberFunction0 class A { @@ -9,5 +11,5 @@ fun A.foo() {} fun main() { val x = A::foo - x : KMemberFunction0 + checkSubtype>(x) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/noAmbiguityMemberVsTopLevel.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/noAmbiguityMemberVsTopLevel.kt index b6f1f6a9d49..542a48f4ffa 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/noAmbiguityMemberVsTopLevel.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/noAmbiguityMemberVsTopLevel.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + import kotlin.reflect.KMemberFunction0 fun foo() {} @@ -8,6 +10,6 @@ class A { fun main() { val x = ::foo - x : KMemberFunction0 + checkSubtype>(x) } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/renameOnImport.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/renameOnImport.kt index d71da504022..287fe53908a 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/renameOnImport.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/renameOnImport.kt @@ -1,3 +1,4 @@ +// !CHECK_TYPE // FILE: a.kt package other @@ -23,7 +24,7 @@ fun main() { val y = AA::bar val z = AA::bazbaz - x : KFunction0 - y : KMemberFunction0 - z : KExtensionFunction1 + checkSubtype>(x) + checkSubtype>(y) + checkSubtype>(z) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/topLevelFromClass.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/topLevelFromClass.kt index 25908ce1b8b..6d16da4a859 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/topLevelFromClass.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/topLevelFromClass.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + import kotlin.reflect.* fun foo() {} @@ -10,8 +12,8 @@ class A { val y = ::bar val z = ::baz - x : KFunction0 - y : KFunction1 - z : KFunction0 + checkSubtype>(x) + checkSubtype>(y) + checkSubtype>(z) } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/topLevelFromExtension.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/topLevelFromExtension.kt index c39d37b241d..3c624df7123 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/topLevelFromExtension.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/topLevelFromExtension.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + import kotlin.reflect.* class A @@ -11,7 +13,7 @@ fun A.main() { val y = ::bar val z = ::baz - x : KFunction0 - y : KFunction1 - z : KFunction0 + checkSubtype>(x) + checkSubtype>(y) + checkSubtype>(z) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/topLevelFromExtensionInClass.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/topLevelFromExtensionInClass.kt index 7d717d2d4e6..9890a849f2e 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/topLevelFromExtensionInClass.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/topLevelFromExtensionInClass.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + import kotlin.reflect.* class A @@ -12,8 +14,8 @@ class B { val y = ::bar val z = ::baz - x : KFunction0 - y : KFunction1 - z : KFunction0 + checkSubtype>(x) + checkSubtype>(y) + checkSubtype>(z) } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/topLevelFromTopLevel.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/topLevelFromTopLevel.kt index f3d0b9a7bd3..42f20e8b517 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/topLevelFromTopLevel.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/topLevelFromTopLevel.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + import kotlin.reflect.* fun foo() {} @@ -9,7 +11,7 @@ fun main() { val y = ::bar val z = ::baz - x : KFunction0 - y : KFunction1 - z : KFunction0 + checkSubtype>(x) + checkSubtype>(y) + checkSubtype>(z) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/abstractPropertyViaSubclasses.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/abstractPropertyViaSubclasses.kt index 55c17425814..1c7924844a1 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/abstractPropertyViaSubclasses.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/abstractPropertyViaSubclasses.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + import kotlin.reflect.KMemberProperty trait Base { @@ -18,17 +20,17 @@ class C : B() { fun test() { val base = Base::x - base : KMemberProperty - base.get(A()) : Any - base.get(B()) : Number - base.get(C()) : Int + checkSubtype>(base) + checkSubtype(base.get(A())) + checkSubtype(base.get(B())) + checkSubtype(base.get(C())) val a = A::x - a : KMemberProperty - a.get(A()) : String - a.get(B()) : Number + checkSubtype>(a) + checkSubtype(a.get(A())) + checkSubtype(a.get(B())) val b = B::x - b : KMemberProperty - b.get(C()) : Int + checkSubtype>(b) + checkSubtype(b.get(C())) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/accessViaSubclass.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/accessViaSubclass.kt index 8c533fbc044..44bba28e333 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/accessViaSubclass.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/accessViaSubclass.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + import kotlin.reflect.KMemberProperty open class Base { @@ -8,6 +10,6 @@ open class Derived : Base() fun test() { val o = Base::foo - o : KMemberProperty - o.get(Derived()) : Int + checkSubtype>(o) + checkSubtype(o.get(Derived())) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/classFromClass.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/classFromClass.kt index f4686a586d8..65ef1ee9ca2 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/classFromClass.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/classFromClass.kt @@ -1,10 +1,12 @@ +// !DIAGNOSTICS:-UNUSED_VARIABLE + import kotlin.reflect.* class A(var g: A) { val f: Int = 0 fun test() { - ::f : KMemberProperty - ::g : KMutableMemberProperty + val fRef: KMemberProperty = ::f + val gRef: KMutableMemberProperty = ::g } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/extensionFromClass.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/extensionFromClass.kt index a15f054d3ff..ac92c4a0dbc 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/extensionFromClass.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/extensionFromClass.kt @@ -1,9 +1,11 @@ +// !DIAGNOSTICS:-UNUSED_VARIABLE + import kotlin.reflect.* class A { fun test() { - ::foo : KExtensionProperty - ::bar : KMutableExtensionProperty + val fooRef: KExtensionProperty = ::foo + val barRef: KMutableExtensionProperty = ::bar } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/extensionFromTopLevel.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/extensionFromTopLevel.kt index 245d870afad..dbb76a0e063 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/extensionFromTopLevel.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/extensionFromTopLevel.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + import kotlin.reflect.* val String.countCharacters: Int @@ -10,18 +12,18 @@ var Int.meaning: Long fun test() { val f = String::countCharacters - f : KTopLevelExtensionProperty - f : KExtensionProperty - f : KMutableExtensionProperty - f.get("abc") : Int + checkSubtype>(f) + checkSubtype>(f) + checkSubtype>(f) + checkSubtype(f.get("abc")) f.set("abc", 0) val g = Int::meaning - g : KTopLevelExtensionProperty - g : KExtensionProperty - g : KMutableTopLevelExtensionProperty - g : KMutableExtensionProperty - g.get(0) : Long + checkSubtype>(g) + checkSubtype>(g) + checkSubtype>(g) + checkSubtype>(g) + checkSubtype(g.get(0)) g.set(1, 0L) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/extensionPropertyOnNullable.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/extensionPropertyOnNullable.kt index 10c3c1de770..ac0014dd549 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/extensionPropertyOnNullable.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/extensionPropertyOnNullable.kt @@ -1,8 +1,10 @@ +// !CHECK_TYPE + val Any?.meaning: Int get() = 42 fun test() { val f = Any?::meaning - f.get(null) : Int - f.get("") : Int + checkSubtype(f.get(null)) + checkSubtype(f.get("")) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/genericClass.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/genericClass.kt index 9b1ff0d1b05..a741e69b357 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/genericClass.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/genericClass.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + import kotlin.reflect.KMemberProperty class A(val t: T) { @@ -6,9 +8,9 @@ class A(val t: T) { fun bar() { val x = A::foo - x : KMemberProperty, String> - x : KMemberProperty, Any?> + checkSubtype, String>>(x) + checkSubtype, Any?>>(x) val y = A<*>::foo - y : KMemberProperty, Any?> + checkSubtype, Any?>>(y) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/javaInstanceField.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/javaInstanceField.kt index 18ec86372b4..7304ad21fdf 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/javaInstanceField.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/javaInstanceField.kt @@ -1,3 +1,4 @@ +// !DIAGNOSTICS:-UNUSED_VARIABLE // FILE: JavaClass.java public class JavaClass { @@ -16,10 +17,10 @@ public class JavaClass { import kotlin.reflect.* fun test() { - JavaClass::publicFinal : KMemberProperty - JavaClass::publicMutable : KMutableMemberProperty - JavaClass::protectedFinal : KMemberProperty - JavaClass::protectedMutable : KMutableMemberProperty - JavaClass::privateFinal : KMemberProperty - JavaClass::privateMutable : KMutableMemberProperty + val pubFinRef: KMemberProperty = JavaClass::publicFinal + val pubMutRef: KMutableMemberProperty = JavaClass::publicMutable + val protFinRef: KMemberProperty = JavaClass::protectedFinal + val protMutRef: KMutableMemberProperty = JavaClass::protectedMutable + val privFinRef: KMemberProperty = JavaClass::privateFinal + val privMutRef: KMutableMemberProperty = JavaClass::privateMutable } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/javaStaticFieldViaImport.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/javaStaticFieldViaImport.kt index 51bb4a55793..1d3017e8e4a 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/javaStaticFieldViaImport.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/javaStaticFieldViaImport.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE +// !DIAGNOSTICS:-UNUSED_VARIABLE // FILE: JavaClass.java public class JavaClass { @@ -18,10 +20,10 @@ import JavaClass.* import kotlin.reflect.* fun test() { - ::publicFinal : KTopLevelProperty - ::publicMutable : KMutableTopLevelProperty - ::protectedFinal : KProperty - ::protectedMutable : KMutableProperty - ::privateFinal : KProperty - ::privateMutable : KMutableProperty + val pubFinRef: KTopLevelProperty = ::publicFinal + val pubMutRef: KMutableTopLevelProperty = ::publicMutable + val protFinRef: KProperty = ::protectedFinal + val protMutRef: KMutableProperty = ::protectedMutable + val privFinRef: KProperty = ::privateFinal + val privMutRef: KMutableProperty = ::privateMutable } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/memberFromExtension.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/memberFromExtension.kt index fa4cbc568e1..24b84678ee1 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/memberFromExtension.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/memberFromExtension.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + import kotlin.reflect.* class A { @@ -13,9 +15,9 @@ fun A.test() { val y = ::bar val z = ::self - x : KMemberProperty - y : KMutableMemberProperty - z : KMutableMemberProperty + checkSubtype>(x) + checkSubtype>(y) + checkSubtype>(z) y.set(z.get(A()), x.get(A()).toString()) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/memberFromTopLevel.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/memberFromTopLevel.kt index a95d1dbfc39..8ba830c6506 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/memberFromTopLevel.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/memberFromTopLevel.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + import kotlin.reflect.* class A { @@ -8,16 +10,16 @@ class A { fun test() { val p = A::foo - p : KMemberProperty - p : KMutableMemberProperty - p.get(A()) : Int + checkSubtype>(p) + checkSubtype>(p) + checkSubtype(p.get(A())) p.get() p.set(A(), 239) val q = A::bar - q : KMemberProperty - q : KMutableMemberProperty - q.get(A()): String + checkSubtype>(q) + checkSubtype>(q) + checkSubtype(q.get(A())) q.set(A(), "q") } diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/samePriorityForFunctionsAndProperties.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/samePriorityForFunctionsAndProperties.kt index 6a4a3e07b96..2065b87f8d4 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/samePriorityForFunctionsAndProperties.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/samePriorityForFunctionsAndProperties.kt @@ -9,5 +9,5 @@ class C { fun Int.baz() {} fun test() { - C::baz checkType { it : _>} + C::baz checkType { _>() } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/topLevelFromTopLevel.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/topLevelFromTopLevel.kt index 8069c3ae562..800a8c4018a 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/topLevelFromTopLevel.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/topLevelFromTopLevel.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + import kotlin.reflect.* var x: Int = 42 @@ -5,29 +7,29 @@ val y: String get() = "y" fun testX() { val xx = ::x - xx : KMutableTopLevelProperty - xx : KMutableTopLevelVariable - xx : KTopLevelProperty - xx : KTopLevelVariable - xx : KMutableProperty - xx : KMutableVariable - xx : KProperty - xx : KCallable + checkSubtype>(xx) + checkSubtype>(xx) + checkSubtype>(xx) + checkSubtype>(xx) + checkSubtype>(xx) + checkSubtype>(xx) + checkSubtype>(xx) + checkSubtype>(xx) - xx.name : String - xx.get() : Int + checkSubtype(xx.name) + checkSubtype(xx.get()) xx.set(239) } fun testY() { val yy = ::y - yy : KMutableTopLevelProperty - yy : KTopLevelVariable - yy : KMutableProperty - yy : KProperty - yy : KCallable + checkSubtype>(yy) + checkSubtype>(yy) + checkSubtype>(yy) + checkSubtype>(yy) + checkSubtype>(yy) - yy.name : String - yy.get() : String + checkSubtype(yy.name) + checkSubtype(yy.get()) yy.set("yy") } diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/arrayConstructor.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/arrayConstructor.kt index 703458ea171..919b8578b2d 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/arrayConstructor.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/arrayConstructor.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + package b fun bar() { @@ -5,8 +7,8 @@ fun bar() { val a2 = Array(1, {i: Int -> "$i"}) val a3 = Array(1, {it}) - a1 : Array - a2 : Array - a3 : Array + checkSubtype>(a1) + checkSubtype>(a2) + checkSubtype>(a3) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/kt1558.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/kt1558.kt index 3429645a12e..8a1f41aac69 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/kt1558.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/kt1558.kt @@ -1,3 +1,5 @@ +// !CHECK_TYPE + //KT-1558 Exception while analyzing package j @@ -16,9 +18,9 @@ fun testArrays(ci: List, cii: List?) { val c5 = ci.toArray(Array()) - c1 : Array - c2 : Array - c3 : Array - c4 : Array - c5 : Array + checkSubtype>(c1) + checkSubtype>(c2) + checkSubtype>(c3) + checkSubtype>(c4) + checkSubtype>(c5) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/varargs/kt3213.kt b/compiler/testData/diagnostics/testsWithStdLib/varargs/kt3213.kt index ed0805c50cd..2ba6c1b72f4 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/varargs/kt3213.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/varargs/kt3213.kt @@ -3,5 +3,5 @@ fun test(a: Array) { val b = a.toList() - b checkType { it : _> } + b checkType { _>() } } \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/BaseDiagnosticsTest.java b/compiler/tests/org/jetbrains/kotlin/checkers/BaseDiagnosticsTest.java index 7f4762c9b44..071b2a4559c 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/BaseDiagnosticsTest.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/BaseDiagnosticsTest.java @@ -65,8 +65,10 @@ public abstract class BaseDiagnosticsTest extends public static final String CHECK_TYPE_DIRECTIVE = "CHECK_TYPE"; public static final String CHECK_TYPE_PACKAGE = "tests._checkType"; private static final String CHECK_TYPE_DECLARATIONS = "\npackage " + CHECK_TYPE_PACKAGE + - "\nclass _" + - "\nfun T.checkType(f: (_) -> Unit) = f"; + "\nfun checkSubtype(t: T) = t" + + "\nclass Inv" + + "\nfun Inv._() {}" + + "\nfun T.checkType(f: Inv.() -> Unit) {}"; public static final String CHECK_TYPE_IMPORT = "import " + CHECK_TYPE_PACKAGE + ".*"; public static final String EXPLICIT_FLEXIBLE_TYPES_DIRECTIVE = "EXPLICIT_FLEXIBLE_TYPES"; diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index 1240cfe16bf..622aa293815 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -6543,12 +6543,6 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } - @TestMetadata("typed.kt") - public void testTyped() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inline/typed.kt"); - doTest(fileName); - } - @TestMetadata("unsupportedConstruction.kt") public void testUnsupportedConstruction() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inline/unsupportedConstruction.kt"); diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/JetBundle.properties b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/JetBundle.properties index 326c7710e51..17b34f02001 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/JetBundle.properties +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/JetBundle.properties @@ -32,7 +32,6 @@ remove.parts.from.property=Remove {0} from property remove.parts.from.property.family=Remove Parts from Property remove.psi.element.family=Remove Element remove.right.part.of.binary.expression=Remove right part of a binary expression -remove.cast=Remove cast remove.elvis.operator=Remove elvis operator remove.redundant.nullable=Remove redundant '?' remove.supertype=Remove supertype ''{0}'' diff --git a/idea/src/org/jetbrains/kotlin/idea/j2k/J2kPostProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/j2k/J2kPostProcessor.kt index 0070ca6bf01..8707746b56a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/j2k/J2kPostProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/j2k/J2kPostProcessor.kt @@ -54,7 +54,7 @@ public class J2kPostProcessor(private val formatCode: Boolean) : PostProcessor { override fun fixForProblem(problem: Diagnostic): (() -> Unit)? { val psiElement = problem.getPsiElement() return when (problem.getFactory()) { - Errors.USELESS_CAST, Errors.USELESS_CAST_STATIC_ASSERT_IS_FINE -> { -> + Errors.USELESS_CAST -> { -> val expression = RemoveRightPartOfBinaryExpressionFix(psiElement as JetBinaryExpressionWithTypeRHS, "").invoke() val variable = expression.getParent() as? JetProperty diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.java b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.java index 5dbfc6c3cbd..1560d3c4098 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.java +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.java @@ -17,11 +17,11 @@ package org.jetbrains.kotlin.idea.quickfix; import org.jetbrains.kotlin.idea.core.codeInsight.ImplementMethodsHandler; +import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createCallable.*; import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createClass.CreateClassFromCallWithConstructorCalleeActionFactory; import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createClass.CreateClassFromConstructorCallActionFactory; import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createClass.CreateClassFromReferenceExpressionActionFactory; import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createClass.CreateClassFromTypeReferenceActionFactory; -import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createCallable.*; import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createVariable.CreateLocalVariableActionFactory; import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createVariable.CreateParameterActionFactory; import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createVariable.CreateParameterByNamedArgumentActionFactory; @@ -88,9 +88,10 @@ public class QuickFixRegistrar { QuickFixes.factories.put(NOTHING_TO_OVERRIDE, AddFunctionToSupertypeFix.createFactory()); QuickFixes.factories.put(VIRTUAL_MEMBER_HIDDEN, AddModifierFix.createFactory(OVERRIDE_KEYWORD)); - QuickFixes.factories.put(USELESS_CAST_STATIC_ASSERT_IS_FINE, ReplaceOperationInBinaryExpressionFix.createChangeCastToStaticAssertFactory()); - QuickFixes.factories.put(USELESS_CAST, RemoveRightPartOfBinaryExpressionFix.createRemoveCastFactory()); - QuickFixes.factories.put(USELESS_CAST_STATIC_ASSERT_IS_FINE, RemoveRightPartOfBinaryExpressionFix.createRemoveCastFactory()); + QuickFixes.factories.put(USELESS_CAST, RemoveRightPartOfBinaryExpressionFix.createRemoveTypeFromBinaryExpressionFactory( + "Remove cast")); + QuickFixes.factories.put(DEPRECATED_STATIC_ASSERT, RemoveRightPartOfBinaryExpressionFix.createRemoveTypeFromBinaryExpressionFactory( + "Remove static type assertion")); JetSingleIntentionActionFactory changeAccessorTypeFactory = ChangeAccessorTypeFix.createFactory(); QuickFixes.factories.put(WRONG_SETTER_PARAMETER_TYPE, changeAccessorTypeFactory); diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/RemoveRightPartOfBinaryExpressionFix.java b/idea/src/org/jetbrains/kotlin/idea/quickfix/RemoveRightPartOfBinaryExpressionFix.java index faf04da27a7..ff3c2b355f7 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/RemoveRightPartOfBinaryExpressionFix.java +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/RemoveRightPartOfBinaryExpressionFix.java @@ -69,13 +69,13 @@ public class RemoveRightPartOfBinaryExpressionFix exten return newExpression; } - public static JetSingleIntentionActionFactory createRemoveCastFactory() { + public static JetSingleIntentionActionFactory createRemoveTypeFromBinaryExpressionFactory(final String message) { return new JetSingleIntentionActionFactory() { @Override public JetIntentionAction createAction(Diagnostic diagnostic) { JetBinaryExpressionWithTypeRHS expression = QuickFixUtil.getParentElementOfType(diagnostic, JetBinaryExpressionWithTypeRHS.class); if (expression == null) return null; - return new RemoveRightPartOfBinaryExpressionFix(expression, JetBundle.message("remove.cast")); + return new RemoveRightPartOfBinaryExpressionFix(expression, message); } }; } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceOperationInBinaryExpressionFix.java b/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceOperationInBinaryExpressionFix.java index b1ab1b861ec..0285987038e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceOperationInBinaryExpressionFix.java +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceOperationInBinaryExpressionFix.java @@ -20,9 +20,7 @@ import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.diagnostics.Diagnostic; import org.jetbrains.kotlin.idea.JetBundle; -import org.jetbrains.kotlin.idea.core.quickfix.QuickFixUtil; import org.jetbrains.kotlin.psi.JetBinaryExpressionWithTypeRHS; import org.jetbrains.kotlin.psi.JetExpression; import org.jetbrains.kotlin.psi.JetFile; @@ -55,22 +53,4 @@ public abstract class ReplaceOperationInBinaryExpressionFix createAction(Diagnostic diagnostic) { - JetBinaryExpressionWithTypeRHS expression = QuickFixUtil - .getParentElementOfType(diagnostic, JetBinaryExpressionWithTypeRHS.class); - if (expression == null) return null; - return new ReplaceOperationInBinaryExpressionFix(expression, " : ") { - @NotNull - @Override - public String getText() { - return JetBundle.message("replace.cast.with.static.assert"); - } - }; - } - }; - } } diff --git a/idea/testData/checker/Casts.kt b/idea/testData/checker/Casts.kt index c4264cf2a8e..cc233038c52 100644 --- a/idea/testData/checker/Casts.kt +++ b/idea/testData/checker/Casts.kt @@ -1,16 +1,18 @@ +fun checkSubtype(t: T) = t + fun test() : Unit { var x : Int? = 0 var y : Int = 0 - x : Int? - y : Int - x as Int : Int - y as Int : Int - x as Int? : Int? - y as Int? : Int? - x as Int? : Int? - y as? Int : Int? - x as? Int? : Int? - y as? Int? : Int? + checkSubtype(x) + checkSubtype(y) + checkSubtype(x as Int) + checkSubtype(y as Int) + checkSubtype(x as Int?) + checkSubtype(y as Int?) + checkSubtype(x as Int?) + checkSubtype(y as? Int) + checkSubtype(x as? Int?) + checkSubtype(y as? Int?) Unit } diff --git a/idea/testData/checker/Constants.kt b/idea/testData/checker/Constants.kt index 453cffee895..312c194d9f7 100644 --- a/idea/testData/checker/Constants.kt +++ b/idea/testData/checker/Constants.kt @@ -1,7 +1,9 @@ +fun checkSubtype(t: T) = t + fun test() { - 1 : Byte - 1 : Int - 1 : Double + checkSubtype(1) + checkSubtype(1) + checkSubtype(1) 1 as Byte 1 as Int 1 as Double diff --git a/idea/testData/checker/ForRangeConventions.kt b/idea/testData/checker/ForRangeConventions.kt index 5ec0337fe07..da0c48a03b2 100644 --- a/idea/testData/checker/ForRangeConventions.kt +++ b/idea/testData/checker/ForRangeConventions.kt @@ -1,5 +1,7 @@ import java.util.*; +fun checkSubtype(t: T) = t + class NotRange1() { } @@ -76,6 +78,6 @@ fun test(notRange1: NotRange1, notRange2: NotRange2, notRange3: NotRange3, notRa for (i in range0); for (i in range1); - for (i in (ArrayList() : List)); + for (i in (checkSubtype>(ArrayList()))); } diff --git a/idea/testData/checker/QualifiedThisInClosures.kt b/idea/testData/checker/QualifiedThisInClosures.kt index 8026d631cd9..43af80f8b90 100644 --- a/idea/testData/checker/QualifiedThisInClosures.kt +++ b/idea/testData/checker/QualifiedThisInClosures.kt @@ -1,16 +1,18 @@ - class A(val a:Int) { +fun checkSubtype(t: T) = t + +class A(val a:Int) { inner class B() { - val x = this@B : B - val y = this@A : A - val z = this : B - val Int.xx : Int get() = this : Int + val x = checkSubtype(this@B) + val y = checkSubtype(this@A) + val z = checkSubtype(this) + val Int.xx : Int get() = checkSubtype(this) fun Char.xx() : Double.() -> Unit { - this : Char - val a: Double.() -> Unit = { this : Double + this@xx : Char} - val b: Double.() -> Unit = a@{this@a : Double + this@xx : Char} - val c = a@{this@a + this@xx : Char} - return (a@{this@a : Double + this@xx : Char}) + checkSubtype(this) + val a: Double.() -> Unit = { checkSubtype(this) + checkSubtype(this@xx) } + val b: Double.() -> Unit = a@{checkSubtype(this@a) + checkSubtype(this@xx) } + val c = a@{this@a + checkSubtype(this@xx) } + return (a@{checkSubtype(this@a) + checkSubtype(this@xx) }) } } } diff --git a/idea/testData/checker/ResolveToJava.kt b/idea/testData/checker/ResolveToJava.kt index 383532b0e39..6fe47e93ad6 100644 --- a/idea/testData/checker/ResolveToJava.kt +++ b/idea/testData/checker/ResolveToJava.kt @@ -6,6 +6,8 @@ import utils.* import java.io.PrintStream import java.lang.Comparable as Com +fun checkSubtype(t: T) = t + val l : MutableList = ArrayList() fun test(l : List) { @@ -22,7 +24,7 @@ fun test(l : List) { Collections.emptyList() Collections.emptyList() - Collections.singleton(1) : Set? + checkSubtype?>(Collections.singleton(1)) Collections.singleton(1.0) List @@ -41,7 +43,7 @@ fun test(l : List) { val c : Com? = null - c : java.lang.Comparable? + checkSubtype<java.lang.Comparable?>(c) // Collections.sort(ArrayList()) } diff --git a/idea/testData/checker/Unused.kt b/idea/testData/checker/Unused.kt index 0152159999a..c21a7877da4 100644 --- a/idea/testData/checker/Unused.kt +++ b/idea/testData/checker/Unused.kt @@ -1,7 +1,6 @@ fun test(unusedParam: Int) { // UNUSED_PARAMETER val str = ":)" str as String // USELESS_CAST - str as Any // USELESS_CAST_STATIC_ASSERT_IS_FINE // UNUSED_FUNCTION_LITERAL { diff --git a/idea/testData/checker/regression/Jet53.kt b/idea/testData/checker/regression/Jet53.kt index 4bf62908dc0..bb638c90294 100644 --- a/idea/testData/checker/regression/Jet53.kt +++ b/idea/testData/checker/regression/Jet53.kt @@ -1,3 +1,5 @@ import java.util.Collections -val ab = Collections.emptyList() : List? \ No newline at end of file +fun checkSubtype(t: T) = t + +val ab = checkSubtype?>(Collections.emptyList()) \ No newline at end of file diff --git a/idea/testData/checker/regression/ScopeForSecondaryConstructors.kt b/idea/testData/checker/regression/ScopeForSecondaryConstructors.kt index 60ee52ef9e9..8c79b0ca048 100644 --- a/idea/testData/checker/regression/ScopeForSecondaryConstructors.kt +++ b/idea/testData/checker/regression/ScopeForSecondaryConstructors.kt @@ -1,18 +1,20 @@ - class Foo(var bar : Int, var barr : Int, var barrr : Int) { - init { - bar = 1 - barr = 1 - barrr = 1 - 1 : Int - this : Foo - } +fun checkSubtype(t: T) = t - init { - bar = 1 - this.bar - 1 : Int - val a : Int =1 - this : Foo - } +class Foo(var bar : Int, var barr : Int, var barrr : Int) { + init { + bar = 1 + barr = 1 + barrr = 1 + checkSubtype(1) + checkSubtype(this) } + init { + bar = 1 + this.bar + checkSubtype(1) + val a : Int =1 + checkSubtype(this) + } +} + diff --git a/idea/testData/quickfix/expressions/afterRemoveStaticTypeAssertion.kt b/idea/testData/quickfix/expressions/afterRemoveStaticTypeAssertion.kt new file mode 100644 index 00000000000..cc1ec84fe9f --- /dev/null +++ b/idea/testData/quickfix/expressions/afterRemoveStaticTypeAssertion.kt @@ -0,0 +1,4 @@ +// "Remove static type assertion" "true" +fun foo(a: String) { + val b = a +} diff --git a/idea/testData/quickfix/expressions/afterReplaceUselessCastWithStaticAssert.kt b/idea/testData/quickfix/expressions/afterReplaceUselessCastWithStaticAssert.kt deleted file mode 100644 index 792e9c049bb..00000000000 --- a/idea/testData/quickfix/expressions/afterReplaceUselessCastWithStaticAssert.kt +++ /dev/null @@ -1,4 +0,0 @@ -// "Replace a cast with a static assert" "true" -fun foo(a: String) { - val b = a : Any -} diff --git a/idea/testData/quickfix/expressions/beforeRemoveStaticTypeAssertion.kt b/idea/testData/quickfix/expressions/beforeRemoveStaticTypeAssertion.kt new file mode 100644 index 00000000000..a729da97899 --- /dev/null +++ b/idea/testData/quickfix/expressions/beforeRemoveStaticTypeAssertion.kt @@ -0,0 +1,4 @@ +// "Remove static type assertion" "true" +fun foo(a: String) { + val b = a : Any +} diff --git a/idea/testData/quickfix/expressions/beforeReplaceUselessCastWithStaticAssert.kt b/idea/testData/quickfix/expressions/beforeReplaceUselessCastWithStaticAssert.kt deleted file mode 100644 index ab4debc2fe2..00000000000 --- a/idea/testData/quickfix/expressions/beforeReplaceUselessCastWithStaticAssert.kt +++ /dev/null @@ -1,4 +0,0 @@ -// "Replace a cast with a static assert" "true" -fun foo(a: String) { - val b = a as Any -} diff --git a/idea/testData/quickfix/typeMismatch/casts/beforeTypeMismatch5.kt b/idea/testData/quickfix/typeMismatch/casts/beforeTypeMismatch5.kt deleted file mode 100644 index 1d5b04b34d2..00000000000 --- a/idea/testData/quickfix/typeMismatch/casts/beforeTypeMismatch5.kt +++ /dev/null @@ -1,5 +0,0 @@ -// "Cast expression 'x' to 'String'" "false" -// ERROR: Type mismatch.
Required:kotlin.String
Found:kotlin.Int
-fun foo(x: Int) { - x: String -} \ No newline at end of file diff --git a/idea/testData/quickfix/typeMismatch/parameterTypeMismatch/beforeChangeFunctionParameterType4.kt b/idea/testData/quickfix/typeMismatch/parameterTypeMismatch/beforeChangeFunctionParameterType4.kt index 8caa98a7e73..c6c482f82ee 100644 --- a/idea/testData/quickfix/typeMismatch/parameterTypeMismatch/beforeChangeFunctionParameterType4.kt +++ b/idea/testData/quickfix/typeMismatch/parameterTypeMismatch/beforeChangeFunctionParameterType4.kt @@ -1,5 +1,4 @@ // "Change parameter 'z' type of function 'foo' to '(Int) -> String'" "false" -// ERROR: Type mismatch.
Required:kotlin.Int
Found:kotlin.String
// ACTION: Disable 'Move Lambda Function Into Parentheses' // ACTION: Edit intention settings @@ -7,7 +6,7 @@ fun foo(y: Int = 0, z: (Int) -> String = {""}) { foo { - "": Int + "" as Int "" } } \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java index 0b28cabad60..e8c120d0266 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java @@ -2866,6 +2866,12 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest { JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/expressions"), Pattern.compile("^before(\\w+)\\.kt$"), true); } + @TestMetadata("beforeRemoveStaticTypeAssertion.kt") + public void testRemoveStaticTypeAssertion() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/expressions/beforeRemoveStaticTypeAssertion.kt"); + doTest(fileName); + } + @TestMetadata("beforeRemoveUselessCast.kt") public void testRemoveUselessCast() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/expressions/beforeRemoveUselessCast.kt"); @@ -2884,12 +2890,6 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest { doTest(fileName); } - @TestMetadata("beforeReplaceUselessCastWithStaticAssert.kt") - public void testReplaceUselessCastWithStaticAssert() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/expressions/beforeReplaceUselessCastWithStaticAssert.kt"); - doTest(fileName); - } - @TestMetadata("beforeUnnecessaryNonNullAssertion1.kt") public void testUnnecessaryNonNullAssertion1() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/expressions/beforeUnnecessaryNonNullAssertion1.kt"); @@ -4916,12 +4916,6 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest { doTest(fileName); } - @TestMetadata("beforeTypeMismatch5.kt") - public void testTypeMismatch5() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/typeMismatch/casts/beforeTypeMismatch5.kt"); - doTest(fileName); - } - @TestMetadata("beforeTypeMismatchLongNameRuntime.kt") public void testTypeMismatchLongNameRuntime() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/typeMismatch/casts/beforeTypeMismatchLongNameRuntime.kt");