diff --git a/compiler/fir/analysis-tests/testData/extendedCheckers/RedundantReturnUnitTypeChecker.txt b/compiler/fir/analysis-tests/testData/extendedCheckers/RedundantReturnUnitTypeChecker.txt index 76e0afb580e..2aefb692f05 100644 --- a/compiler/fir/analysis-tests/testData/extendedCheckers/RedundantReturnUnitTypeChecker.txt +++ b/compiler/fir/analysis-tests/testData/extendedCheckers/RedundantReturnUnitTypeChecker.txt @@ -60,7 +60,7 @@ FILE: RedundantReturnUnitTypeChecker.kt public final fun foo(): R|kotlin/Unit| { ^foo this@R|/B|.R|/B.run|( = run@fun (): R|kotlin/Int| { - ^ this@R|/B|.R|/B.bar|() + this@R|/B|.R|/B.bar|() } ) } @@ -89,7 +89,7 @@ FILE: RedundantReturnUnitTypeChecker.kt public final fun goo(): R|kotlin/Unit| { ^goo (this@R|/B|, Int(1)).R|/B.let|( = let@fun (it: R|kotlin/Int|): R|kotlin/Int| { - ^ this@R|/B|.R|/B.bar|() + this@R|/B|.R|/B.bar|() } ) } diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/lambdas.txt b/compiler/fir/analysis-tests/testData/resolve/cfg/lambdas.txt index bd3cd9f3f3a..d3cd05f2903 100644 --- a/compiler/fir/analysis-tests/testData/resolve/cfg/lambdas.txt +++ b/compiler/fir/analysis-tests/testData/resolve/cfg/lambdas.txt @@ -6,7 +6,7 @@ FILE: lambdas.kt when () { (R|/x| is R|kotlin/Int|) -> { R|/run|( = run@fun (): R|kotlin/Unit| { - ^ R|/x|.R|kotlin/Int.inc|() + R|/x|.R|kotlin/Int.inc|() } ) } diff --git a/compiler/fir/analysis-tests/testData/resolve/expresssions/lambda.txt b/compiler/fir/analysis-tests/testData/resolve/expresssions/lambda.txt index b76334a2b5a..a250f63d58b 100644 --- a/compiler/fir/analysis-tests/testData/resolve/expresssions/lambda.txt +++ b/compiler/fir/analysis-tests/testData/resolve/expresssions/lambda.txt @@ -9,7 +9,7 @@ FILE: lambda.kt } public final fun main(): R|kotlin/Unit| { R|/foo|( = foo@fun (): R|kotlin/Unit| { - ^ String(This is test) + String(This is test) } ) R|/bar|( = bar@fun (): R|kotlin/String| { diff --git a/compiler/fir/analysis-tests/testData/resolve/expresssions/lambdaWithReceiver.txt b/compiler/fir/analysis-tests/testData/resolve/expresssions/lambdaWithReceiver.txt index b6f66d70178..7e81775f64d 100644 --- a/compiler/fir/analysis-tests/testData/resolve/expresssions/lambdaWithReceiver.txt +++ b/compiler/fir/analysis-tests/testData/resolve/expresssions/lambdaWithReceiver.txt @@ -35,7 +35,7 @@ FILE: lambdaWithReceiver.kt R|/complexLambda|( = complexLambda@fun R|kotlin/Int|.(it: R|kotlin/String|): R|kotlin/Unit| { this@R|special/anonymous|.R|kotlin/Int.inc|() this@R|special/anonymous|.R|kotlin/Int.inc|() - ^ R|/it|.R|kotlin/String.length| + R|/it|.R|kotlin/String.length| } ) } diff --git a/compiler/fir/analysis-tests/testData/resolve/inference/lambdaInElvis.txt b/compiler/fir/analysis-tests/testData/resolve/inference/lambdaInElvis.txt index 90c2359ee66..a590d3ccedc 100644 --- a/compiler/fir/analysis-tests/testData/resolve/inference/lambdaInElvis.txt +++ b/compiler/fir/analysis-tests/testData/resolve/inference/lambdaInElvis.txt @@ -9,13 +9,13 @@ FILE: lambdaInElvis.kt } public final fun bar1(w: R|kotlin/collections/List|): R|kotlin/collections/List?| { ^bar1 R|/foo|( = foo@fun (container: R|kotlin/collections/MutableList|): R|kotlin/Unit| { - ^ R|/container|.R|FakeOverride|(String()) + R|/container|.R|FakeOverride|(String()) } ) ?: R|/w| } public final fun bar2(): R|kotlin/collections/List?| { ^bar2 R|/foo|( = foo@fun (container: R|kotlin/collections/MutableList|): R|kotlin/Unit| { - ^ R|/container|.R|FakeOverride|(String()) + R|/container|.R|FakeOverride|(String()) } ) ?: R|/listOf|() } diff --git a/compiler/fir/analysis-tests/testData/resolve/problems/complexLambdaWithTypeVariableAsExpectedType.txt b/compiler/fir/analysis-tests/testData/resolve/problems/complexLambdaWithTypeVariableAsExpectedType.txt index c87cebf5b11..1ce8ca4e960 100644 --- a/compiler/fir/analysis-tests/testData/resolve/problems/complexLambdaWithTypeVariableAsExpectedType.txt +++ b/compiler/fir/analysis-tests/testData/resolve/problems/complexLambdaWithTypeVariableAsExpectedType.txt @@ -7,7 +7,7 @@ FILE: complexLambdaWithTypeVariableAsExpectedType.kt } public final fun test(): R|kotlin/Unit| { R|/select| kotlin/Unit|>(R|/id| kotlin/Int|>( = id@fun (it: R|kotlin/Int|): R|kotlin/Int| { - ^ R|/it|.R|kotlin/Int.inv|() + R|/it|.R|kotlin/Int.inv|() } ), R|/id| kotlin/Unit|>( = id@fun (it: R|kotlin/Int|): R|kotlin/Unit| { ^@id Unit diff --git a/compiler/fir/analysis-tests/testData/resolve/samConversions/runnable.txt b/compiler/fir/analysis-tests/testData/resolve/samConversions/runnable.txt index f4ad4bc83af..f265cd70f90 100644 --- a/compiler/fir/analysis-tests/testData/resolve/samConversions/runnable.txt +++ b/compiler/fir/analysis-tests/testData/resolve/samConversions/runnable.txt @@ -1,11 +1,11 @@ FILE: main.kt public final fun main(): R|kotlin/Unit| { Q|JavaClass|.R|/JavaClass.foo|( = foo@fun (): R|kotlin/Unit| { - ^ String() + String() } ) R|/JavaClass.JavaClass|().R|/JavaClass.bar|( = bar@fun (): R|kotlin/Unit| { - ^ String() + String() } ) } diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/safeCalls.txt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/safeCalls.txt index a11922bc998..bc9fabea3a0 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/safeCalls.txt +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/safeCalls.txt @@ -21,7 +21,7 @@ FILE: safeCalls.kt } public final fun test_3(x: R|kotlin/Any|): R|kotlin/Unit| { (R|/x| as? R|A|)?.{ $subj$.R|/A.bar|(R|/x|) }?.{ $subj$.R|/foo|(R|/x|.R|/A.bool|()) }?.{ $subj$.R|/let|( = let@fun (): R|kotlin/Unit| { - ^ R|/x|.R|/A.bool|() + R|/x|.R|/A.bool|() } ) } R|/x|.#() diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/addAllOnJavaCollection.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/addAllOnJavaCollection.txt index 3641a3d6a9b..15e3d9ce8e1 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/addAllOnJavaCollection.txt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/addAllOnJavaCollection.txt @@ -2,7 +2,7 @@ FILE: addAllOnJavaCollection.kt public final fun foo(): R|kotlin/Unit| { lval y: R|kotlin/collections/List| = R|kotlin/collections/listOf|(vararg(String(Alpha), String(Beta))) lval x: R|java/util/LinkedHashSet| = R|java/util/LinkedHashSet.LinkedHashSet|().R|kotlin/apply||>( = apply@fun R|java/util/LinkedHashSet|.(): R|kotlin/Unit| { - ^ this@R|special/anonymous|.R|FakeOverride|(R|/y|) + this@R|special/anonymous|.R|FakeOverride|(R|/y|) } ) lval z: R|java/util/ArrayList| = R|java/util/ArrayList.ArrayList|() diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/complexPostponedCfg.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/complexPostponedCfg.txt index 009c72006b7..76bfdd64ae8 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/complexPostponedCfg.txt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/complexPostponedCfg.txt @@ -7,9 +7,9 @@ FILE: complexPostponedCfg.kt lval firstCalls: R|kotlin/collections/List| = R|kotlin/with||>((R|/statements|.R|kotlin/collections/last|() as R|FirFunctionCall|), = setCall@fun R|FirFunctionCall|.(): R|kotlin/collections/List| { ^ R|kotlin/collections/buildList|( = buildList@fun R|kotlin/collections/MutableList|.(): R|kotlin/Unit| { this@R|special/anonymous|.R|FakeOverride|(this@R|special/anonymous|) - ^ R|kotlin/with|((R|/arguments|.R|kotlin/collections/last|() as R|FirFunctionCall|), = plusCall@fun R|FirFunctionCall|.(): R|kotlin/Boolean| { + R|kotlin/with|((R|/arguments|.R|kotlin/collections/last|() as R|FirFunctionCall|), = plusCall@fun R|FirFunctionCall|.(): R|kotlin/Boolean| { this@R|special/anonymous|.R|FakeOverride|(this@R|special/anonymous|) - ^ this@R|special/anonymous|.R|FakeOverride|((R|/explicitReceiver| as R|FirFunctionCall|)) + this@R|special/anonymous|.R|FakeOverride|((R|/explicitReceiver| as R|FirFunctionCall|)) } ) } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromLibrary/callsInPlace.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromLibrary/callsInPlace.txt index 15ca59afa42..c006792858e 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromLibrary/callsInPlace.txt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromLibrary/callsInPlace.txt @@ -9,13 +9,13 @@ FILE: callsInPlace.kt } public final fun test_2(): R|kotlin/Unit| { R|kotlin/repeat|(Int(10), = repeat@fun (it: R|kotlin/Int|): R|kotlin/Unit| { - ^ String(test_2) + String(test_2) } ) } public final fun test_3(): R|kotlin/Unit| { R|kotlin/repeat|(action = repeat@fun (it: R|kotlin/Int|): R|kotlin/Unit| { - ^ String(test_3) + String(test_3) } , times = Int(10)) } @@ -39,19 +39,19 @@ FILE: callsInPlace.kt } public final fun test_6(): R|kotlin/Unit| { R|/myRun|(myRun@fun (): R|kotlin/Unit| { - ^ String(test_6_1) + String(test_6_1) } , = myRun@fun (): R|kotlin/Unit| { - ^ String(test_6_2) + String(test_6_2) } ) } public final fun test_7(): R|kotlin/Unit| { R|/myRun|(block2 = myRun@fun (): R|kotlin/Unit| { - ^ String(test_7_2) + String(test_7_2) } , block1 = myRun@fun (): R|kotlin/Unit| { - ^ String(test_7_1) + String(test_7_1) } ) } @@ -60,7 +60,7 @@ FILE: callsInPlace.kt } public final fun test_8(): R|kotlin/Unit| { R|/myDummyRun|( = myDummyRun@fun (): R|kotlin/Unit| { - ^ String(test_8) + String(test_8) } ) } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/hashTableWithForEach.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/hashTableWithForEach.txt index 4da94d184ca..160e05c30c9 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/hashTableWithForEach.txt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/hashTableWithForEach.txt @@ -15,7 +15,7 @@ FILE: hashTableWithForEach.kt R|/DEBUG| -> { ^ Q|java/util/Collections|.R|java/util/Collections.unmodifiableSet|, kotlin/collections/MutableMap.MutableEntry?>!|>(R|kotlin/collections/mutableSetOf||>().R|kotlin/apply|>|>( = apply@fun R|kotlin/collections/MutableSet>|.(): R|kotlin/Unit| { this@R|/SomeHashTable|.R|/SomeHashTable.forEach|( = forEach@fun (key: R|K|, value: R|V|): R|kotlin/Unit| { - ^ this@R|special/anonymous|.R|FakeOverride|(R|/SomeHashTable.Entry.Entry|(R|/key|, R|/value|)) + this@R|special/anonymous|.R|FakeOverride|(R|/SomeHashTable.Entry.Entry|(R|/key|, R|/value|)) } ) } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/inference/builderInference.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/inference/builderInference.txt index f22324c775b..51d244e4873 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/inference/builderInference.txt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/inference/builderInference.txt @@ -6,7 +6,7 @@ FILE: builderInference.kt } public final fun test(): R|kotlin/Unit| { lval s: R|kotlin/String| = R|/foo|( = foo@fun R|kotlin/collections/MutableList|.(): R|kotlin/Unit| { - ^ this@R|special/anonymous|.R|FakeOverride|(String()) + this@R|special/anonymous|.R|FakeOverride|(String()) } ) R|/takeString|(R|/s|) diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/inference/builderInferenceFromStdlib.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/inference/builderInferenceFromStdlib.txt index bc77332b341..8b6b2b8e15d 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/inference/builderInferenceFromStdlib.txt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/inference/builderInferenceFromStdlib.txt @@ -1,14 +1,14 @@ FILE: builderInferenceFromStdlib.kt public final fun test_1(): R|kotlin/Unit| { lval list: R|kotlin/collections/List| = R|kotlin/collections/buildList|( = buildList@fun R|kotlin/collections/MutableList|.(): R|kotlin/Unit| { - ^ this@R|special/anonymous|.R|FakeOverride|(String()) + this@R|special/anonymous|.R|FakeOverride|(String()) } ) R|/takeList|(R|/list|) } public final fun test_2(): R|kotlin/Unit| { lval list: R|kotlin/collections/List| = R|/myBuildList|( = myBuildList@fun R|kotlin/collections/MutableList|.(): R|kotlin/Unit| { - ^ this@R|special/anonymous|.R|FakeOverride|(String()) + this@R|special/anonymous|.R|FakeOverride|(String()) } ) R|/takeList|(R|/list|) diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/MyMap.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/MyMap.txt index 3577ca88c65..c205590d84b 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/MyMap.txt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/MyMap.txt @@ -9,7 +9,7 @@ FILE: test.kt R|/map|.R|FakeOverride|( = forEach@fun (key: R|ft!|, value: R|ft!|): R|kotlin/Unit| { R|kotlin/io/println|((R|/key|.R|kotlin/Any.toString|(), String(: ), R|/value|.R|kotlin/Any.toString|())) R|/key|.R|kotlin/String.length| - ^ R|/value|.R|kotlin/String.length| + R|/value|.R|kotlin/String.length| } ) R|/map|.R|kotlin/collections/forEach|!|, R|ft!|>( = forEach@fun (: R|kotlin/collections/Map.Entry!, ft!>|): R|kotlin/Unit| { @@ -17,7 +17,7 @@ FILE: test.kt lval value: R|ft!| = R|/|.R|kotlin/collections/component2|!|, R|ft!|>() R|kotlin/io/println|((R|/key|.R|kotlin/Any.toString|(), String(: ), R|/value|.R|kotlin/Any.toString|())) R|/key|.R|kotlin/String.length| - ^ R|/value|.R|kotlin/String.length| + R|/value|.R|kotlin/String.length| } ) } @@ -31,7 +31,7 @@ FILE: test.kt R|/map|.R|FakeOverride|( = forEach@fun (key: R|ft!|, value: R|ft!|): R|kotlin/Unit| { R|kotlin/io/println|((R|/key|.R|kotlin/Any.toString|(), String(: ), R|/value|.R|kotlin/Any.toString|())) R|/key|.R|kotlin/String.length| - ^ R|/value|.R|kotlin/String.length| + R|/value|.R|kotlin/String.length| } ) R|/map|.R|kotlin/collections/forEach|( = forEach@fun (: R|kotlin/collections/Map.Entry|): R|kotlin/Unit| { @@ -39,7 +39,7 @@ FILE: test.kt lval value: R|kotlin/String| = R|/|.R|kotlin/collections/component2|() R|kotlin/io/println|((R|/key|.R|kotlin/Any.toString|(), String(: ), R|/value|.R|kotlin/Any.toString|())) R|/key|.R|kotlin/String.length| - ^ R|/value|.R|kotlin/String.length| + R|/value|.R|kotlin/String.length| } ) } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/SyntheticWithForEach.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/SyntheticWithForEach.txt index 15b731930ca..301a91e87af 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/SyntheticWithForEach.txt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/SyntheticWithForEach.txt @@ -2,12 +2,12 @@ FILE: test.kt public final fun R|Call|.testForEach(): R|kotlin/Unit| { this@R|/testForEach|.R|/Call.arguments|.R|FakeOverride|( = forEach@fun (key: R|ft!|, value: R|ft!|): R|kotlin/Unit| { R|/key|.R|kotlin/String.length| - ^ R|/value|.R|kotlin/String.length| + R|/value|.R|kotlin/String.length| } ) this@R|/testForEach|.R|/Call.arguments|.R|kotlin/collections/forEach|!|, R|ft!|>( = forEach@fun (it: R|kotlin/collections/Map.Entry!, ft!>|): R|kotlin/Unit| { R|/it|.R|FakeOverride!|>|.R|kotlin/String.length| - ^ R|/it|.R|FakeOverride!|>|.R|kotlin/String.length| + R|/it|.R|FakeOverride!|>|.R|kotlin/String.length| } ) } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/mapList.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/mapList.txt index 81b205011a0..81603d6f6f5 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/mapList.txt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/mapList.txt @@ -7,7 +7,7 @@ FILE: mapList.kt ) R|/u|.R|/applyX||>( = applyX@fun R|kotlin/collections/List|.(): R|kotlin/Unit| { this@R|special/anonymous|.R|FakeOverride|(Int(1)) - ^ this@R|special/anonymous|.R|FakeOverride|(Int(1)) + this@R|special/anonymous|.R|FakeOverride|(Int(1)) } ) } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/noneWithForEach.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/noneWithForEach.txt index f61da3884a6..4ebcc56e213 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/noneWithForEach.txt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/noneWithForEach.txt @@ -11,7 +11,7 @@ FILE: noneWithForEach.kt } ).R|kotlin/collections/forEach||>( = forEach@fun (it: R|kotlin/collections/Map.Entry>|): R|kotlin/Unit| { lval diagnostics: R|kotlin/collections/List| = R|/it|.R|FakeOverride|>| - ^ R|/filtered|.R|FakeOverride|(R|/diagnostics|.R|kotlin/collections/filter|( = filter@fun (me: R|Diagnostic|): R|kotlin/Boolean| { + R|/filtered|.R|FakeOverride|(R|/diagnostics|.R|kotlin/collections/filter|( = filter@fun (me: R|Diagnostic|): R|kotlin/Boolean| { ^ R|/diagnostics|.R|kotlin/collections/none|( = none@fun (other: R|Diagnostic|): R|kotlin/Boolean| { ^ !=(R|/me|, R|/other|) } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt index 5a237acc072..64837822d63 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt @@ -748,6 +748,12 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor } private fun FirAnonymousFunction.addReturn(): FirAnonymousFunction { + // If this lambda's resolved, expected return type is Unit, we don't need an explicit return statement. + // During conversion (to backend IR), the last expression will be coerced to Unit if needed. + // As per KT-41005, we should not force coercion to Unit for nullable return type, though. + if (returnTypeRef.isUnit && body?.typeRef?.isMarkedNullable == false) { + return this + } val lastStatement = body?.statements?.lastOrNull() val returnType = (body?.typeRef as? FirResolvedTypeRef) ?: return this val returnNothing = returnType.isNothing || returnType.isUnit diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/FirTypeUtils.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/FirTypeUtils.kt index 0819c0d5ba5..17ac072b9a4 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/FirTypeUtils.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/FirTypeUtils.kt @@ -35,15 +35,21 @@ val FirTypeRef.isArrayType: Boolean isBuiltinType(StandardClassIds.Array, false) || StandardClassIds.primitiveArrayTypeByElementType.values.any { isBuiltinType(it, false) } -private fun FirTypeRef.isBuiltinType(classId: ClassId, isNullable: Boolean): Boolean { - val type = when (this) { +private val FirTypeRef.classLikeTypeOrNull: ConeClassLikeType? + get() = when (this) { is FirImplicitBuiltinTypeRef -> type - is FirResolvedTypeRef -> type as? ConeClassLikeType ?: return false - else -> return false + is FirResolvedTypeRef -> type as? ConeClassLikeType + else -> null } + +private fun FirTypeRef.isBuiltinType(classId: ClassId, isNullable: Boolean): Boolean { + val type = this.classLikeTypeOrNull ?: return false return type.lookupTag.classId == classId && type.isNullable == isNullable } +val FirTypeRef.isMarkedNullable: Boolean? + get() = classLikeTypeOrNull?.isMarkedNullable + val FirFunctionTypeRef.parametersCount: Int get() = if (receiverTypeRef != null) valueParameters.size + 1 diff --git a/compiler/testData/codegen/box/coroutines/coercionToUnit.kt b/compiler/testData/codegen/box/coroutines/coercionToUnit.kt index 87cb2fa583f..f26e8fdf6d0 100644 --- a/compiler/testData/codegen/box/coroutines/coercionToUnit.kt +++ b/compiler/testData/codegen/box/coroutines/coercionToUnit.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // WITH_COROUTINES // COMMON_COROUTINES_TEST diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/throwInTryWithHandleResult.kt b/compiler/testData/codegen/box/coroutines/controlFlow/throwInTryWithHandleResult.kt index db8b2515b94..d01e25273c0 100644 --- a/compiler/testData/codegen/box/coroutines/controlFlow/throwInTryWithHandleResult.kt +++ b/compiler/testData/codegen/box/coroutines/controlFlow/throwInTryWithHandleResult.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // WITH_COROUTINES // COMMON_COROUTINES_TEST diff --git a/compiler/testData/codegen/box/coroutines/handleResultNonUnitExpression.kt b/compiler/testData/codegen/box/coroutines/handleResultNonUnitExpression.kt index b13ae030bf5..8bbbfa402f8 100644 --- a/compiler/testData/codegen/box/coroutines/handleResultNonUnitExpression.kt +++ b/compiler/testData/codegen/box/coroutines/handleResultNonUnitExpression.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // WITH_COROUTINES // COMMON_COROUTINES_TEST diff --git a/compiler/testData/codegen/box/coroutines/lastStatementInc.kt b/compiler/testData/codegen/box/coroutines/lastStatementInc.kt index 8832b6ed5c3..e3cad551967 100644 --- a/compiler/testData/codegen/box/coroutines/lastStatementInc.kt +++ b/compiler/testData/codegen/box/coroutines/lastStatementInc.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // WITH_COROUTINES // COMMON_COROUTINES_TEST diff --git a/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/basic.fir.kt b/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/basic.fir.kt index 363d4dd8d6c..6a405239001 100644 --- a/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/basic.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/basic.fir.kt @@ -142,8 +142,8 @@ fun main() { val x18: (C) -> Unit = select(id { it }, { it }, id<(B) -> Unit> { x -> x }) // Resolution of extension/non-extension functions combination - val x19: String.() -> Unit = select(")!>id { this }, ")!>id(fun(x: String) {})) - val x20: String.() -> Unit = select(")!>{ this }, (fun(x: String) {})) + val x19: String.() -> Unit = select(")!>id { this }, ")!>id(fun(x: String) {})) + val x20: String.() -> Unit = select(")!>{ this }, (fun(x: String) {})) val x21: String.() -> Unit = select(")!>id(fun(x: String) {}), ")!>id(fun(x: String) {})) select(id Unit>(fun(x: String) {}), ")!>id(fun(x: String) {})) select(")!>id(fun String.(x: String) {}), ")!>id(fun(x: String, y: String) {})) diff --git a/compiler/testData/ir/irText/types/coercionToUnitInLambdaReturnValue.fir.txt b/compiler/testData/ir/irText/types/coercionToUnitInLambdaReturnValue.fir.txt deleted file mode 100644 index 3c0102af943..00000000000 --- a/compiler/testData/ir/irText/types/coercionToUnitInLambdaReturnValue.fir.txt +++ /dev/null @@ -1,12 +0,0 @@ -FILE fqName: fileName:/coercionToUnitInLambdaReturnValue.kt - FUN name:use visibility:public modality:FINAL <> (fn:kotlin.Function0) returnType:kotlin.Unit - VALUE_PARAMETER name:fn index:0 type:kotlin.Function0 - BLOCK_BODY - FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - CALL 'public final fun use (fn: kotlin.Function0): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: FUN_EXPR type=kotlin.Function0 origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (): kotlin.Unit declared in .test' - CONST Int type=kotlin.Int value=42 diff --git a/compiler/testData/ir/irText/types/coercionToUnitInLambdaReturnValue.kt b/compiler/testData/ir/irText/types/coercionToUnitInLambdaReturnValue.kt index e5b6883ae17..629ea394959 100644 --- a/compiler/testData/ir/irText/types/coercionToUnitInLambdaReturnValue.kt +++ b/compiler/testData/ir/irText/types/coercionToUnitInLambdaReturnValue.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !LANGUAGE: +NewInference fun use(fn: () -> Unit) {}