From 419f54259cd159e364af4492039ab82cf22ab099 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Thu, 12 Nov 2020 17:45:40 +0300 Subject: [PATCH] [TEST] Change semantics of `CHECK_TYPE` directive and update testdata Previously helpers from checkType.kt was in special package, and if directive was enabled then test runner (`AbstractDiagnosticTest`) injected additional imports to test files and removed them after test was completed. It's very hard to support such behavior in new test infrastructure so there was a decision about changing `CHECK_TYPE`: 1. All helpers from `checkType.kt` now stays in default package 2. `CHECK_TYPE` only adds `checkType.kt` to set of analyzed files and don't modify their content For test which are written in default package (most of tests actually) there are no changes. On the other hand if there is a test where dev want to use checkType functions in testfile with some package then he should explicitly import functions which he needed (`checkSubtype`, `checkType`, `_`) --- ...ntheticPropertiesWrongImplicitReceiver.txt | 16 +++---- .../resolve/lambdaArgInScopeFunction.txt | 24 +++++----- .../resolve/lambdaPropertyTypeInference.txt | 32 +++++++------- .../testData/resolve/objectInnerClass.txt | 8 ++-- .../resolve/overrides/simpleMostSpecific.txt | 44 +++++++++---------- .../diagnostics/helpers/types/checkType.kt | 8 ++-- .../tests/FunctionCalleeExpressions.fir.kt | 3 ++ .../tests/FunctionCalleeExpressions.kt | 3 ++ .../bound/companionObject.fir.kt | 2 + .../bound/companionObject.kt | 2 + .../function/differentPackageClass.fir.kt | 4 +- .../function/differentPackageClass.kt | 4 +- .../function/differentPackageExtension.fir.kt | 3 ++ .../function/differentPackageExtension.kt | 3 ++ .../function/differentPackageTopLevel.fir.kt | 3 ++ .../function/differentPackageTopLevel.kt | 3 ++ .../kt2631_MultipleDeclaration.fir.kt | 4 +- .../kt2631_MultipleDeclaration.kt | 4 +- .../checkDeparenthesizedType.fir.kt | 2 + .../checkDeparenthesizedType.kt | 2 + .../completeInferenceIfManyFailed.fir.kt | 2 + .../completeInferenceIfManyFailed.kt | 4 +- .../inference/dependOnExpectedType.fir.kt | 1 + .../tests/inference/dependOnExpectedType.kt | 1 + .../inference/functionPlaceholderError.fir.kt | 4 +- .../inference/functionPlaceholderError.kt | 4 +- .../tests/inference/listConstructor.fir.kt | 1 + .../tests/inference/listConstructor.kt | 1 + .../tests/inference/mapFunction.fir.kt | 3 +- .../tests/inference/mapFunction.kt | 3 +- .../mostSpecificAfterInference.fir.kt | 3 +- .../inference/mostSpecificAfterInference.kt | 3 +- .../inferenceForNestedBinaryCall.kt | 2 + .../tests/inference/regressions/kt1029.fir.kt | 2 + .../tests/inference/regressions/kt1029.kt | 2 + .../tests/inference/regressions/kt1031.fir.kt | 1 + .../tests/inference/regressions/kt1031.kt | 1 + .../tests/inference/regressions/kt1145.fir.kt | 4 +- .../tests/inference/regressions/kt1145.kt | 4 +- .../tests/inference/regressions/kt1410.fir.kt | 4 +- .../tests/inference/regressions/kt1410.kt | 4 +- .../tests/inference/regressions/kt1718.fir.kt | 3 +- .../tests/inference/regressions/kt1718.kt | 3 +- .../tests/inference/regressions/kt1944.kt | 2 + .../tests/inference/regressions/kt2179.fir.kt | 1 + .../tests/inference/regressions/kt2179.kt | 1 + .../tests/inference/regressions/kt2200.fir.kt | 3 +- .../tests/inference/regressions/kt2200.kt | 3 +- .../tests/inference/regressions/kt2294.kt | 1 + .../tests/inference/regressions/kt2324.fir.kt | 1 + .../tests/inference/regressions/kt2324.kt | 1 + .../tests/inference/regressions/kt2407.fir.kt | 3 +- .../tests/inference/regressions/kt2407.kt | 3 +- .../tests/inference/regressions/kt2505.kt | 2 + .../tests/inference/regressions/kt731.fir.kt | 4 +- .../tests/inference/regressions/kt731.kt | 4 +- .../tests/inference/regressions/kt943.fir.kt | 3 +- .../tests/inference/regressions/kt943.kt | 3 +- .../tests/inference/regressions/kt948.fir.kt | 3 +- .../tests/inference/regressions/kt948.kt | 3 +- .../conflictingSubstitutionsFromUpperBound.kt | 3 ++ .../upperBounds/intersectUpperBounds.fir.kt | 4 +- .../upperBounds/intersectUpperBounds.kt | 4 +- .../testData/diagnostics/tests/j+k/kt2394.kt | 2 + .../diagnostics/tests/j+k/kt2641.fir.kt | 4 +- .../testData/diagnostics/tests/j+k/kt2641.kt | 4 +- .../nullabilityAndSmartCasts/kt1778.fir.kt | 4 +- .../tests/nullabilityAndSmartCasts/kt1778.kt | 4 +- .../nullabilityAndSmartCasts/kt2176.fir.kt | 2 + .../tests/nullabilityAndSmartCasts/kt2176.kt | 2 + .../nullabilityAndSmartCasts/kt2234.fir.kt | 2 + .../tests/nullabilityAndSmartCasts/kt2234.kt | 2 + .../numbers/doublesInSimpleConstraints.fir.kt | 4 +- .../numbers/doublesInSimpleConstraints.kt | 4 +- .../numbers/numbersInSimpleConstraints.fir.kt | 4 ++ .../numbers/numbersInSimpleConstraints.kt | 4 ++ .../explicitFlexibleWithPackage.fir.kt | 5 ++- .../explicitFlexibleWithPackage.kt | 5 ++- .../scopes/protectedVisibility/kt7971.fir.kt | 2 + .../scopes/protectedVisibility/kt7971.kt | 2 + .../inference/intersectionTypes.fir.kt | 4 +- .../smartCasts/inference/intersectionTypes.kt | 4 +- .../constructorCallThroughPrivateAlias.fir.kt | 5 +++ .../constructorCallThroughPrivateAlias.kt | 5 +++ .../inference/arrayConstructor.kt | 2 + .../testsWithStdLib/inference/kt1558.fir.kt | 2 + .../testsWithStdLib/inference/kt1558.kt | 2 + .../resolve/hidesMembers.fir.kt | 2 + .../testsWithStdLib/resolve/hidesMembers.kt | 2 + .../checkers/AbstractDiagnosticsTest.kt | 5 +++ .../kotlin/checkers/BaseDiagnosticsTest.kt | 5 --- 91 files changed, 269 insertions(+), 111 deletions(-) diff --git a/compiler/fir/analysis-tests/testData/resolve/callResolution/syntheticPropertiesWrongImplicitReceiver.txt b/compiler/fir/analysis-tests/testData/resolve/callResolution/syntheticPropertiesWrongImplicitReceiver.txt index 9e7d91a50ef..d8831061cc2 100644 --- a/compiler/fir/analysis-tests/testData/resolve/callResolution/syntheticPropertiesWrongImplicitReceiver.txt +++ b/compiler/fir/analysis-tests/testData/resolve/callResolution/syntheticPropertiesWrongImplicitReceiver.txt @@ -6,14 +6,14 @@ FILE: main.kt ^ Int(1) } public final fun bar(a: R|A|): R|kotlin/Unit| { - R|/a|.R|/foo|.R|tests/_checkType/checkType|(checkType@fun R|tests/_checkType/Inv|.(): R|kotlin/Unit| { - this@R|special/anonymous|.R|tests/_checkType/_|() + R|/a|.R|/foo|.R|/checkType|(checkType@fun R|CheckTypeInv|.(): R|kotlin/Unit| { + this@R|special/anonymous|.R|/_|() } ) } public final fun R|JavaClass|.bar(a: R|A|): R|kotlin/Unit| { - R|/a|.R|/foo|.R|tests/_checkType/checkType|(checkType@fun R|tests/_checkType/Inv|.(): R|kotlin/Unit| { - this@R|special/anonymous|.R|tests/_checkType/_|() + R|/a|.R|/foo|.R|/checkType|(checkType@fun R|CheckTypeInv|.(): R|kotlin/Unit| { + this@R|special/anonymous|.R|/_|() } ) } @@ -21,13 +21,13 @@ FILE: CHECK_TYPE.kt public final fun checkSubtype(t: R|T|): R|T| { ^checkSubtype R|/t| } - public final class Inv : R|kotlin/Any| { - public constructor(): R|tests/_checkType/Inv| { + public final class CheckTypeInv : R|kotlin/Any| { + public constructor(): R|CheckTypeInv| { super() } } - public final fun R|tests/_checkType/Inv|._(): R|kotlin/Unit| { + public final fun R|CheckTypeInv|._(): R|kotlin/Unit| { } - public final infix fun R|T|.checkType(f: R|tests/_checkType/Inv.() -> kotlin/Unit|): R|kotlin/Unit| { + public final infix fun R|T|.checkType(f: R|CheckTypeInv.() -> kotlin/Unit|): R|kotlin/Unit| { } diff --git a/compiler/fir/analysis-tests/testData/resolve/lambdaArgInScopeFunction.txt b/compiler/fir/analysis-tests/testData/resolve/lambdaArgInScopeFunction.txt index d33d7c1bece..a3013d57256 100644 --- a/compiler/fir/analysis-tests/testData/resolve/lambdaArgInScopeFunction.txt +++ b/compiler/fir/analysis-tests/testData/resolve/lambdaArgInScopeFunction.txt @@ -17,8 +17,8 @@ FILE: lambdaArgInScopeFunction.kt ^ R|/it| } ) } - R|/value|.R|tests/_checkType/checkType|( = checkType@fun R|tests/_checkType/Inv|.(): R|kotlin/Unit| { - this@R|special/anonymous|.R|tests/_checkType/_|() + R|/value|.R|/checkType|( = checkType@fun R|CheckTypeInv|.(): R|kotlin/Unit| { + this@R|special/anonymous|.R|/_|() } ) lval lambda: R|() -> KotlinClass| = R|/kotlinClass|?.{ $subj$.R|kotlin/let| KotlinClass|>( = let@fun (it: R|KotlinClass|): R|() -> KotlinClass| { @@ -28,8 +28,8 @@ FILE: lambdaArgInScopeFunction.kt } ) } - R|/lambda|.R|tests/_checkType/checkType| KotlinClass|>( = checkType@fun R|tests/_checkType/Inv?>|.(): R|kotlin/Unit| { - this@R|special/anonymous|.# KotlinClass?|>() + R|/lambda|.R|/checkType| KotlinClass|>( = checkType@fun R|CheckTypeInv?>|.(): R|kotlin/Unit| { + this@R|special/anonymous|.# KotlinClass?|>() } ) } @@ -38,8 +38,8 @@ FILE: lambdaArgInScopeFunction.kt ^ R|/it| } ) - R|/value|.R|tests/_checkType/checkType|( = checkType@fun R|tests/_checkType/Inv|.(): R|kotlin/Unit| { - this@R|special/anonymous|.R|tests/_checkType/_|() + R|/value|.R|/checkType|( = checkType@fun R|CheckTypeInv|.(): R|kotlin/Unit| { + this@R|special/anonymous|.R|/_|() } ) lval lambda: R|() -> KotlinClass| = R|/kotlinClass|.R|kotlin/let| KotlinClass|>( = let@fun (it: R|KotlinClass|): R|() -> KotlinClass| { @@ -49,8 +49,8 @@ FILE: lambdaArgInScopeFunction.kt } ) - R|/lambda|.R|tests/_checkType/checkType| KotlinClass|>( = checkType@fun R|tests/_checkType/Inv>|.(): R|kotlin/Unit| { - this@R|special/anonymous|.# KotlinClass?|>() + R|/lambda|.R|/checkType| KotlinClass|>( = checkType@fun R|CheckTypeInv>|.(): R|kotlin/Unit| { + this@R|special/anonymous|.# KotlinClass?|>() } ) } @@ -58,13 +58,13 @@ FILE: CHECK_TYPE.kt public final fun checkSubtype(t: R|T|): R|T| { ^checkSubtype R|/t| } - public final class Inv : R|kotlin/Any| { - public constructor(): R|tests/_checkType/Inv| { + public final class CheckTypeInv : R|kotlin/Any| { + public constructor(): R|CheckTypeInv| { super() } } - public final fun R|tests/_checkType/Inv|._(): R|kotlin/Unit| { + public final fun R|CheckTypeInv|._(): R|kotlin/Unit| { } - public final infix fun R|T|.checkType(f: R|tests/_checkType/Inv.() -> kotlin/Unit|): R|kotlin/Unit| { + public final infix fun R|T|.checkType(f: R|CheckTypeInv.() -> kotlin/Unit|): R|kotlin/Unit| { } diff --git a/compiler/fir/analysis-tests/testData/resolve/lambdaPropertyTypeInference.txt b/compiler/fir/analysis-tests/testData/resolve/lambdaPropertyTypeInference.txt index 75cea3d673b..38bcc13dff5 100644 --- a/compiler/fir/analysis-tests/testData/resolve/lambdaPropertyTypeInference.txt +++ b/compiler/fir/analysis-tests/testData/resolve/lambdaPropertyTypeInference.txt @@ -24,16 +24,16 @@ FILE: KotlinClass.kt } } - R|/validType|.R|tests/_checkType/checkType| kotlin/Boolean|>( = checkType@fun R|tests/_checkType/Inv>|.(): R|kotlin/Unit| { - this@R|special/anonymous|.R|tests/_checkType/_| kotlin/Boolean|>() + R|/validType|.R|/checkType| kotlin/Boolean|>( = checkType@fun R|CheckTypeInv>|.(): R|kotlin/Unit| { + this@R|special/anonymous|.R|/_| kotlin/Boolean|>() } ) - R|/invalidType|.R|tests/_checkType/checkType| kotlin/Boolean|>( = checkType@fun R|tests/_checkType/Inv>|.(): R|kotlin/Unit| { - this@R|special/anonymous|.# kotlin/Boolean|>() + R|/invalidType|.R|/checkType| kotlin/Boolean|>( = checkType@fun R|CheckTypeInv>|.(): R|kotlin/Unit| { + this@R|special/anonymous|.# kotlin/Boolean|>() } ) - R|/Case1.Case1|(R|/javaClass|).R|/Case1.x|.R|tests/_checkType/checkType| kotlin/Boolean|>( = checkType@fun R|tests/_checkType/Inv>|.(): R|kotlin/Unit| { - this@R|special/anonymous|.# kotlin/Boolean|>() + R|/Case1.Case1|(R|/javaClass|).R|/Case1.x|.R|/checkType| kotlin/Boolean|>( = checkType@fun R|CheckTypeInv>|.(): R|kotlin/Unit| { + this@R|special/anonymous|.# kotlin/Boolean|>() } ) } @@ -117,16 +117,16 @@ FILE: KotlinClass.kt } } - R|/validType|.R|tests/_checkType/checkType| kotlin/Boolean|>( = checkType@fun R|tests/_checkType/Inv>|.(): R|kotlin/Unit| { - this@R|special/anonymous|.R|tests/_checkType/_| kotlin/Boolean|>() + R|/validType|.R|/checkType| kotlin/Boolean|>( = checkType@fun R|CheckTypeInv>|.(): R|kotlin/Unit| { + this@R|special/anonymous|.R|/_| kotlin/Boolean|>() } ) - R|/invalidType|.R|tests/_checkType/checkType| kotlin/Boolean|>( = checkType@fun R|tests/_checkType/Inv>|.(): R|kotlin/Unit| { - this@R|special/anonymous|.# kotlin/Boolean|>() + R|/invalidType|.R|/checkType| kotlin/Boolean|>( = checkType@fun R|CheckTypeInv>|.(): R|kotlin/Unit| { + this@R|special/anonymous|.# kotlin/Boolean|>() } ) - R|/Case2.Case2|(R|/kotlinClass|).R|/Case2.x|.R|tests/_checkType/checkType| kotlin/Boolean|>( = checkType@fun R|tests/_checkType/Inv>|.(): R|kotlin/Unit| { - this@R|special/anonymous|.# kotlin/Boolean|>() + R|/Case2.Case2|(R|/kotlinClass|).R|/Case2.x|.R|/checkType| kotlin/Boolean|>( = checkType@fun R|CheckTypeInv>|.(): R|kotlin/Unit| { + this@R|special/anonymous|.# kotlin/Boolean|>() } ) } @@ -176,13 +176,13 @@ FILE: CHECK_TYPE.kt public final fun checkSubtype(t: R|T|): R|T| { ^checkSubtype R|/t| } - public final class Inv : R|kotlin/Any| { - public constructor(): R|tests/_checkType/Inv| { + public final class CheckTypeInv : R|kotlin/Any| { + public constructor(): R|CheckTypeInv| { super() } } - public final fun R|tests/_checkType/Inv|._(): R|kotlin/Unit| { + public final fun R|CheckTypeInv|._(): R|kotlin/Unit| { } - public final infix fun R|T|.checkType(f: R|tests/_checkType/Inv.() -> kotlin/Unit|): R|kotlin/Unit| { + public final infix fun R|T|.checkType(f: R|CheckTypeInv.() -> kotlin/Unit|): R|kotlin/Unit| { } diff --git a/compiler/fir/analysis-tests/testData/resolve/objectInnerClass.txt b/compiler/fir/analysis-tests/testData/resolve/objectInnerClass.txt index de2e3414f51..b16c64244ce 100644 --- a/compiler/fir/analysis-tests/testData/resolve/objectInnerClass.txt +++ b/compiler/fir/analysis-tests/testData/resolve/objectInnerClass.txt @@ -201,13 +201,13 @@ FILE: CHECK_TYPE.kt public final fun checkSubtype(t: R|T|): R|T| { ^checkSubtype R|/t| } - public final class Inv : R|kotlin/Any| { - public constructor(): R|tests/_checkType/Inv| { + public final class CheckTypeInv : R|kotlin/Any| { + public constructor(): R|CheckTypeInv| { super() } } - public final fun R|tests/_checkType/Inv|._(): R|kotlin/Unit| { + public final fun R|CheckTypeInv|._(): R|kotlin/Unit| { } - public final infix fun R|T|.checkType(f: R|tests/_checkType/Inv.() -> kotlin/Unit|): R|kotlin/Unit| { + public final infix fun R|T|.checkType(f: R|CheckTypeInv.() -> kotlin/Unit|): R|kotlin/Unit| { } diff --git a/compiler/fir/analysis-tests/testData/resolve/overrides/simpleMostSpecific.txt b/compiler/fir/analysis-tests/testData/resolve/overrides/simpleMostSpecific.txt index 977db279c78..d24df0ce59d 100644 --- a/compiler/fir/analysis-tests/testData/resolve/overrides/simpleMostSpecific.txt +++ b/compiler/fir/analysis-tests/testData/resolve/overrides/simpleMostSpecific.txt @@ -30,43 +30,43 @@ FILE: simpleMostSpecific.kt public abstract interface D3 : R|A|, R|C| { } public final fun main(d1: R|D1|, d2: R|D2|, d3: R|D3|): R|kotlin/Unit| { - R|/d1|.R|/B.x|.R|tests/_checkType/checkType|( = checkType@fun R|tests/_checkType/Inv|.(): R|kotlin/Unit| { - this@R|special/anonymous|.R|tests/_checkType/_|() + R|/d1|.R|/B.x|.R|/checkType|( = checkType@fun R|CheckTypeInv|.(): R|kotlin/Unit| { + this@R|special/anonymous|.R|/_|() } ) R|/d1|.R|/B.x| = String() - R|/d1|.R|/B.foo|().R|tests/_checkType/checkType|( = checkType@fun R|tests/_checkType/Inv|.(): R|kotlin/Unit| { - this@R|special/anonymous|.R|tests/_checkType/_|() + R|/d1|.R|/B.foo|().R|/checkType|( = checkType@fun R|CheckTypeInv|.(): R|kotlin/Unit| { + this@R|special/anonymous|.R|/_|() } ) - R|/d1|.R|/B.bar|(Int(1), String()).R|tests/_checkType/checkType|( = checkType@fun R|tests/_checkType/Inv|.(): R|kotlin/Unit| { - this@R|special/anonymous|.R|tests/_checkType/_|() + R|/d1|.R|/B.bar|(Int(1), String()).R|/checkType|( = checkType@fun R|CheckTypeInv|.(): R|kotlin/Unit| { + this@R|special/anonymous|.R|/_|() } ) - R|/d2|.R|/B.x|.R|tests/_checkType/checkType|( = checkType@fun R|tests/_checkType/Inv|.(): R|kotlin/Unit| { - this@R|special/anonymous|.R|tests/_checkType/_|() + R|/d2|.R|/B.x|.R|/checkType|( = checkType@fun R|CheckTypeInv|.(): R|kotlin/Unit| { + this@R|special/anonymous|.R|/_|() } ) R|/d2|.R|/B.x| = String() - R|/d2|.R|/B.foo|().R|tests/_checkType/checkType|( = checkType@fun R|tests/_checkType/Inv|.(): R|kotlin/Unit| { - this@R|special/anonymous|.R|tests/_checkType/_|() + R|/d2|.R|/B.foo|().R|/checkType|( = checkType@fun R|CheckTypeInv|.(): R|kotlin/Unit| { + this@R|special/anonymous|.R|/_|() } ) - R|/d2|.R|/B.bar|(Int(1), String()).R|tests/_checkType/checkType|( = checkType@fun R|tests/_checkType/Inv|.(): R|kotlin/Unit| { - this@R|special/anonymous|.R|tests/_checkType/_|() + R|/d2|.R|/B.bar|(Int(1), String()).R|/checkType|( = checkType@fun R|CheckTypeInv|.(): R|kotlin/Unit| { + this@R|special/anonymous|.R|/_|() } ) - R|/d3|.R|/C.x|.R|tests/_checkType/checkType|( = checkType@fun R|tests/_checkType/Inv|.(): R|kotlin/Unit| { - this@R|special/anonymous|.R|tests/_checkType/_|() + R|/d3|.R|/C.x|.R|/checkType|( = checkType@fun R|CheckTypeInv|.(): R|kotlin/Unit| { + this@R|special/anonymous|.R|/_|() } ) R|/d3|.R|/C.x| = String() - R|/d3|.R|/A.foo|().R|tests/_checkType/checkType|( = checkType@fun R|tests/_checkType/Inv|.(): R|kotlin/Unit| { - this@R|special/anonymous|.R|tests/_checkType/_|() + R|/d3|.R|/A.foo|().R|/checkType|( = checkType@fun R|CheckTypeInv|.(): R|kotlin/Unit| { + this@R|special/anonymous|.R|/_|() } ) - R|/d3|.R|/A.bar|(Int(1), String()).R|tests/_checkType/checkType|( = checkType@fun R|tests/_checkType/Inv|.(): R|kotlin/Unit| { - this@R|special/anonymous|.R|tests/_checkType/_|() + R|/d3|.R|/A.bar|(Int(1), String()).R|/checkType|( = checkType@fun R|CheckTypeInv|.(): R|kotlin/Unit| { + this@R|special/anonymous|.R|/_|() } ) } @@ -74,13 +74,13 @@ FILE: CHECK_TYPE.kt public final fun checkSubtype(t: R|T|): R|T| { ^checkSubtype R|/t| } - public final class Inv : R|kotlin/Any| { - public constructor(): R|tests/_checkType/Inv| { + public final class CheckTypeInv : R|kotlin/Any| { + public constructor(): R|CheckTypeInv| { super() } } - public final fun R|tests/_checkType/Inv|._(): R|kotlin/Unit| { + public final fun R|CheckTypeInv|._(): R|kotlin/Unit| { } - public final infix fun R|T|.checkType(f: R|tests/_checkType/Inv.() -> kotlin/Unit|): R|kotlin/Unit| { + public final infix fun R|T|.checkType(f: R|CheckTypeInv.() -> kotlin/Unit|): R|kotlin/Unit| { } diff --git a/compiler/testData/diagnostics/helpers/types/checkType.kt b/compiler/testData/diagnostics/helpers/types/checkType.kt index 1e4869bc28b..43b66629058 100644 --- a/compiler/testData/diagnostics/helpers/types/checkType.kt +++ b/compiler/testData/diagnostics/helpers/types/checkType.kt @@ -1,7 +1,5 @@ -package tests._checkType - fun checkSubtype(t: T) = t -class Inv -fun Inv._() {} +class CheckTypeInv +fun CheckTypeInv._() {} -infix fun T.checkType(f: Inv.() -> Unit) {} +infix fun T.checkType(f: CheckTypeInv.() -> Unit) {} diff --git a/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.fir.kt b/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.fir.kt index 5d8592d2732..6a62617d900 100644 --- a/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.fir.kt +++ b/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.fir.kt @@ -3,6 +3,9 @@ package foo +import checkType +import checkSubtype + fun Any.foo() : () -> Unit { return {} } diff --git a/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.kt b/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.kt index d08dc66e872..5263624e844 100644 --- a/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.kt +++ b/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.kt @@ -3,6 +3,9 @@ package foo +import checkType +import checkSubtype + fun Any.foo() : () -> Unit { return {} } diff --git a/compiler/testData/diagnostics/tests/callableReference/bound/companionObject.fir.kt b/compiler/testData/diagnostics/tests/callableReference/bound/companionObject.fir.kt index bd6cd6dc7e3..c14f2527175 100644 --- a/compiler/testData/diagnostics/tests/callableReference/bound/companionObject.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/bound/companionObject.fir.kt @@ -3,6 +3,8 @@ package test +import checkSubtype + class C { companion object { fun foo(): String = "companion" diff --git a/compiler/testData/diagnostics/tests/callableReference/bound/companionObject.kt b/compiler/testData/diagnostics/tests/callableReference/bound/companionObject.kt index d053ab877fa..58734c704a7 100644 --- a/compiler/testData/diagnostics/tests/callableReference/bound/companionObject.kt +++ b/compiler/testData/diagnostics/tests/callableReference/bound/companionObject.kt @@ -3,6 +3,8 @@ package test +import checkSubtype + class C { companion object { fun foo(): String = "companion" diff --git a/compiler/testData/diagnostics/tests/callableReference/function/differentPackageClass.fir.kt b/compiler/testData/diagnostics/tests/callableReference/function/differentPackageClass.fir.kt index f25fc6ddbc7..073282b9ab2 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/differentPackageClass.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/function/differentPackageClass.fir.kt @@ -3,6 +3,8 @@ package first +import checkSubtype + class A { fun foo() {} fun bar(x: Int) {} @@ -14,7 +16,7 @@ class A { package other import kotlin.reflect.* - +import checkSubtype import first.A fun main() { diff --git a/compiler/testData/diagnostics/tests/callableReference/function/differentPackageClass.kt b/compiler/testData/diagnostics/tests/callableReference/function/differentPackageClass.kt index 1d0c327455f..6202b9f2179 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/differentPackageClass.kt +++ b/compiler/testData/diagnostics/tests/callableReference/function/differentPackageClass.kt @@ -3,6 +3,8 @@ package first +import checkSubtype + class A { fun foo() {} fun bar(x: Int) {} @@ -14,7 +16,7 @@ class A { package other import kotlin.reflect.* - +import checkSubtype import first.A fun main() { diff --git a/compiler/testData/diagnostics/tests/callableReference/function/differentPackageExtension.fir.kt b/compiler/testData/diagnostics/tests/callableReference/function/differentPackageExtension.fir.kt index fda9de85f94..67f25303cc8 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/differentPackageExtension.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/function/differentPackageExtension.fir.kt @@ -4,6 +4,8 @@ package first +import checkSubtype + class A fun A.foo() {} @@ -18,6 +20,7 @@ import kotlin.reflect.KFunction1 import first.A import first.foo +import checkSubtype fun main() { val x = first.A::foo diff --git a/compiler/testData/diagnostics/tests/callableReference/function/differentPackageExtension.kt b/compiler/testData/diagnostics/tests/callableReference/function/differentPackageExtension.kt index 6b26e8a0b3b..13d0f4e6cc4 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/differentPackageExtension.kt +++ b/compiler/testData/diagnostics/tests/callableReference/function/differentPackageExtension.kt @@ -4,6 +4,8 @@ package first +import checkSubtype + class A fun A.foo() {} @@ -18,6 +20,7 @@ import kotlin.reflect.KFunction1 import first.A import first.foo +import checkSubtype fun main() { val x = first.A::foo diff --git a/compiler/testData/diagnostics/tests/callableReference/function/differentPackageTopLevel.fir.kt b/compiler/testData/diagnostics/tests/callableReference/function/differentPackageTopLevel.fir.kt index 0f7f02af9f8..c9a4ed9b01a 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/differentPackageTopLevel.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/function/differentPackageTopLevel.fir.kt @@ -3,6 +3,8 @@ package first +import checkSubtype + fun foo() {} fun bar(x: Int) {} fun baz() = "OK" @@ -16,6 +18,7 @@ import kotlin.reflect.* import first.foo import first.bar import first.baz +import checkSubtype fun main() { val x = ::foo diff --git a/compiler/testData/diagnostics/tests/callableReference/function/differentPackageTopLevel.kt b/compiler/testData/diagnostics/tests/callableReference/function/differentPackageTopLevel.kt index b1d196fd7e2..63d9bcbbfb4 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/differentPackageTopLevel.kt +++ b/compiler/testData/diagnostics/tests/callableReference/function/differentPackageTopLevel.kt @@ -3,6 +3,8 @@ package first +import checkSubtype + fun foo() {} fun bar(x: Int) {} fun baz() = "OK" @@ -16,6 +18,7 @@ import kotlin.reflect.* import first.foo import first.bar import first.baz +import checkSubtype fun main() { val x = ::foo diff --git a/compiler/testData/diagnostics/tests/declarationChecks/kt2631_MultipleDeclaration.fir.kt b/compiler/testData/diagnostics/tests/declarationChecks/kt2631_MultipleDeclaration.fir.kt index 3a8cba18859..a87fe97c06a 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/kt2631_MultipleDeclaration.fir.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/kt2631_MultipleDeclaration.fir.kt @@ -3,6 +3,8 @@ //KT-2631 Check multiple assignment package a +import checkSubtype + class MyClass { operator fun component1() = 1 operator fun component2() = "a" @@ -24,4 +26,4 @@ fun test(mc1: MyClass, mc2: MyClass2) { checkSubtype(a) checkSubtype(b) checkSubtype(c) -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/declarationChecks/kt2631_MultipleDeclaration.kt b/compiler/testData/diagnostics/tests/declarationChecks/kt2631_MultipleDeclaration.kt index 99728930b1f..916878dd56f 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/kt2631_MultipleDeclaration.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/kt2631_MultipleDeclaration.kt @@ -3,6 +3,8 @@ //KT-2631 Check multiple assignment package a +import checkSubtype + class MyClass { operator fun component1() = 1 operator fun component2() = "a" @@ -24,4 +26,4 @@ fun test(mc1: MyClass, mc2: MyClass2) { checkSubtype(a) checkSubtype(b) checkSubtype(c) -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/deparenthesize/checkDeparenthesizedType.fir.kt b/compiler/testData/diagnostics/tests/deparenthesize/checkDeparenthesizedType.fir.kt index 4e839cc1292..2937d8e871a 100644 --- a/compiler/testData/diagnostics/tests/deparenthesize/checkDeparenthesizedType.fir.kt +++ b/compiler/testData/diagnostics/tests/deparenthesize/checkDeparenthesizedType.fir.kt @@ -3,6 +3,8 @@ package m +import checkSubtype + fun test(i: Int?) { if (i != null) { foo(l1@ i) diff --git a/compiler/testData/diagnostics/tests/deparenthesize/checkDeparenthesizedType.kt b/compiler/testData/diagnostics/tests/deparenthesize/checkDeparenthesizedType.kt index 8e89a8ad7f3..20ed233ab7c 100644 --- a/compiler/testData/diagnostics/tests/deparenthesize/checkDeparenthesizedType.kt +++ b/compiler/testData/diagnostics/tests/deparenthesize/checkDeparenthesizedType.kt @@ -3,6 +3,8 @@ package m +import checkSubtype + fun test(i: Int?) { if (i != null) { foo(l1@ i) diff --git a/compiler/testData/diagnostics/tests/inference/completeInferenceIfManyFailed.fir.kt b/compiler/testData/diagnostics/tests/inference/completeInferenceIfManyFailed.fir.kt index 7848dde3efe..e2f422cf43c 100644 --- a/compiler/testData/diagnostics/tests/inference/completeInferenceIfManyFailed.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/completeInferenceIfManyFailed.fir.kt @@ -3,6 +3,8 @@ package d +import checkSubtype + fun joinT(x: Int, vararg a: T): T? { return null } diff --git a/compiler/testData/diagnostics/tests/inference/completeInferenceIfManyFailed.kt b/compiler/testData/diagnostics/tests/inference/completeInferenceIfManyFailed.kt index 7f26973a7af..dacf903b75b 100644 --- a/compiler/testData/diagnostics/tests/inference/completeInferenceIfManyFailed.kt +++ b/compiler/testData/diagnostics/tests/inference/completeInferenceIfManyFailed.kt @@ -3,6 +3,8 @@ package d +import checkSubtype + fun joinT(x: Int, vararg a: T): T? { return null } @@ -14,4 +16,4 @@ fun joinT(x: Comparable<*>, fun test() { val x2 = joinT(Unit, "2") checkSubtype(x2) -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/inference/dependOnExpectedType.fir.kt b/compiler/testData/diagnostics/tests/inference/dependOnExpectedType.fir.kt index bae7a552814..d26254bef7c 100644 --- a/compiler/testData/diagnostics/tests/inference/dependOnExpectedType.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/dependOnExpectedType.fir.kt @@ -3,6 +3,7 @@ package h //+JDK import java.util.* +import checkSubtype fun id(t: T) : T = t diff --git a/compiler/testData/diagnostics/tests/inference/dependOnExpectedType.kt b/compiler/testData/diagnostics/tests/inference/dependOnExpectedType.kt index a08c09e8bde..2a227938921 100644 --- a/compiler/testData/diagnostics/tests/inference/dependOnExpectedType.kt +++ b/compiler/testData/diagnostics/tests/inference/dependOnExpectedType.kt @@ -3,6 +3,7 @@ package h //+JDK import java.util.* +import checkSubtype fun id(t: T) : T = t diff --git a/compiler/testData/diagnostics/tests/inference/functionPlaceholderError.fir.kt b/compiler/testData/diagnostics/tests/inference/functionPlaceholderError.fir.kt index 790d98a513a..998c43024e6 100644 --- a/compiler/testData/diagnostics/tests/inference/functionPlaceholderError.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/functionPlaceholderError.fir.kt @@ -3,6 +3,8 @@ package a +import checkSubtype + fun emptyList(): List = throw Exception() fun foo(f: T.() -> Unit, l: List): T = throw Exception("$f$l") @@ -12,4 +14,4 @@ fun test() { checkSubtype(q) foo({}, emptyList()) -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/inference/functionPlaceholderError.kt b/compiler/testData/diagnostics/tests/inference/functionPlaceholderError.kt index 3ee7c4cc974..9f543b11387 100644 --- a/compiler/testData/diagnostics/tests/inference/functionPlaceholderError.kt +++ b/compiler/testData/diagnostics/tests/inference/functionPlaceholderError.kt @@ -3,6 +3,8 @@ package a +import checkSubtype + fun emptyList(): List = throw Exception() fun foo(f: T.() -> Unit, l: List): T = throw Exception("$f$l") @@ -12,4 +14,4 @@ fun test() { checkSubtype(q) foo({}, emptyList()) -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/inference/listConstructor.fir.kt b/compiler/testData/diagnostics/tests/inference/listConstructor.fir.kt index af1c0fc71be..aab8f8b1fbc 100644 --- a/compiler/testData/diagnostics/tests/inference/listConstructor.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/listConstructor.fir.kt @@ -3,6 +3,7 @@ package a //+JDK import java.util.* +import checkSubtype fun cons(x: A, xs: List): List = xs diff --git a/compiler/testData/diagnostics/tests/inference/listConstructor.kt b/compiler/testData/diagnostics/tests/inference/listConstructor.kt index 65e308bcd3a..cb496c0591f 100644 --- a/compiler/testData/diagnostics/tests/inference/listConstructor.kt +++ b/compiler/testData/diagnostics/tests/inference/listConstructor.kt @@ -3,6 +3,7 @@ package a //+JDK import java.util.* +import checkSubtype fun cons(x: A, xs: List): List = xs diff --git a/compiler/testData/diagnostics/tests/inference/mapFunction.fir.kt b/compiler/testData/diagnostics/tests/inference/mapFunction.fir.kt index b9232a4cf5f..54cf1e0dc54 100644 --- a/compiler/testData/diagnostics/tests/inference/mapFunction.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/mapFunction.fir.kt @@ -4,6 +4,7 @@ package a //+JDK import java.util.* +import checkSubtype fun foo() { val v = array(1, 2, 3) @@ -32,4 +33,4 @@ fun array(vararg t : T) : Array = t as Array infix fun Array.map(transform : (T) -> R) : List {} -infix fun Iterable.map(transform : (T) -> R) : List {} \ No newline at end of file +infix fun Iterable.map(transform : (T) -> R) : List {} diff --git a/compiler/testData/diagnostics/tests/inference/mapFunction.kt b/compiler/testData/diagnostics/tests/inference/mapFunction.kt index c5bfc0765f4..a87b00b7de4 100644 --- a/compiler/testData/diagnostics/tests/inference/mapFunction.kt +++ b/compiler/testData/diagnostics/tests/inference/mapFunction.kt @@ -4,6 +4,7 @@ package a //+JDK import java.util.* +import checkSubtype fun foo() { val v = array(1, 2, 3) @@ -32,4 +33,4 @@ fun array(vararg t : T) : Array = t as Array infix fun Array.map(transform : (T) -> R) : List {} -infix fun Iterable.map(transform : (T) -> R) : List {} \ No newline at end of file +infix fun Iterable.map(transform : (T) -> R) : List {} diff --git a/compiler/testData/diagnostics/tests/inference/mostSpecificAfterInference.fir.kt b/compiler/testData/diagnostics/tests/inference/mostSpecificAfterInference.fir.kt index 5907bf98364..a64c7fa2700 100644 --- a/compiler/testData/diagnostics/tests/inference/mostSpecificAfterInference.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/mostSpecificAfterInference.fir.kt @@ -4,6 +4,7 @@ package i //+JDK import java.util.* +import checkSubtype fun Collection.map1(f : (T) -> R) : List {} fun java.lang.Iterable.map1(f : (T) -> R) : List {} @@ -21,4 +22,4 @@ fun test1(list: List) { val res = list.foo() //check res is not of error type checkSubtype(res) -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/inference/mostSpecificAfterInference.kt b/compiler/testData/diagnostics/tests/inference/mostSpecificAfterInference.kt index 8296c47e6b5..7bf485ee7d2 100644 --- a/compiler/testData/diagnostics/tests/inference/mostSpecificAfterInference.kt +++ b/compiler/testData/diagnostics/tests/inference/mostSpecificAfterInference.kt @@ -4,6 +4,7 @@ package i //+JDK import java.util.* +import checkSubtype fun Collection.map1(f : (T) -> R) : List {} fun java.lang.Iterable.map1(f : (T) -> R) : List {} @@ -21,4 +22,4 @@ fun test1(list: List) { val res = list.foo() //check res is not of error type 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 afe3f7f76dc..8823d4a7e12 100644 --- a/compiler/testData/diagnostics/tests/inference/nestedCalls/inferenceForNestedBinaryCall.kt +++ b/compiler/testData/diagnostics/tests/inference/nestedCalls/inferenceForNestedBinaryCall.kt @@ -3,6 +3,8 @@ package aaa +import checkSubtype + infix fun T.foo(t: T) = t fun id(t: T) = t diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt1029.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt1029.fir.kt index 3d020b79bfd..c7fe8b75d3a 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt1029.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt1029.fir.kt @@ -3,6 +3,8 @@ //KT-1029 Wrong type inference package i +import checkSubtype + public fun from(yielder: ()->Iterable) : Iterable { } diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt1029.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt1029.kt index 20da0c58420..b3f15256803 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt1029.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt1029.kt @@ -3,6 +3,8 @@ //KT-1029 Wrong type inference package i +import checkSubtype + public fun from(yielder: ()->Iterable) : Iterable { } diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt1031.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt1031.fir.kt index 5574b422d33..69964f68375 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt1031.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt1031.fir.kt @@ -4,6 +4,7 @@ package i import java.util.ArrayList +import checkSubtype public infix fun Iterable.where(predicate : (TItem)->Boolean) : ()->Iterable { } diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt1031.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt1031.kt index c9fdca53736..6eb7c9fb878 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt1031.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt1031.kt @@ -4,6 +4,7 @@ package i import java.util.ArrayList +import checkSubtype public infix fun Iterable.where(predicate : (TItem)->Boolean) : ()->Iterable { } diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt1145.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt1145.fir.kt index c4a1ff3b486..12d9a7c5a9f 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt1145.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt1145.fir.kt @@ -4,6 +4,8 @@ package d +import checkSubtype + fun test(numbers: Iterable) { val s = numbers.map{it.toString()}.fold(""){it, it2 -> it + it2} checkSubtype(s) @@ -12,4 +14,4 @@ fun test(numbers: Iterable) { //from library fun Iterable.map(transform : (T) -> R) : List {} -fun Iterable.fold(initial: T, operation: (T, T) -> T): T {} \ No newline at end of file +fun Iterable.fold(initial: T, operation: (T, T) -> T): T {} diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt1145.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt1145.kt index 2a4961ab24e..bd015e993c3 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt1145.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt1145.kt @@ -4,6 +4,8 @@ package d +import checkSubtype + fun test(numbers: Iterable) { val s = numbers.map{it.toString()}.fold(""){it, it2 -> it + it2} checkSubtype(s) @@ -12,4 +14,4 @@ fun test(numbers: Iterable) { //from library fun Iterable.map(transform : (T) -> R) : List {} -fun Iterable.fold(initial: T, operation: (T, T) -> T): T {} \ No newline at end of file +fun Iterable.fold(initial: T, operation: (T, T) -> T): T {} diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt1410.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt1410.fir.kt index 56da5d551cd..5a6978651e5 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt1410.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt1410.fir.kt @@ -4,6 +4,8 @@ //+JDK package d +import checkSubtype + public fun MutableCollection.filterToMy(result : MutableList, filter : (T) -> Boolean) : MutableCollection { for (t in this){ if (filter(t)){ @@ -23,4 +25,4 @@ fun test(result: MutableList, collection: MutableCollection, pre } //from library -fun String.startsWith(prefix: String) : Boolean {} \ No newline at end of file +fun String.startsWith(prefix: String) : Boolean {} diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt1410.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt1410.kt index bd566d78ae6..3a83b1d871d 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt1410.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt1410.kt @@ -4,6 +4,8 @@ //+JDK package d +import checkSubtype + public fun MutableCollection.filterToMy(result : MutableList, filter : (T) -> Boolean) : MutableCollection { for (t in this){ if (filter(t)){ @@ -23,4 +25,4 @@ fun test(result: MutableList, collection: MutableCollection, pre } //from library -fun String.startsWith(prefix: String) : Boolean {} \ No newline at end of file +fun String.startsWith(prefix: String) : Boolean {} diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt1718.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt1718.fir.kt index 1fbdb53e7c0..b7727bba810 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt1718.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt1718.fir.kt @@ -4,6 +4,7 @@ package n import java.util.ArrayList +import checkSubtype fun test() { val list = arrayList("foo", "bar") + arrayList("cheese", "wine") @@ -14,4 +15,4 @@ fun test() { //from library fun arrayList(vararg values: T) : ArrayList {} -operator fun Iterable.plus(elements: Iterable): List {} \ No newline at end of file +operator fun Iterable.plus(elements: Iterable): List {} diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt1718.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt1718.kt index c43277d871f..d36c5f1a055 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt1718.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt1718.kt @@ -4,6 +4,7 @@ package n import java.util.ArrayList +import checkSubtype fun test() { val list = arrayList("foo", "bar") + arrayList("cheese", "wine") @@ -14,4 +15,4 @@ fun test() { //from library fun arrayList(vararg values: T) : ArrayList {} -operator fun Iterable.plus(elements: Iterable): List {} \ No newline at end of file +operator fun Iterable.plus(elements: Iterable): List {} diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt1944.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt1944.kt index 2d4ec214c35..dcc5ba3389e 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt1944.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt1944.kt @@ -4,6 +4,8 @@ //KT-1944 Inference fails on run() package j +import checkSubtype + class P { var x : Int = 0 private set diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2179.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2179.fir.kt index b19c3e751d1..fb41c0fca46 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt2179.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2179.fir.kt @@ -5,6 +5,7 @@ package i //+JDK import java.util.* +import checkSubtype fun test() { val sample1: List> = arrayList(arrayList(1, 7, null, 8)) diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2179.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2179.kt index 6101e0ebdc4..cdea6f5db14 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt2179.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2179.kt @@ -5,6 +5,7 @@ package i //+JDK import java.util.* +import checkSubtype fun test() { val sample1: List> = arrayList(arrayList(1, 7, null, 8)) diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2200.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2200.fir.kt index ce35fed156d..ba6eafc3e00 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt2200.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2200.fir.kt @@ -3,6 +3,7 @@ //KT-2200 array(array()) breaks compiler package n +import checkSubtype fun main() { val a = array(array()) @@ -15,4 +16,4 @@ fun main() { //from library @Suppress("UNCHECKED_CAST") -fun array(vararg t : T) : Array = t as Array \ No newline at end of file +fun array(vararg t : T) : Array = t as Array diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2200.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2200.kt index bf6cb78a2a6..531db47b897 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt2200.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2200.kt @@ -3,6 +3,7 @@ //KT-2200 array(array()) breaks compiler package n +import checkSubtype fun main() { val a = array(array()) @@ -15,4 +16,4 @@ fun main() { //from library @Suppress("UNCHECKED_CAST") -fun array(vararg t : T) : Array = t as Array \ No newline at end of file +fun array(vararg t : T) : Array = t as Array diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2294.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2294.kt index 12c8a18d952..f1c6224d45d 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt2294.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2294.kt @@ -3,6 +3,7 @@ //KT-2294 Type inference infers DONT_CARE instead of correct type package a +import checkSubtype public fun foo(array: Array): Array = array diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2324.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2324.fir.kt index 5ff13eabd11..1cb99c46ae3 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt2324.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2324.fir.kt @@ -5,6 +5,7 @@ package i //+JDK import java.util.* +import checkSubtype fun someFunction(list: List, transform: (T) -> K): List { val result = arrayList() diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2324.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2324.kt index 3af09afefac..2d4bb7f7453 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt2324.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2324.kt @@ -5,6 +5,7 @@ package i //+JDK import java.util.* +import checkSubtype fun someFunction(list: List, transform: (T) -> K): List { val result = arrayList() diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2407.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2407.fir.kt index 836e667aec3..b9c208001d8 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt2407.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2407.fir.kt @@ -3,6 +3,7 @@ package n import java.util.* +import checkSubtype fun test() { val foo = arrayList("").map { it -> it.length }.fold(0, { x, y -> Math.max(x, y) }) @@ -15,4 +16,4 @@ fun arrayList(vararg values: T) : ArrayList {} fun Collection.map(transform : (T) -> R) : List {} -fun Iterable.fold(initial: T, operation: (T, T) -> T): T {} \ No newline at end of file +fun Iterable.fold(initial: T, operation: (T, T) -> T): T {} diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2407.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2407.kt index a68067cba50..4188db5e35b 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt2407.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2407.kt @@ -3,6 +3,7 @@ package n import java.util.* +import checkSubtype fun test() { val foo = arrayList("").map { it -> it.length }.fold(0, { x, y -> Math.max(x, y) }) @@ -15,4 +16,4 @@ fun arrayList(vararg values: T) : ArrayList { Collection.map(transform : (T) -> R) : List {} -fun Iterable.fold(initial: T, operation: (T, T) -> T): T {} \ No newline at end of file +fun Iterable.fold(initial: T, operation: (T, T) -> T): T {} diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2505.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2505.kt index b8497562454..180bc52e28d 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt2505.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2505.kt @@ -5,6 +5,8 @@ package a +import checkSubtype + interface MyType {} class MyClass : MyType {} diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt731.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt731.fir.kt index 566f5cef041..0c046e44916 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt731.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt731.fir.kt @@ -4,6 +4,8 @@ //KT-731 Missing error from type inference package a +import checkSubtype + class A(x: T) { val p = x } @@ -16,4 +18,4 @@ fun main() { val a = A(1) val t: String = a.foo({p -> p}) checkSubtype(t) -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt731.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt731.kt index d81bbf95be4..e8a55a78751 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt731.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt731.kt @@ -4,6 +4,8 @@ //KT-731 Missing error from type inference package a +import checkSubtype + class A(x: T) { val p = x } @@ -16,4 +18,4 @@ fun main() { val a = A(1) val t: String = a.foo({p -> p}) checkSubtype(t) -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt943.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt943.fir.kt index 6d899167b02..de262a10f93 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt943.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt943.fir.kt @@ -6,6 +6,7 @@ package maze //+JDK import java.util.Collections.* import java.util.* +import checkSubtype fun foo(lines: List) { val w = max(lines, comparator {o1, o2 -> @@ -19,4 +20,4 @@ fun foo(lines: List) { //standard library fun T?.sure() : T = this!! -public inline fun comparator(fn: (T,T) -> Int): Comparator {} \ No newline at end of file +public inline fun comparator(fn: (T,T) -> Int): Comparator {} diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt943.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt943.kt index afebc4c5fdc..7933a758ce5 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt943.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt943.kt @@ -6,6 +6,7 @@ package maze //+JDK import java.util.Collections.* import java.util.* +import checkSubtype fun foo(lines: List) { val w = max(lines, comparator {o1, o2 -> @@ -19,4 +20,4 @@ fun foo(lines: List) { //standard library fun T?.sure() : T = this!! -public inline fun comparator(fn: (T,T) -> Int): Comparator {} \ No newline at end of file +public inline fun comparator(fn: (T,T) -> Int): Comparator {} diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt948.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt948.fir.kt index 8d783455714..4b8a09505af 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt948.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt948.fir.kt @@ -6,6 +6,7 @@ package a import java.util.* +import checkSubtype fun emptyList() : List? = ArrayList() @@ -20,4 +21,4 @@ fun foo() { doWithList(emptyList()!!) } -fun doWithList(list: List) = list \ No newline at end of file +fun doWithList(list: List) = list diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt948.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt948.kt index 88507dd8e6e..4459f60c7a4 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt948.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt948.kt @@ -6,6 +6,7 @@ package a import java.util.* +import checkSubtype fun emptyList() : List? = ArrayList() @@ -20,4 +21,4 @@ fun foo() { doWithList(emptyList()!!) } -fun doWithList(list: List) = list \ No newline at end of file +fun doWithList(list: List) = list diff --git a/compiler/testData/diagnostics/tests/inference/upperBounds/conflictingSubstitutionsFromUpperBound.kt b/compiler/testData/diagnostics/tests/inference/upperBounds/conflictingSubstitutionsFromUpperBound.kt index b3631d69542..ff6404686aa 100644 --- a/compiler/testData/diagnostics/tests/inference/upperBounds/conflictingSubstitutionsFromUpperBound.kt +++ b/compiler/testData/diagnostics/tests/inference/upperBounds/conflictingSubstitutionsFromUpperBound.kt @@ -4,6 +4,9 @@ package g import java.util.HashSet +import checkType +import _ + fun > convert(src: Collection, dest: C): C = throw Exception("$src $dest") fun test(l: List) { diff --git a/compiler/testData/diagnostics/tests/inference/upperBounds/intersectUpperBounds.fir.kt b/compiler/testData/diagnostics/tests/inference/upperBounds/intersectUpperBounds.fir.kt index 3569deeff8a..133d2feda13 100644 --- a/compiler/testData/diagnostics/tests/inference/upperBounds/intersectUpperBounds.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/upperBounds/intersectUpperBounds.fir.kt @@ -3,6 +3,8 @@ package s +import checkSubtype + interface In interface A @@ -30,4 +32,4 @@ fun test(inA: In) { checkSubtype(r) } -fun use(vararg a: Any?) = a \ No newline at end of file +fun use(vararg a: Any?) = a diff --git a/compiler/testData/diagnostics/tests/inference/upperBounds/intersectUpperBounds.kt b/compiler/testData/diagnostics/tests/inference/upperBounds/intersectUpperBounds.kt index 21a558161a9..9c7631f212b 100644 --- a/compiler/testData/diagnostics/tests/inference/upperBounds/intersectUpperBounds.kt +++ b/compiler/testData/diagnostics/tests/inference/upperBounds/intersectUpperBounds.kt @@ -3,6 +3,8 @@ package s +import checkSubtype + interface In interface A @@ -30,4 +32,4 @@ fun test(inA: In) { checkSubtype(r) } -fun use(vararg a: Any?) = a \ No newline at end of file +fun use(vararg a: Any?) = a diff --git a/compiler/testData/diagnostics/tests/j+k/kt2394.kt b/compiler/testData/diagnostics/tests/j+k/kt2394.kt index 26365f9af3b..99839c02cc0 100644 --- a/compiler/testData/diagnostics/tests/j+k/kt2394.kt +++ b/compiler/testData/diagnostics/tests/j+k/kt2394.kt @@ -4,6 +4,8 @@ //KT-2394 java.lang.Iterable should be visible as kotlin.Iterable package d +import checkSubtype + fun foo(iterable: Iterable, iterator: Iterator, comparable: Comparable) { checkSubtype>(iterable) checkSubtype>(iterator) diff --git a/compiler/testData/diagnostics/tests/j+k/kt2641.fir.kt b/compiler/testData/diagnostics/tests/j+k/kt2641.fir.kt index ea101ae4fc6..19abd5e7c48 100644 --- a/compiler/testData/diagnostics/tests/j+k/kt2641.fir.kt +++ b/compiler/testData/diagnostics/tests/j+k/kt2641.fir.kt @@ -5,6 +5,8 @@ package a import java.util.Iterator import java.lang.Comparable as Comp +import checkSubtype + fun bar(any: Any): java.lang.Iterable? { val a: java.lang.Comparable? = null val b: Iterable @@ -15,4 +17,4 @@ fun bar(any: Any): java.lang.Iterable? { } any as Iterator<*> return null -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/j+k/kt2641.kt b/compiler/testData/diagnostics/tests/j+k/kt2641.kt index 022be5d88ed..c2f999dd1de 100644 --- a/compiler/testData/diagnostics/tests/j+k/kt2641.kt +++ b/compiler/testData/diagnostics/tests/j+k/kt2641.kt @@ -5,6 +5,8 @@ package a import java.util.Iterator import java.lang.Comparable as Comp +import checkSubtype + fun bar(any: Any): java.lang.Iterable? { val a: java.lang.Comparable? = null val b: Iterable<Integer> @@ -15,4 +17,4 @@ fun bar(any: Any): java.lang.Iterable } any as Iterator<*> return null -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt1778.fir.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt1778.fir.kt index 1530d65eb5f..e0bfec66a76 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt1778.fir.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt1778.fir.kt @@ -2,6 +2,8 @@ //KT-1778 Automatically cast error package kt1778 +import checkSubtype + fun main(args : Array) { val x = checkSubtype(args[0]) if(x is java.lang.CharSequence) { @@ -9,4 +11,4 @@ fun main(args : Array) { if ("a" == x || "b" == x) x.length else x.length() // <– THEN ERROR if ("a" == x && "a" == x) x.length else x.length() // <– ELSE ERROR } -} \ 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 1d1bf593f1d..b016144bed1 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt1778.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt1778.kt @@ -2,6 +2,8 @@ //KT-1778 Automatically cast error package kt1778 +import checkSubtype + fun main(args : Array) { val x = checkSubtype(args[0]) if(x is java.lang.CharSequence) { @@ -9,4 +11,4 @@ fun main(args : Array) { if ("a" == x || "b" == x) x.length else x.length() // <– THEN ERROR if ("a" == x && "a" == x) x.length else x.length() // <– ELSE ERROR } -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2176.fir.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2176.fir.kt index 67c08638cce..ea93bce992c 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2176.fir.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2176.fir.kt @@ -3,6 +3,8 @@ //KT-2176 non-nullability is not inferred after !! or "as" package kt2176 +import checkSubtype + fun f1(a: String?) { a!! checkSubtype(a) diff --git a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2176.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2176.kt index e346432dc10..d89ee854f52 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2176.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2176.kt @@ -3,6 +3,8 @@ //KT-2176 non-nullability is not inferred after !! or "as" package kt2176 +import checkSubtype + fun f1(a: String?) { a!! checkSubtype(a) diff --git a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2234.fir.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2234.fir.kt index f79097f30b6..fe807690557 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2234.fir.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2234.fir.kt @@ -2,6 +2,8 @@ package a +import checkSubtype + //KT-2234 'period!!' has type Int? class Pair(val a: A, val b: B) diff --git a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2234.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2234.kt index cbd456c235f..7b6df9dde68 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2234.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2234.kt @@ -2,6 +2,8 @@ package a +import checkSubtype + //KT-2234 'period!!' has type Int? class Pair(val a: A, val b: B) diff --git a/compiler/testData/diagnostics/tests/numbers/doublesInSimpleConstraints.fir.kt b/compiler/testData/diagnostics/tests/numbers/doublesInSimpleConstraints.fir.kt index 31ef50e4c41..ed75bdb678d 100644 --- a/compiler/testData/diagnostics/tests/numbers/doublesInSimpleConstraints.fir.kt +++ b/compiler/testData/diagnostics/tests/numbers/doublesInSimpleConstraints.fir.kt @@ -3,6 +3,8 @@ package a +import checkSubtype + fun id(t: T): T = t fun either(t1: T, t2: T): T = t1 @@ -20,4 +22,4 @@ fun test() { checkSubtype(d) val e: Float = id(1) -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/numbers/doublesInSimpleConstraints.kt b/compiler/testData/diagnostics/tests/numbers/doublesInSimpleConstraints.kt index 9c46e5d5ea8..e17f289ee67 100644 --- a/compiler/testData/diagnostics/tests/numbers/doublesInSimpleConstraints.kt +++ b/compiler/testData/diagnostics/tests/numbers/doublesInSimpleConstraints.kt @@ -3,6 +3,8 @@ package a +import checkSubtype + fun id(t: T): T = t fun either(t1: T, t2: T): T = t1 @@ -20,4 +22,4 @@ fun test() { checkSubtype(d) val e: Float = id(1) -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/numbers/numbersInSimpleConstraints.fir.kt b/compiler/testData/diagnostics/tests/numbers/numbersInSimpleConstraints.fir.kt index ccb9320dfbe..c6f1f114cc0 100644 --- a/compiler/testData/diagnostics/tests/numbers/numbersInSimpleConstraints.fir.kt +++ b/compiler/testData/diagnostics/tests/numbers/numbersInSimpleConstraints.fir.kt @@ -2,6 +2,10 @@ // !CHECK_TYPE package a +import checkType +import _ +import checkSubtype + fun id(t: T): T = t fun either(t1: T, t2: T): T = t1 diff --git a/compiler/testData/diagnostics/tests/numbers/numbersInSimpleConstraints.kt b/compiler/testData/diagnostics/tests/numbers/numbersInSimpleConstraints.kt index 4370e828990..4c6fbb91feb 100644 --- a/compiler/testData/diagnostics/tests/numbers/numbersInSimpleConstraints.kt +++ b/compiler/testData/diagnostics/tests/numbers/numbersInSimpleConstraints.kt @@ -2,6 +2,10 @@ // !CHECK_TYPE package a +import checkType +import _ +import checkSubtype + fun id(t: T): T = t fun either(t1: T, t2: T): T = t1 diff --git a/compiler/testData/diagnostics/tests/platformTypes/explicitFlexibleWithPackage.fir.kt b/compiler/testData/diagnostics/tests/platformTypes/explicitFlexibleWithPackage.fir.kt index 571418a21e2..2df300ed26b 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/explicitFlexibleWithPackage.fir.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/explicitFlexibleWithPackage.fir.kt @@ -3,7 +3,10 @@ // !CHECK_TYPE package ppp +import checkType +import _ + fun foo(f: ft) { 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 63f650fc139..1970c6ef232 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/explicitFlexibleWithPackage.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/explicitFlexibleWithPackage.kt @@ -3,7 +3,10 @@ // !CHECK_TYPE package ppp +import checkType +import _ + fun foo(f: ft) { f.checkType { _() } f.checkType { _() } -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/scopes/protectedVisibility/kt7971.fir.kt b/compiler/testData/diagnostics/tests/scopes/protectedVisibility/kt7971.fir.kt index 337f4764db5..27db9f77583 100644 --- a/compiler/testData/diagnostics/tests/scopes/protectedVisibility/kt7971.fir.kt +++ b/compiler/testData/diagnostics/tests/scopes/protectedVisibility/kt7971.fir.kt @@ -11,6 +11,8 @@ public abstract class AbstractModule { package module2 import module1.* +import checkType +import _ fun javaClass(): Class = null!! diff --git a/compiler/testData/diagnostics/tests/scopes/protectedVisibility/kt7971.kt b/compiler/testData/diagnostics/tests/scopes/protectedVisibility/kt7971.kt index 83bcff10c2f..13f51aa955d 100644 --- a/compiler/testData/diagnostics/tests/scopes/protectedVisibility/kt7971.kt +++ b/compiler/testData/diagnostics/tests/scopes/protectedVisibility/kt7971.kt @@ -11,6 +11,8 @@ public abstract class AbstractModule { package module2 import module1.* +import checkType +import _ fun javaClass(): Class = null!! diff --git a/compiler/testData/diagnostics/tests/smartCasts/inference/intersectionTypes.fir.kt b/compiler/testData/diagnostics/tests/smartCasts/inference/intersectionTypes.fir.kt index 5bfb285c232..a5726756c33 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/inference/intersectionTypes.fir.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/inference/intersectionTypes.fir.kt @@ -3,6 +3,8 @@ package a +import checkSubtype + fun id(t: T): T = t fun two(u: T, v: T): T = u @@ -58,4 +60,4 @@ fun rr(s: String?) { //from library fun arrayListOf(vararg values: T): MutableList = throw Exception() -fun use(vararg a: Any) = a \ No newline at end of file +fun use(vararg a: Any) = a diff --git a/compiler/testData/diagnostics/tests/smartCasts/inference/intersectionTypes.kt b/compiler/testData/diagnostics/tests/smartCasts/inference/intersectionTypes.kt index 8477a0bddb2..3a1268c199a 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/inference/intersectionTypes.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/inference/intersectionTypes.kt @@ -3,6 +3,8 @@ package a +import checkSubtype + fun id(t: T): T = t fun two(u: T, v: T): T = u @@ -58,4 +60,4 @@ fun rr(s: String?) { //from library fun arrayListOf(vararg values: T): MutableList = throw Exception() -fun use(vararg a: Any) = a \ No newline at end of file +fun use(vararg a: Any) = a diff --git a/compiler/testData/diagnostics/tests/typealias/constructorCallThroughPrivateAlias.fir.kt b/compiler/testData/diagnostics/tests/typealias/constructorCallThroughPrivateAlias.fir.kt index 1475e2951eb..bc72f271c10 100644 --- a/compiler/testData/diagnostics/tests/typealias/constructorCallThroughPrivateAlias.fir.kt +++ b/compiler/testData/diagnostics/tests/typealias/constructorCallThroughPrivateAlias.fir.kt @@ -3,6 +3,9 @@ // FILE: a.kt package a +import checkType +import _ + class B(x: String) typealias A1 = B private typealias A2 = B @@ -18,6 +21,8 @@ fun bar() { package usage import a.B +import checkType +import _ fun baz() { a.A1("") // resolved to B constructor, OK diff --git a/compiler/testData/diagnostics/tests/typealias/constructorCallThroughPrivateAlias.kt b/compiler/testData/diagnostics/tests/typealias/constructorCallThroughPrivateAlias.kt index 7d6ae58cb01..5f9c7f95d1e 100644 --- a/compiler/testData/diagnostics/tests/typealias/constructorCallThroughPrivateAlias.kt +++ b/compiler/testData/diagnostics/tests/typealias/constructorCallThroughPrivateAlias.kt @@ -3,6 +3,9 @@ // FILE: a.kt package a +import checkType +import _ + class B(x: String) typealias A1 = B private typealias A2 = B @@ -18,6 +21,8 @@ fun bar() { package usage import a.B +import checkType +import _ fun baz() { a.A1("") // resolved to B constructor, OK diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/arrayConstructor.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/arrayConstructor.kt index aa2e0494e0f..421620c5f4b 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/arrayConstructor.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/arrayConstructor.kt @@ -3,6 +3,8 @@ package b +import checkSubtype + fun bar() { val a1 = Array(1, {i: Int -> i}) val a2 = Array(1, {i: Int -> "$i"}) diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/kt1558.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/kt1558.fir.kt index a360a7cd9d9..f42237eb05a 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/kt1558.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/kt1558.fir.kt @@ -3,6 +3,8 @@ //KT-1558 Exception while analyzing package j +import checkSubtype + fun T?.sure() : T = this!! fun List<*>.toArray(ar: Array): Array = ar diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/kt1558.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/kt1558.kt index 2db5bd7fee7..073c85653b3 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/kt1558.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/kt1558.kt @@ -3,6 +3,8 @@ //KT-1558 Exception while analyzing package j +import checkSubtype + fun T?.sure() : T = this!! fun List<*>.toArray(ar: Array): Array = ar diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/hidesMembers.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/resolve/hidesMembers.fir.kt index fd2ce8d10e4..5ceddd130b9 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/resolve/hidesMembers.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/hidesMembers.fir.kt @@ -20,6 +20,8 @@ fun A.forEach(s: String) {} package a import b.* +import checkType +import _ class A { fun forEach() = this diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/hidesMembers.kt b/compiler/testData/diagnostics/testsWithStdLib/resolve/hidesMembers.kt index e593bbccd40..fd6989c1461 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/resolve/hidesMembers.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/hidesMembers.kt @@ -20,6 +20,8 @@ fun A.forEach(s: String) {} package a import b.* +import checkType +import _ class A { fun forEach() = this diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/checkers/AbstractDiagnosticsTest.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/checkers/AbstractDiagnosticsTest.kt index 50c17ade7ed..77f25e674ed 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/checkers/AbstractDiagnosticsTest.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/checkers/AbstractDiagnosticsTest.kt @@ -625,6 +625,7 @@ abstract class AbstractDiagnosticsTest : BaseDiagnosticsTest() { getTopLevelPackagesFromFileList(getKtFiles(testFiles, false)) ).toSet() + val checkTypeEnabled = testFiles.any { it.declareCheckType } val stepIntoFilter = Predicate { descriptor -> val module = DescriptorUtils.getContainingModuleOrNull(descriptor) if (module !in modules) return@Predicate false @@ -634,6 +635,8 @@ abstract class AbstractDiagnosticsTest : BaseDiagnosticsTest() { return@Predicate fqName.isRoot || fqName.pathSegments().first() in packagesNames } + if (checkTypeEnabled && descriptor.name in NAMES_OF_CHECK_TYPE_HELPER) return@Predicate false + true } @@ -768,5 +771,7 @@ abstract class AbstractDiagnosticsTest : BaseDiagnosticsTest() { private val HASH_SANITIZER = fun(s: String): String = s.replace("@(\\d)+".toRegex(), "") private val MODULE_FILES = ModuleCapability>("") + + private val NAMES_OF_CHECK_TYPE_HELPER = listOf("checkSubtype", "CheckTypeInv", "_", "checkType").map { Name.identifier(it) } } } diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/checkers/BaseDiagnosticsTest.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/checkers/BaseDiagnosticsTest.kt index 22c35a3c478..c6935bb88c3 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/checkers/BaseDiagnosticsTest.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/checkers/BaseDiagnosticsTest.kt @@ -190,9 +190,6 @@ abstract class BaseDiagnosticsTest : KotlinMultiFileTestWithJava