From 7d59c7689c1c0fa18978a04a8d7bb3f505361867 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steven=20Sch=C3=A4fer?= Date: Mon, 13 Jun 2022 14:49:49 +0200 Subject: [PATCH] JVM IR: Avoid direct invokes in callable reference tests Due to the direct invoke optimization, most callable reference tests were not generating callable references/lambdas. --- .../bound/arrayGetIntrinsic.kt | 2 +- .../bound/companionObjectReceiver.kt | 2 +- .../box/callableReference/bound/emptyLHS.kt | 48 +++++++++---------- .../bound/genericValOnLHS.kt | 4 +- .../box/callableReference/bound/kt15446.kt | 6 +-- .../callableReference/bound/objectReceiver.kt | 2 +- .../box/callableReference/constructor.kt | 3 +- .../function/abstractClassMember.kt | 2 +- .../function/booleanNotIntrinsic.kt | 4 +- .../function/classMemberFromClass.kt | 2 +- .../function/classMemberFromExtension.kt | 2 +- .../function/constructorFromTopLevelNoArgs.kt | 2 +- .../constructorFromTopLevelOneStringArg.kt | 2 +- .../function/equalsIntrinsic.kt | 2 +- .../function/extensionFromClass.kt | 2 +- .../function/extensionFromExtension.kt | 2 +- .../function/genericMember.kt | 2 +- .../function/innerConstructorFromClass.kt | 2 +- .../function/innerConstructorFromExtension.kt | 2 +- .../innerConstructorFromTopLevelNoArgs.kt | 2 +- ...nnerConstructorFromTopLevelOneStringArg.kt | 5 +- .../function/javaCollectionsStaticMethod.kt | 2 +- .../function/local/constructor.kt | 2 +- .../local/constructorWithInitializer.kt | 2 +- .../function/local/extension.kt | 2 +- .../function/local/extensionToLocalClass.kt | 2 +- .../function/local/extensionToPrimitive.kt | 2 +- .../function/local/recursiveClosure.kt | 2 +- .../function/local/simple.kt | 2 +- .../function/local/simpleClosure.kt | 2 +- .../function/local/simpleWithArg.kt | 2 +- .../function/nestedConstructorFromClass.kt | 2 +- .../nestedConstructorFromTopLevelNoArgs.kt | 2 +- ...stedConstructorFromTopLevelOneStringArg.kt | 2 +- .../function/privateClassMember.kt | 2 +- .../function/topLevelFromClass.kt | 2 +- .../function/topLevelFromExtension.kt | 2 +- .../traitImplMethodWithClassReceiver.kt | 2 +- .../callableReference/function/traitMember.kt | 2 +- .../box/callableReference/staticMethod.kt | 2 +- .../box/classes/privateOuterFunctions.kt | 2 +- .../box/classes/privateOuterProperty.kt | 2 +- .../testData/codegen/box/closures/kt4137.kt | 2 +- .../codegen/box/closures/localFunInInit.kt | 2 +- .../codegen/box/controlStructures/kt2597.kt | 2 +- .../callableReference/bound/emptyLHS.kt | 24 +++++----- .../callableReference/lambdaParameterUsed.kt | 2 +- .../coroutines/localFunctions/named/rec.kt | 6 +-- .../simpleSuspendCallableReference.kt | 2 +- .../codegen/box/defaultArguments/protected.kt | 2 +- .../box/delegatedProperty/local/kt16864.kt | 2 +- .../boundInnerContructorRef.kt | 2 +- .../boundMemberRef.kt | 2 +- .../directInvokeOptimization/contructorRef.kt | 2 +- .../directInvokeOptimization/nestedLambdas.kt | 2 +- .../simpleAnonymousFun.kt | 2 +- .../directInvokeOptimization/simpleFunRef.kt | 2 +- .../directInvokeOptimization/simpleLambda.kt | 2 +- .../unboundInnerContructorRef.kt | 2 +- .../unboundMemberRef.kt | 4 ++ .../codegen/box/extensionFunctions/kt3298.kt | 2 +- .../functions/invoke/extensionInvokeOnExpr.kt | 4 +- .../invoke/invokeOnExprByConvention.kt | 4 +- .../testData/codegen/box/functions/kt2481.kt | 2 +- .../box/functions/localFunctions/kt2895.kt | 2 +- .../overloadedLocalFunction3.kt | 2 +- .../boundInlineClassExtensionFun.kt | 6 +-- .../boundInlineClassExtensionFunGeneric.kt | 6 +-- .../boundInlineClassMemberFun.kt | 6 +-- .../boundInlineClassMemberFunGeneric.kt | 6 +-- .../constructorWithInlineClassParameters.kt | 6 +-- ...tructorWithInlineClassParametersGeneric.kt | 6 +-- .../funWithInlineClassParameters.kt | 2 +- .../funWithInlineClassParametersGeneric.kt | 2 +- .../inlineClassExtensionFun.kt | 6 +-- .../inlineClassExtensionFunGeneric.kt | 6 +-- .../inlineClassMemberFun.kt | 6 +-- .../inlineClassMemberFunGeneric.kt | 6 +-- .../callableReferencesWithInlineClasses.kt | 2 +- ...lableReferencesWithInlineClassesGeneric.kt | 2 +- ...cessPrivateInlineClassMethodFromLambda2.kt | 2 +- ...vateInlineClassMethodFromLambda2Generic.kt | 2 +- .../captureInlineClassInstanceInLambda.kt | 2 +- .../captureInlineClassInstanceInLambda2.kt | 2 +- ...tureInlineClassInstanceInLambda2Generic.kt | 2 +- ...ptureInlineClassInstanceInLambdaGeneric.kt | 2 +- .../captureLocalVarDelegatedToInlineClass.kt | 6 +-- ...reLocalVarDelegatedToInlineClassGeneric.kt | 6 +-- .../testData/codegen/box/intrinsics/kt8666.kt | 16 +++---- .../codegen/box/jvm8/defaults/accessor.kt | 2 +- .../defaults/accessorsFromDefaultImpls.kt | 2 +- .../defaults/allCompatibility/accessor.kt | 2 +- .../box/jvm8/defaults/callableReference.kt | 2 +- .../jvm8/defaults/noDefaultImpls/accessor.kt | 2 +- .../box/jvmField/captureClassFields.kt | 2 +- .../codegen/box/jvmName/callableReference.kt | 2 +- .../testData/codegen/box/jvmStatic/closure.kt | 12 ++--- .../box/jvmStatic/functionReference.kt | 2 +- .../codegen/box/jvmStatic/kt21246a.kt | 2 +- .../labels/propertyAccessorFunctionLiteral.kt | 2 +- .../forIterator/MultiDeclForValCaptured.kt | 2 +- ...tiDeclForComponentExtensionsValCaptured.kt | 2 +- .../forRange/MultiDeclForValCaptured.kt | 2 +- .../MultiDeclForValCaptured.kt | 2 +- ...tiDeclForComponentExtensionsValCaptured.kt | 2 +- ...tiDeclForComponentExtensionsValCaptured.kt | 2 +- .../MultiDeclForValCaptured.kt | 2 +- ...tiDeclForComponentExtensionsValCaptured.kt | 2 +- ...tiDeclForComponentExtensionsValCaptured.kt | 2 +- ...tiDeclForComponentExtensionsValCaptured.kt | 2 +- ...tiDeclForComponentExtensionsValCaptured.kt | 2 +- .../optimized/callableRefToFun.kt | 2 +- .../anonymousObjectPropertyInitialization.kt | 2 +- .../testData/codegen/box/properties/kt2331.kt | 2 +- .../contains/nullableInPrimitiveRange.kt | 4 +- .../noPrivateNoAccessorsInMultiFileFacade.kt | 2 +- .../noPrivateNoAccessorsInMultiFileFacade2.kt | 2 +- .../traitWithPrivateMemberAccessFromLambda.kt | 4 +- compiler/testData/codegen/box/unit/kt4265.kt | 6 +-- .../testData/codegen/box/unit/sillyThings.kt | 4 +- .../capturedValInLambdaInitializedOutside.kt | 2 +- .../lateinit/companionObjectFromLambda.kt | 8 ++-- .../when/exhaustiveWhenSpecialCases.kt | 2 +- 123 files changed, 216 insertions(+), 208 deletions(-) diff --git a/compiler/testData/codegen/box/callableReference/bound/arrayGetIntrinsic.kt b/compiler/testData/codegen/box/callableReference/bound/arrayGetIntrinsic.kt index 2e367377469..9dd8160a95f 100644 --- a/compiler/testData/codegen/box/callableReference/bound/arrayGetIntrinsic.kt +++ b/compiler/testData/codegen/box/callableReference/bound/arrayGetIntrinsic.kt @@ -1,4 +1,4 @@ fun box(): String { - return if ((arrayOf(1, 2, 3)::get)(1) == 2) "OK" else "Fail" + return if ((arrayOf(1, 2, 3)::get).let { it(1) } == 2) "OK" else "Fail" } diff --git a/compiler/testData/codegen/box/callableReference/bound/companionObjectReceiver.kt b/compiler/testData/codegen/box/callableReference/bound/companionObjectReceiver.kt index de6f3e28552..dea1d40855b 100644 --- a/compiler/testData/codegen/box/callableReference/bound/companionObjectReceiver.kt +++ b/compiler/testData/codegen/box/callableReference/bound/companionObjectReceiver.kt @@ -5,4 +5,4 @@ class A { } } -fun box() = (A.Companion::ok)() \ No newline at end of file +fun box() = (A.Companion::ok).let { it() } \ No newline at end of file diff --git a/compiler/testData/codegen/box/callableReference/bound/emptyLHS.kt b/compiler/testData/codegen/box/callableReference/bound/emptyLHS.kt index e83e406c73b..dda296e4039 100644 --- a/compiler/testData/codegen/box/callableReference/bound/emptyLHS.kt +++ b/compiler/testData/codegen/box/callableReference/bound/emptyLHS.kt @@ -7,11 +7,11 @@ class A { val aMemberProperty: Int get() = 42.also { result += "A.amp," } fun test(): String { - (::memberFunction)() - (::aExtensionFunction)() + (::memberFunction).let { it() } + (::aExtensionFunction).let { it() } - (::memberProperty)() - (::aExtensionProperty)() + (::memberProperty).let { it() } + (::aExtensionProperty).let { it() } return result } @@ -21,17 +21,17 @@ class A { val memberProperty: Int get() = 42.also { result += "B.mp," } fun test(): String { - (::aMemberFunction)() - (::aExtensionFunction)() + (::aMemberFunction).let { it() } + (::aExtensionFunction).let { it() } - (::aMemberProperty)() - (::aExtensionProperty)() + (::aMemberProperty).let { it() } + (::aExtensionProperty).let { it() } - (::memberFunction)() - (::memberProperty)() + (::memberFunction).let { it() } + (::memberProperty).let { it() } - (::bExtensionFunction)() - (::bExtensionProperty)() + (::bExtensionFunction).let { it() } + (::bExtensionProperty).let { it() } return result } @@ -53,28 +53,28 @@ fun box(): String { result = "" with(A()) { - (::memberFunction)() - (::aExtensionFunction)() + (::memberFunction).let { it() } + (::aExtensionFunction).let { it() } - (::memberProperty)() - (::aExtensionProperty)() + (::memberProperty).let { it() } + (::aExtensionProperty).let { it() } } if (result != "A.mf,A.ef,A.mp,A.ep,") return "Fail $result" result = "" with(A()) { with(B()) { - (::aMemberFunction)() - (::aExtensionFunction)() + (::aMemberFunction).let { it() } + (::aExtensionFunction).let { it() } - (::aMemberProperty)() - (::aExtensionProperty)() + (::aMemberProperty).let { it() } + (::aExtensionProperty).let { it() } - (::memberFunction)() - (::memberProperty)() + (::memberFunction).let { it() } + (::memberProperty).let { it() } - (::bExtensionFunction)() - (::bExtensionProperty)() + (::bExtensionFunction).let { it() } + (::bExtensionProperty).let { it() } } } if (result != "A.amf,A.ef,A.amp,A.ep,B.mf,B.mp,B.ef,B.ep,") return "Fail $result" diff --git a/compiler/testData/codegen/box/callableReference/bound/genericValOnLHS.kt b/compiler/testData/codegen/box/callableReference/bound/genericValOnLHS.kt index 8911473c689..19735df9e46 100644 --- a/compiler/testData/codegen/box/callableReference/bound/genericValOnLHS.kt +++ b/compiler/testData/codegen/box/callableReference/bound/genericValOnLHS.kt @@ -7,6 +7,6 @@ class Host { fun box(): String { Generic(Host()).p::class - (Generic(Host()).p::t)() - return (Generic(Host()).p::v)() + (Generic(Host()).p::t).let { it() } + return (Generic(Host()).p::v).let { it() } } diff --git a/compiler/testData/codegen/box/callableReference/bound/kt15446.kt b/compiler/testData/codegen/box/callableReference/bound/kt15446.kt index a65f2ee7016..43e5d2c1feb 100644 --- a/compiler/testData/codegen/box/callableReference/bound/kt15446.kt +++ b/compiler/testData/codegen/box/callableReference/bound/kt15446.kt @@ -3,13 +3,13 @@ fun box(): String { val a = intArrayOf(1, 2) val b = arrayOf("OK") - if ((a::component2)() != 2) { + if ((a::component2).let { it() } != 2) { return "fail" } - if ((a::get)(1) != 2) { + if ((a::get).let { it(1) } != 2) { return "fail" } - return (b::get)(0) + return (b::get).let { it(0) } } \ No newline at end of file diff --git a/compiler/testData/codegen/box/callableReference/bound/objectReceiver.kt b/compiler/testData/codegen/box/callableReference/bound/objectReceiver.kt index 4595a7aab50..74ec122d26c 100644 --- a/compiler/testData/codegen/box/callableReference/bound/objectReceiver.kt +++ b/compiler/testData/codegen/box/callableReference/bound/objectReceiver.kt @@ -3,4 +3,4 @@ object Singleton { fun ok() = "OK" } -fun box() = (Singleton::ok)() \ No newline at end of file +fun box() = (Singleton::ok).let { it() } \ No newline at end of file diff --git a/compiler/testData/codegen/box/callableReference/constructor.kt b/compiler/testData/codegen/box/callableReference/constructor.kt index 8d9703bec2f..7c1ca6af4a9 100644 --- a/compiler/testData/codegen/box/callableReference/constructor.kt +++ b/compiler/testData/codegen/box/callableReference/constructor.kt @@ -10,6 +10,7 @@ class A { // FILE: 1.kt fun box(): String { - (::A)(0.0, 0) + val constructor = ::A + constructor(0.0, 0) return "OK" } diff --git a/compiler/testData/codegen/box/callableReference/function/abstractClassMember.kt b/compiler/testData/codegen/box/callableReference/function/abstractClassMember.kt index 515b25914d0..63566a3ac61 100644 --- a/compiler/testData/codegen/box/callableReference/function/abstractClassMember.kt +++ b/compiler/testData/codegen/box/callableReference/function/abstractClassMember.kt @@ -6,4 +6,4 @@ class B : A() { override fun foo() = "OK" } -fun box(): String = (A::foo)(B()) +fun box(): String = (A::foo).let { it(B()) } diff --git a/compiler/testData/codegen/box/callableReference/function/booleanNotIntrinsic.kt b/compiler/testData/codegen/box/callableReference/function/booleanNotIntrinsic.kt index 213c8d88996..bb9693eea81 100644 --- a/compiler/testData/codegen/box/callableReference/function/booleanNotIntrinsic.kt +++ b/compiler/testData/codegen/box/callableReference/function/booleanNotIntrinsic.kt @@ -1,5 +1,5 @@ fun box(): String { - if ((Boolean::not)(true) != false) return "Fail 1" - if ((Boolean::not)(false) != true) return "Fail 2" + if ((Boolean::not).let { it(true) } != false) return "Fail 1" + if ((Boolean::not).let { it(false) } != true) return "Fail 2" return "OK" } diff --git a/compiler/testData/codegen/box/callableReference/function/classMemberFromClass.kt b/compiler/testData/codegen/box/callableReference/function/classMemberFromClass.kt index 3ed816ee504..83d7e161c7b 100644 --- a/compiler/testData/codegen/box/callableReference/function/classMemberFromClass.kt +++ b/compiler/testData/codegen/box/callableReference/function/classMemberFromClass.kt @@ -1,7 +1,7 @@ class A { fun foo(k: Int) = k - fun result() = (A::foo)(this, 111) + fun result() = (A::foo).let { it(this, 111) } } fun box(): String { diff --git a/compiler/testData/codegen/box/callableReference/function/classMemberFromExtension.kt b/compiler/testData/codegen/box/callableReference/function/classMemberFromExtension.kt index 9619233c943..7ace23841d0 100644 --- a/compiler/testData/codegen/box/callableReference/function/classMemberFromExtension.kt +++ b/compiler/testData/codegen/box/callableReference/function/classMemberFromExtension.kt @@ -3,7 +3,7 @@ class A { fun k(k: Int) = k } -fun A.foo() = (A::o)(this) + (A::k)(this, 222) +fun A.foo() = (A::o).let { it(this) } + (A::k).let { it(this, 222) } fun box(): String { val result = A().foo() diff --git a/compiler/testData/codegen/box/callableReference/function/constructorFromTopLevelNoArgs.kt b/compiler/testData/codegen/box/callableReference/function/constructorFromTopLevelNoArgs.kt index db7b7fd01ef..405d622eb29 100644 --- a/compiler/testData/codegen/box/callableReference/function/constructorFromTopLevelNoArgs.kt +++ b/compiler/testData/codegen/box/callableReference/function/constructorFromTopLevelNoArgs.kt @@ -2,4 +2,4 @@ class A { var result = "OK" } -fun box() = (::A)().result +fun box() = (::A).let { it() }.result diff --git a/compiler/testData/codegen/box/callableReference/function/constructorFromTopLevelOneStringArg.kt b/compiler/testData/codegen/box/callableReference/function/constructorFromTopLevelOneStringArg.kt index 63a861dbcf4..ba347d93a37 100644 --- a/compiler/testData/codegen/box/callableReference/function/constructorFromTopLevelOneStringArg.kt +++ b/compiler/testData/codegen/box/callableReference/function/constructorFromTopLevelOneStringArg.kt @@ -1,3 +1,3 @@ class A(val result: String) -fun box() = (::A)("OK").result +fun box() = (::A).let { it("OK") }.result diff --git a/compiler/testData/codegen/box/callableReference/function/equalsIntrinsic.kt b/compiler/testData/codegen/box/callableReference/function/equalsIntrinsic.kt index c83a188802d..0df776549a6 100644 --- a/compiler/testData/codegen/box/callableReference/function/equalsIntrinsic.kt +++ b/compiler/testData/codegen/box/callableReference/function/equalsIntrinsic.kt @@ -1,3 +1,3 @@ class A -fun box() = if ((A::equals)(A(), A())) "Fail" else "OK" +fun box() = if ((A::equals).let { it(A(), A()) }) "Fail" else "OK" diff --git a/compiler/testData/codegen/box/callableReference/function/extensionFromClass.kt b/compiler/testData/codegen/box/callableReference/function/extensionFromClass.kt index 0248c2f9f2c..25d6aa44ba5 100644 --- a/compiler/testData/codegen/box/callableReference/function/extensionFromClass.kt +++ b/compiler/testData/codegen/box/callableReference/function/extensionFromClass.kt @@ -1,5 +1,5 @@ class A { - fun result() = (A::foo)(this, "OK") + fun result() = (A::foo).let { it(this, "OK") } } fun A.foo(x: String) = x diff --git a/compiler/testData/codegen/box/callableReference/function/extensionFromExtension.kt b/compiler/testData/codegen/box/callableReference/function/extensionFromExtension.kt index 103ceee5cbc..4364c469115 100644 --- a/compiler/testData/codegen/box/callableReference/function/extensionFromExtension.kt +++ b/compiler/testData/codegen/box/callableReference/function/extensionFromExtension.kt @@ -1,6 +1,6 @@ class A -fun A.foo() = (A::bar)(this, "OK") +fun A.foo() = (A::bar).let { it(this, "OK") } fun A.bar(x: String) = x diff --git a/compiler/testData/codegen/box/callableReference/function/genericMember.kt b/compiler/testData/codegen/box/callableReference/function/genericMember.kt index 25dabc055f2..70f7258f6eb 100644 --- a/compiler/testData/codegen/box/callableReference/function/genericMember.kt +++ b/compiler/testData/codegen/box/callableReference/function/genericMember.kt @@ -2,4 +2,4 @@ class A(val t: T) { fun foo(): T = t } -fun box() = (A::foo)(A("OK")) +fun box() = (A::foo).let { it(A("OK")) } diff --git a/compiler/testData/codegen/box/callableReference/function/innerConstructorFromClass.kt b/compiler/testData/codegen/box/callableReference/function/innerConstructorFromClass.kt index 31bb102ee62..a4333d5d09f 100644 --- a/compiler/testData/codegen/box/callableReference/function/innerConstructorFromClass.kt +++ b/compiler/testData/codegen/box/callableReference/function/innerConstructorFromClass.kt @@ -4,7 +4,7 @@ class A { val k = 222 } - fun result() = (A::Inner)(this).o + (A::Inner)(this).k + fun result() = (A::Inner).let { it(this) }.o + (A::Inner).let { it(this) }.k } fun box(): String { diff --git a/compiler/testData/codegen/box/callableReference/function/innerConstructorFromExtension.kt b/compiler/testData/codegen/box/callableReference/function/innerConstructorFromExtension.kt index bcde4b24cae..23238b80f05 100644 --- a/compiler/testData/codegen/box/callableReference/function/innerConstructorFromExtension.kt +++ b/compiler/testData/codegen/box/callableReference/function/innerConstructorFromExtension.kt @@ -5,7 +5,7 @@ class A { } } -fun A.foo() = (A::Inner)(this).o + (A::Inner)(this).k +fun A.foo() = (A::Inner).let { it(this) }.o + (A::Inner).let { it(this) }.k fun box(): String { val result = A().foo() diff --git a/compiler/testData/codegen/box/callableReference/function/innerConstructorFromTopLevelNoArgs.kt b/compiler/testData/codegen/box/callableReference/function/innerConstructorFromTopLevelNoArgs.kt index 577eb19e7af..440c34b1a83 100644 --- a/compiler/testData/codegen/box/callableReference/function/innerConstructorFromTopLevelNoArgs.kt +++ b/compiler/testData/codegen/box/callableReference/function/innerConstructorFromTopLevelNoArgs.kt @@ -6,7 +6,7 @@ class A { } fun box(): String { - val result = (A::Inner)((::A)()).o + (A::Inner)(A()).k + val result = (A::Inner).let { c -> c((::A).let { it() }).o } + (A::Inner).let { it(A()) }.k if (result != 333) return "Fail $result" return "OK" } diff --git a/compiler/testData/codegen/box/callableReference/function/innerConstructorFromTopLevelOneStringArg.kt b/compiler/testData/codegen/box/callableReference/function/innerConstructorFromTopLevelOneStringArg.kt index 0eb2b831a2b..32ffd572e64 100644 --- a/compiler/testData/codegen/box/callableReference/function/innerConstructorFromTopLevelOneStringArg.kt +++ b/compiler/testData/codegen/box/callableReference/function/innerConstructorFromTopLevelOneStringArg.kt @@ -3,7 +3,10 @@ class A { } fun box(): String { - val result = (A::Inner)((::A)(), 111).result + (A::Inner)(A(), 222).result + val result = (A::Inner).let { c -> c((::A).let { it() }, 111) }.result + (A::Inner).let { it(A(), 222) }.result if (result != 333) return "Fail $result" return "OK" } + +// CHECK_BYTECODE_TEXT +// 3 Function[^.\n]*\.invoke diff --git a/compiler/testData/codegen/box/callableReference/function/javaCollectionsStaticMethod.kt b/compiler/testData/codegen/box/callableReference/function/javaCollectionsStaticMethod.kt index c28d727bdd5..8d3cd00917c 100644 --- a/compiler/testData/codegen/box/callableReference/function/javaCollectionsStaticMethod.kt +++ b/compiler/testData/codegen/box/callableReference/function/javaCollectionsStaticMethod.kt @@ -10,6 +10,6 @@ fun box(): String { numbers.add(1) numbers.add(2) numbers.add(3) - (Collections::rotate)(numbers, 1) + (Collections::rotate).let { it(numbers, 1) } return if ("$numbers" == "[3, 1, 2]") "OK" else "Fail $numbers" } diff --git a/compiler/testData/codegen/box/callableReference/function/local/constructor.kt b/compiler/testData/codegen/box/callableReference/function/local/constructor.kt index 291af016082..71ea6266696 100644 --- a/compiler/testData/codegen/box/callableReference/function/local/constructor.kt +++ b/compiler/testData/codegen/box/callableReference/function/local/constructor.kt @@ -3,5 +3,5 @@ fun box(): String { val result = "OK" } - return (::A)().result + return (::A).let { it() }.result } diff --git a/compiler/testData/codegen/box/callableReference/function/local/constructorWithInitializer.kt b/compiler/testData/codegen/box/callableReference/function/local/constructorWithInitializer.kt index 0e8c0a25839..b6f57166397 100644 --- a/compiler/testData/codegen/box/callableReference/function/local/constructorWithInitializer.kt +++ b/compiler/testData/codegen/box/callableReference/function/local/constructorWithInitializer.kt @@ -6,5 +6,5 @@ fun box(): String { } } - return (::A)().result + return (::A).let { it() }.result } diff --git a/compiler/testData/codegen/box/callableReference/function/local/extension.kt b/compiler/testData/codegen/box/callableReference/function/local/extension.kt index 3919a320e81..6471f4231ee 100644 --- a/compiler/testData/codegen/box/callableReference/function/local/extension.kt +++ b/compiler/testData/codegen/box/callableReference/function/local/extension.kt @@ -2,5 +2,5 @@ class A fun box(): String { fun A.foo() = "OK" - return (A::foo)(A()) + return (A::foo).let { it(A()) } } diff --git a/compiler/testData/codegen/box/callableReference/function/local/extensionToLocalClass.kt b/compiler/testData/codegen/box/callableReference/function/local/extensionToLocalClass.kt index 43537f177e9..dc63f6d408d 100644 --- a/compiler/testData/codegen/box/callableReference/function/local/extensionToLocalClass.kt +++ b/compiler/testData/codegen/box/callableReference/function/local/extensionToLocalClass.kt @@ -1,5 +1,5 @@ fun box(): String { class A fun A.foo() = "OK" - return (A::foo)((::A)()) + return (A::foo).let { c -> c((::A).let { it() }) } } diff --git a/compiler/testData/codegen/box/callableReference/function/local/extensionToPrimitive.kt b/compiler/testData/codegen/box/callableReference/function/local/extensionToPrimitive.kt index 9cb84f4df07..1d5870af1fc 100644 --- a/compiler/testData/codegen/box/callableReference/function/local/extensionToPrimitive.kt +++ b/compiler/testData/codegen/box/callableReference/function/local/extensionToPrimitive.kt @@ -1,4 +1,4 @@ fun box(): String { fun Int.is42With(that: Int) = this + 2 * that == 42 - return if ((Int::is42With)(16, 13)) "OK" else "Fail" + return if ((Int::is42With).let { it(16, 13) }) "OK" else "Fail" } diff --git a/compiler/testData/codegen/box/callableReference/function/local/recursiveClosure.kt b/compiler/testData/codegen/box/callableReference/function/local/recursiveClosure.kt index 75ca4009a47..afb877648ba 100644 --- a/compiler/testData/codegen/box/callableReference/function/local/recursiveClosure.kt +++ b/compiler/testData/codegen/box/callableReference/function/local/recursiveClosure.kt @@ -1,7 +1,7 @@ fun foo(until: Int): String { fun bar(x: Int): String = if (x == until) "OK" else bar(x + 1) - return (::bar)(0) + return (::bar).let { it(0) } } fun box() = foo(10) diff --git a/compiler/testData/codegen/box/callableReference/function/local/simple.kt b/compiler/testData/codegen/box/callableReference/function/local/simple.kt index 789703872db..1df0016eb37 100644 --- a/compiler/testData/codegen/box/callableReference/function/local/simple.kt +++ b/compiler/testData/codegen/box/callableReference/function/local/simple.kt @@ -1,4 +1,4 @@ fun box(): String { fun foo() = "OK" - return (::foo)() + return (::foo).let { it() } } diff --git a/compiler/testData/codegen/box/callableReference/function/local/simpleClosure.kt b/compiler/testData/codegen/box/callableReference/function/local/simpleClosure.kt index 5aeb154fbdd..e72a08beb48 100644 --- a/compiler/testData/codegen/box/callableReference/function/local/simpleClosure.kt +++ b/compiler/testData/codegen/box/callableReference/function/local/simpleClosure.kt @@ -3,5 +3,5 @@ fun box(): String { fun foo() = result - return (::foo)() + return (::foo).let { it() } } diff --git a/compiler/testData/codegen/box/callableReference/function/local/simpleWithArg.kt b/compiler/testData/codegen/box/callableReference/function/local/simpleWithArg.kt index e45fce85e2e..cc4de67c572 100644 --- a/compiler/testData/codegen/box/callableReference/function/local/simpleWithArg.kt +++ b/compiler/testData/codegen/box/callableReference/function/local/simpleWithArg.kt @@ -1,4 +1,4 @@ fun box(): String { fun foo(s: String) = s - return (::foo)("OK") + return (::foo).let { it("OK") } } diff --git a/compiler/testData/codegen/box/callableReference/function/nestedConstructorFromClass.kt b/compiler/testData/codegen/box/callableReference/function/nestedConstructorFromClass.kt index 8e0439f4f03..e605b1fc51c 100644 --- a/compiler/testData/codegen/box/callableReference/function/nestedConstructorFromClass.kt +++ b/compiler/testData/codegen/box/callableReference/function/nestedConstructorFromClass.kt @@ -4,7 +4,7 @@ class A { val k = 222 } - fun result() = (::Nested)().o + (A::Nested)().k + fun result() = (::Nested).let { it() }.o + (A::Nested).let { it() }.k } fun box(): String { diff --git a/compiler/testData/codegen/box/callableReference/function/nestedConstructorFromTopLevelNoArgs.kt b/compiler/testData/codegen/box/callableReference/function/nestedConstructorFromTopLevelNoArgs.kt index f99dd41ae86..def319c7a4e 100644 --- a/compiler/testData/codegen/box/callableReference/function/nestedConstructorFromTopLevelNoArgs.kt +++ b/compiler/testData/codegen/box/callableReference/function/nestedConstructorFromTopLevelNoArgs.kt @@ -4,4 +4,4 @@ class A { } } -fun box() = (A::Nested)().result +fun box() = (A::Nested).let { it() }.result diff --git a/compiler/testData/codegen/box/callableReference/function/nestedConstructorFromTopLevelOneStringArg.kt b/compiler/testData/codegen/box/callableReference/function/nestedConstructorFromTopLevelOneStringArg.kt index 3f0c03c67f3..9d68f064de7 100644 --- a/compiler/testData/codegen/box/callableReference/function/nestedConstructorFromTopLevelOneStringArg.kt +++ b/compiler/testData/codegen/box/callableReference/function/nestedConstructorFromTopLevelOneStringArg.kt @@ -2,4 +2,4 @@ class A { class Nested(val result: String) } -fun box() = (A::Nested)("OK").result +fun box() = (A::Nested).let { it("OK") }.result diff --git a/compiler/testData/codegen/box/callableReference/function/privateClassMember.kt b/compiler/testData/codegen/box/callableReference/function/privateClassMember.kt index f99ac7e3ad6..6efed35c30f 100644 --- a/compiler/testData/codegen/box/callableReference/function/privateClassMember.kt +++ b/compiler/testData/codegen/box/callableReference/function/privateClassMember.kt @@ -1,7 +1,7 @@ class A { private fun foo() = "OK" - fun bar() = (A::foo)(this) + fun bar() = (A::foo).let { it(this) } } fun box() = A().bar() diff --git a/compiler/testData/codegen/box/callableReference/function/topLevelFromClass.kt b/compiler/testData/codegen/box/callableReference/function/topLevelFromClass.kt index 48f8b3698e6..99d27df0fe6 100644 --- a/compiler/testData/codegen/box/callableReference/function/topLevelFromClass.kt +++ b/compiler/testData/codegen/box/callableReference/function/topLevelFromClass.kt @@ -5,7 +5,7 @@ fun run(arg1: T, arg2: T, funRef:(T,T) -> T): T { fun foo(o: Int, k: Int) = o + k class A { - fun bar() = (::foo)(111, 222) + fun bar() = (::foo).let { it(111, 222) } } fun box(): String { diff --git a/compiler/testData/codegen/box/callableReference/function/topLevelFromExtension.kt b/compiler/testData/codegen/box/callableReference/function/topLevelFromExtension.kt index cd8cf660a11..977cace7c59 100644 --- a/compiler/testData/codegen/box/callableReference/function/topLevelFromExtension.kt +++ b/compiler/testData/codegen/box/callableReference/function/topLevelFromExtension.kt @@ -6,7 +6,7 @@ fun foo(o: Int, k: Int) = o + k class A -fun A.bar() = (::foo)(111, 222) +fun A.bar() = (::foo).let { it(111, 222) } fun box(): String { val result = A().bar() diff --git a/compiler/testData/codegen/box/callableReference/function/traitImplMethodWithClassReceiver.kt b/compiler/testData/codegen/box/callableReference/function/traitImplMethodWithClassReceiver.kt index 9171f0b094b..327fe74d811 100644 --- a/compiler/testData/codegen/box/callableReference/function/traitImplMethodWithClassReceiver.kt +++ b/compiler/testData/codegen/box/callableReference/function/traitImplMethodWithClassReceiver.kt @@ -4,7 +4,7 @@ interface T { class B : T { inner class C { - fun bar() = (T::foo)(this@B) + fun bar() = (T::foo).let { it(this@B) } } } diff --git a/compiler/testData/codegen/box/callableReference/function/traitMember.kt b/compiler/testData/codegen/box/callableReference/function/traitMember.kt index 88cf738eaa7..c089e5ad416 100644 --- a/compiler/testData/codegen/box/callableReference/function/traitMember.kt +++ b/compiler/testData/codegen/box/callableReference/function/traitMember.kt @@ -6,4 +6,4 @@ class B : A { override fun foo() = "OK" } -fun box() = (A::foo)(B()) +fun box() = (A::foo).let { it(B()) } diff --git a/compiler/testData/codegen/box/callableReference/staticMethod.kt b/compiler/testData/codegen/box/callableReference/staticMethod.kt index b636c3bfe8e..982d4393641 100644 --- a/compiler/testData/codegen/box/callableReference/staticMethod.kt +++ b/compiler/testData/codegen/box/callableReference/staticMethod.kt @@ -13,6 +13,6 @@ class A { fun box(): String { val args = arrayOf("Fail") - (A::main)(args) + (A::main).let { it(args) } return args[0] } diff --git a/compiler/testData/codegen/box/classes/privateOuterFunctions.kt b/compiler/testData/codegen/box/classes/privateOuterFunctions.kt index ceeb4ff69ce..f76e898c720 100644 --- a/compiler/testData/codegen/box/classes/privateOuterFunctions.kt +++ b/compiler/testData/codegen/box/classes/privateOuterFunctions.kt @@ -6,7 +6,7 @@ class C { { "".ext() f() - }.invoke() + }.let { it.invoke() } object : Runnable { public override fun run() { diff --git a/compiler/testData/codegen/box/classes/privateOuterProperty.kt b/compiler/testData/codegen/box/classes/privateOuterProperty.kt index 0f0bc3e452f..0009bfea2a1 100644 --- a/compiler/testData/codegen/box/classes/privateOuterProperty.kt +++ b/compiler/testData/codegen/box/classes/privateOuterProperty.kt @@ -4,7 +4,7 @@ class C{ public fun foo() : Int { { v = v + 1 - }.invoke() + }.let { it.invoke() } object : Runnable { public override fun run() { diff --git a/compiler/testData/codegen/box/closures/kt4137.kt b/compiler/testData/codegen/box/closures/kt4137.kt index ea401a6fe80..adc47c875a8 100644 --- a/compiler/testData/codegen/box/closures/kt4137.kt +++ b/compiler/testData/codegen/box/closures/kt4137.kt @@ -6,7 +6,7 @@ infix fun Int.foo(s: Int): Int { return this + s } -open class B : A({ 1 foo 2} ()) +open class B : A({ 1 foo 2 }.let { it() }) fun box(): String { return if (B().s == 3) "OK" else "Fail" diff --git a/compiler/testData/codegen/box/closures/localFunInInit.kt b/compiler/testData/codegen/box/closures/localFunInInit.kt index 12ef89bf126..3b667866e22 100644 --- a/compiler/testData/codegen/box/closures/localFunInInit.kt +++ b/compiler/testData/codegen/box/closures/localFunInInit.kt @@ -3,7 +3,7 @@ class A { init { val flag = "OK" fun getFlag(): String = flag - result = { getFlag() } () + result = { getFlag() }.let { it() } } } fun box(): String = A().result diff --git a/compiler/testData/codegen/box/controlStructures/kt2597.kt b/compiler/testData/codegen/box/controlStructures/kt2597.kt index af5af144a86..fa027b9d0cf 100644 --- a/compiler/testData/codegen/box/controlStructures/kt2597.kt +++ b/compiler/testData/codegen/box/controlStructures/kt2597.kt @@ -5,6 +5,6 @@ fun box(): String { i++ } else { } - }() + }.let { it() } return "OK" } diff --git a/compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bound/emptyLHS.kt b/compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bound/emptyLHS.kt index 6d47297d7a2..4d6a8640e7c 100644 --- a/compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bound/emptyLHS.kt +++ b/compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bound/emptyLHS.kt @@ -16,8 +16,8 @@ class A { } suspend fun test(): String { - (::memberFunction)() - (::aExtensionFunction)() + (::memberFunction).let { it() } + (::aExtensionFunction).let { it() } return result } @@ -28,12 +28,12 @@ class A { } suspend fun test(): String { - (::aMemberFunction)() - (::aExtensionFunction)() + (::aMemberFunction).let { it() } + (::aExtensionFunction).let { it() } - (::memberFunction)() + (::memberFunction).let { it() } - (::bExtensionFunction)() + (::bExtensionFunction).let { it() } return result } @@ -69,8 +69,8 @@ fun box(): String { result = "" builder { with(A()) { - (::memberFunction)() - (::aExtensionFunction)() + (::memberFunction).let { it() } + (::aExtensionFunction).let { it() } } } if (result != "A.mf,A.ef,") return "Fail $result" @@ -79,12 +79,12 @@ fun box(): String { builder { with(A()) { with(B()) { - (::aMemberFunction)() - (::aExtensionFunction)() + (::aMemberFunction).let { it() } + (::aExtensionFunction).let { it() } - (::memberFunction)() + (::memberFunction).let { it() } - (::bExtensionFunction)() + (::bExtensionFunction).let { it() } } } } diff --git a/compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/lambdaParameterUsed.kt b/compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/lambdaParameterUsed.kt index 62e18992587..82f0c24985b 100644 --- a/compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/lambdaParameterUsed.kt +++ b/compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/lambdaParameterUsed.kt @@ -2,7 +2,7 @@ import kotlin.coroutines.* -fun box(): String = a { (::write)() } +fun box(): String = a { (::write).let { it() } } fun builder(c: suspend () -> Unit) { c.startCoroutine(Continuation(EmptyCoroutineContext) { diff --git a/compiler/testData/codegen/box/coroutines/localFunctions/named/rec.kt b/compiler/testData/codegen/box/coroutines/localFunctions/named/rec.kt index 13c2535fb0d..16438d8e16d 100644 --- a/compiler/testData/codegen/box/coroutines/localFunctions/named/rec.kt +++ b/compiler/testData/codegen/box/coroutines/localFunctions/named/rec.kt @@ -44,7 +44,7 @@ suspend fun fooCallableReference(until: Int): String { val k = "K" val dot = "." suspend fun bar(x: Int): String = - if (x == until) dot else if (x < until) o + (::bar)(x * 2) else k + (::bar)(x - 1) + if (x == until) dot else if (x < until) o + (::bar).let { it(x * 2) } else k + (::bar).let { it(x - 1) } return bar(1) } @@ -53,8 +53,8 @@ suspend fun fooCallableReferenceIndirectRecursion(until: Int): String { val k = "K" val dot = "." suspend fun bar(x: Int): String { - suspend fun innerO() = o + (::bar)(x * 2) - suspend fun innerK() = k + (::bar)(x - 1) + suspend fun innerO() = o + (::bar).let { it(x * 2) } + suspend fun innerK() = k + (::bar).let { it(x - 1) } return if (x == until) dot else if (x < until) innerO() else innerK() } return bar(1) diff --git a/compiler/testData/codegen/box/coroutines/simpleSuspendCallableReference.kt b/compiler/testData/codegen/box/coroutines/simpleSuspendCallableReference.kt index 60b6ae846cd..86855762575 100644 --- a/compiler/testData/codegen/box/coroutines/simpleSuspendCallableReference.kt +++ b/compiler/testData/codegen/box/coroutines/simpleSuspendCallableReference.kt @@ -29,7 +29,7 @@ inline suspend fun K(block: suspend (String) -> String) = block("K") suspend fun ok(o: String): String { return o + run { if (o != "K") { - (::ok)("K") + (::ok).let { it("K") } } else "" } } diff --git a/compiler/testData/codegen/box/defaultArguments/protected.kt b/compiler/testData/codegen/box/defaultArguments/protected.kt index be1243f96c6..721d8f52d56 100644 --- a/compiler/testData/codegen/box/defaultArguments/protected.kt +++ b/compiler/testData/codegen/box/defaultArguments/protected.kt @@ -14,7 +14,7 @@ import foo.Foo class Bar() : Foo() { fun execute(): String { - return { foo() } () + return { foo() }.let { it() } } } diff --git a/compiler/testData/codegen/box/delegatedProperty/local/kt16864.kt b/compiler/testData/codegen/box/delegatedProperty/local/kt16864.kt index f5dedb6d76b..03dac92af12 100644 --- a/compiler/testData/codegen/box/delegatedProperty/local/kt16864.kt +++ b/compiler/testData/codegen/box/delegatedProperty/local/kt16864.kt @@ -8,5 +8,5 @@ fun box(): String { object { val keys = key }.keys - } () + }.let { it() } } \ No newline at end of file diff --git a/compiler/testData/codegen/box/directInvokeOptimization/boundInnerContructorRef.kt b/compiler/testData/codegen/box/directInvokeOptimization/boundInnerContructorRef.kt index de6c7f4db9d..1cf63bf904b 100644 --- a/compiler/testData/codegen/box/directInvokeOptimization/boundInnerContructorRef.kt +++ b/compiler/testData/codegen/box/directInvokeOptimization/boundInnerContructorRef.kt @@ -1,6 +1,6 @@ // CHECK_BYTECODE_TEXT // JVM_IR_TEMPLATES -// 0 Function(^.)*.invoke +// 0 invoke class Outer (val x: String) { inner class Inner(val y: String) { diff --git a/compiler/testData/codegen/box/directInvokeOptimization/boundMemberRef.kt b/compiler/testData/codegen/box/directInvokeOptimization/boundMemberRef.kt index 0c0ffe939a6..d59d2a44317 100644 --- a/compiler/testData/codegen/box/directInvokeOptimization/boundMemberRef.kt +++ b/compiler/testData/codegen/box/directInvokeOptimization/boundMemberRef.kt @@ -1,6 +1,6 @@ // CHECK_BYTECODE_TEXT // JVM_IR_TEMPLATES -// 0 Function(^.)*.invoke +// 0 invoke class C(val x: String) { fun foo(s: String) = x + s diff --git a/compiler/testData/codegen/box/directInvokeOptimization/contructorRef.kt b/compiler/testData/codegen/box/directInvokeOptimization/contructorRef.kt index 8cba2f2fc05..cff0a3852a3 100644 --- a/compiler/testData/codegen/box/directInvokeOptimization/contructorRef.kt +++ b/compiler/testData/codegen/box/directInvokeOptimization/contructorRef.kt @@ -1,6 +1,6 @@ // CHECK_BYTECODE_TEXT // JVM_IR_TEMPLATES -// 0 Function(^.)*.invoke +// 0 invoke class C(x: String, y: String) { val yx = y + x diff --git a/compiler/testData/codegen/box/directInvokeOptimization/nestedLambdas.kt b/compiler/testData/codegen/box/directInvokeOptimization/nestedLambdas.kt index b5d3c0e510b..7bfa7b10542 100644 --- a/compiler/testData/codegen/box/directInvokeOptimization/nestedLambdas.kt +++ b/compiler/testData/codegen/box/directInvokeOptimization/nestedLambdas.kt @@ -1,6 +1,6 @@ // CHECK_BYTECODE_TEXT // JVM_IR_TEMPLATES -// 0 Function(^.)*.invoke +// 0 invoke fun box() = { k: String -> diff --git a/compiler/testData/codegen/box/directInvokeOptimization/simpleAnonymousFun.kt b/compiler/testData/codegen/box/directInvokeOptimization/simpleAnonymousFun.kt index d848a3f1acb..0982e33426b 100644 --- a/compiler/testData/codegen/box/directInvokeOptimization/simpleAnonymousFun.kt +++ b/compiler/testData/codegen/box/directInvokeOptimization/simpleAnonymousFun.kt @@ -1,6 +1,6 @@ // CHECK_BYTECODE_TEXT // JVM_IR_TEMPLATES -// 0 Function(^.)*.invoke +// 0 invoke fun box() = (fun (s: String): String { diff --git a/compiler/testData/codegen/box/directInvokeOptimization/simpleFunRef.kt b/compiler/testData/codegen/box/directInvokeOptimization/simpleFunRef.kt index 5e93e88af0e..7676778f7ac 100644 --- a/compiler/testData/codegen/box/directInvokeOptimization/simpleFunRef.kt +++ b/compiler/testData/codegen/box/directInvokeOptimization/simpleFunRef.kt @@ -1,6 +1,6 @@ // CHECK_BYTECODE_TEXT // JVM_IR_TEMPLATES -// 0 Function(^.)*.invoke +// 0 invoke fun ok(s: String) = "O" + s diff --git a/compiler/testData/codegen/box/directInvokeOptimization/simpleLambda.kt b/compiler/testData/codegen/box/directInvokeOptimization/simpleLambda.kt index acd0bd104b0..d91b30fb75d 100644 --- a/compiler/testData/codegen/box/directInvokeOptimization/simpleLambda.kt +++ b/compiler/testData/codegen/box/directInvokeOptimization/simpleLambda.kt @@ -1,6 +1,6 @@ // CHECK_BYTECODE_TEXT // JVM_IR_TEMPLATES -// 0 Function(^.)*.invoke +// 0 invoke fun box() = { s: String -> diff --git a/compiler/testData/codegen/box/directInvokeOptimization/unboundInnerContructorRef.kt b/compiler/testData/codegen/box/directInvokeOptimization/unboundInnerContructorRef.kt index 91e3013d38d..dd25b177788 100644 --- a/compiler/testData/codegen/box/directInvokeOptimization/unboundInnerContructorRef.kt +++ b/compiler/testData/codegen/box/directInvokeOptimization/unboundInnerContructorRef.kt @@ -1,6 +1,6 @@ // CHECK_BYTECODE_TEXT // JVM_IR_TEMPLATES -// 0 Function(^.)*.invoke +// 0 invoke class Outer (val x: String) { inner class Inner(val y: String) { diff --git a/compiler/testData/codegen/box/directInvokeOptimization/unboundMemberRef.kt b/compiler/testData/codegen/box/directInvokeOptimization/unboundMemberRef.kt index ac729cf310c..5aa5b18cabe 100644 --- a/compiler/testData/codegen/box/directInvokeOptimization/unboundMemberRef.kt +++ b/compiler/testData/codegen/box/directInvokeOptimization/unboundMemberRef.kt @@ -1,2 +1,6 @@ +// CHECK_BYTECODE_TEXT +// JVM_IR_TEMPLATES +// 0 invoke + fun box(): String = (String::plus)("O", "K") diff --git a/compiler/testData/codegen/box/extensionFunctions/kt3298.kt b/compiler/testData/codegen/box/extensionFunctions/kt3298.kt index d0f83531a69..7dd7b31853b 100644 --- a/compiler/testData/codegen/box/extensionFunctions/kt3298.kt +++ b/compiler/testData/codegen/box/extensionFunctions/kt3298.kt @@ -4,7 +4,7 @@ fun result(r: String) { result = r } object Foo { private operator fun String.unaryPlus() = "(" + this + ")" - fun foo() = { result(+"Stuff") }() + fun foo() = { result(+"Stuff") }.let { it() } } fun box(): String { diff --git a/compiler/testData/codegen/box/functions/invoke/extensionInvokeOnExpr.kt b/compiler/testData/codegen/box/functions/invoke/extensionInvokeOnExpr.kt index 35496700fd7..861c80730da 100644 --- a/compiler/testData/codegen/box/functions/invoke/extensionInvokeOnExpr.kt +++ b/compiler/testData/codegen/box/functions/invoke/extensionInvokeOnExpr.kt @@ -13,8 +13,8 @@ fun B.test(): String { if (foo()() != "##") return "fail3" if (foo()(42) != "#42") return "fail4" if ((foo())(42) != "#42") return "fail5" - if ({ -> A()}()() != "##") return "fail6" - if ({ -> A()}()(37) != "#37") return "fail7" + if ({ -> A()}.let { it() }() != "##") return "fail6" + if ({ -> A()}.let { it() }(37) != "#37") return "fail7" return "OK" } diff --git a/compiler/testData/codegen/box/functions/invoke/invokeOnExprByConvention.kt b/compiler/testData/codegen/box/functions/invoke/invokeOnExprByConvention.kt index 16e174b8db5..d8e11dcedb9 100644 --- a/compiler/testData/codegen/box/functions/invoke/invokeOnExprByConvention.kt +++ b/compiler/testData/codegen/box/functions/invoke/invokeOnExprByConvention.kt @@ -14,7 +14,7 @@ fun box(): String { if (foo()() != "##") return "fail3" if (foo()(42) != "#42") return "fail4" if ((foo())(42) != "#42") return "fail5" - if ({ -> A()}()() != "##") return "fail6" - if ({ -> A()}()(37) != "#37") return "fail7" + if ({ -> A()}.let { it() }() != "##") return "fail6" + if ({ -> A()}.let { it() }(37) != "#37") return "fail7" return "OK" } \ No newline at end of file diff --git a/compiler/testData/codegen/box/functions/kt2481.kt b/compiler/testData/codegen/box/functions/kt2481.kt index ea353c41cb1..19fb2b02744 100644 --- a/compiler/testData/codegen/box/functions/kt2481.kt +++ b/compiler/testData/codegen/box/functions/kt2481.kt @@ -9,6 +9,6 @@ public class B(): A(){ public override fun method() : String { return ({ super.method() - })() + }).let { it() } } } diff --git a/compiler/testData/codegen/box/functions/localFunctions/kt2895.kt b/compiler/testData/codegen/box/functions/localFunctions/kt2895.kt index 76db2bdc71e..e8d1563105e 100644 --- a/compiler/testData/codegen/box/functions/localFunctions/kt2895.kt +++ b/compiler/testData/codegen/box/functions/localFunctions/kt2895.kt @@ -3,7 +3,7 @@ fun outer() { if (i > 0){ { it: Int -> inner(0) // <- invocation of literal itself is generated instead - }.invoke(1) + }.let { it.invoke(1) } } } inner(1) diff --git a/compiler/testData/codegen/box/functions/localFunctions/overloadedLocalFunction3.kt b/compiler/testData/codegen/box/functions/localFunctions/overloadedLocalFunction3.kt index 9504e6ebfac..d8180a60865 100644 --- a/compiler/testData/codegen/box/functions/localFunctions/overloadedLocalFunction3.kt +++ b/compiler/testData/codegen/box/functions/localFunctions/overloadedLocalFunction3.kt @@ -14,7 +14,7 @@ fun box(): String { { foo(foo, 1) foo("K") - } () + }.let { it() } } return s diff --git a/compiler/testData/codegen/box/inlineClasses/callableReferences/boundInlineClassExtensionFun.kt b/compiler/testData/codegen/box/inlineClasses/callableReferences/boundInlineClassExtensionFun.kt index 36e6ef58a2f..480d35c38e5 100644 --- a/compiler/testData/codegen/box/inlineClasses/callableReferences/boundInlineClassExtensionFun.kt +++ b/compiler/testData/codegen/box/inlineClasses/callableReferences/boundInlineClassExtensionFun.kt @@ -16,9 +16,9 @@ fun L.test() = x fun S.test() = x fun box(): String { - if (Z(42)::test.invoke() != 42) throw AssertionError() - if (L(1234L)::test.invoke() != 1234L) throw AssertionError() - if (S("abcdef")::test.invoke() != "abcdef") throw AssertionError() + if (Z(42)::test.let { it.invoke() } != 42) throw AssertionError() + if (L(1234L)::test.let { it.invoke() } != 1234L) throw AssertionError() + if (S("abcdef")::test.let { it.invoke() } != "abcdef") throw AssertionError() return "OK" } \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/callableReferences/boundInlineClassExtensionFunGeneric.kt b/compiler/testData/codegen/box/inlineClasses/callableReferences/boundInlineClassExtensionFunGeneric.kt index de299c08caa..9bf0baecfbf 100644 --- a/compiler/testData/codegen/box/inlineClasses/callableReferences/boundInlineClassExtensionFunGeneric.kt +++ b/compiler/testData/codegen/box/inlineClasses/callableReferences/boundInlineClassExtensionFunGeneric.kt @@ -16,9 +16,9 @@ fun L.test() = x fun S.test() = x fun box(): String { - if (Z(42)::test.invoke() != 42) throw AssertionError() - if (L(1234L)::test.invoke() != 1234L) throw AssertionError() - if (S("abcdef")::test.invoke() != "abcdef") throw AssertionError() + if (Z(42)::test.let { it.invoke() } != 42) throw AssertionError() + if (L(1234L)::test.let { it.invoke() } != 1234L) throw AssertionError() + if (S("abcdef")::test.let { it.invoke() } != "abcdef") throw AssertionError() return "OK" } \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/callableReferences/boundInlineClassMemberFun.kt b/compiler/testData/codegen/box/inlineClasses/callableReferences/boundInlineClassMemberFun.kt index eadedfa3a2e..89df646d681 100644 --- a/compiler/testData/codegen/box/inlineClasses/callableReferences/boundInlineClassMemberFun.kt +++ b/compiler/testData/codegen/box/inlineClasses/callableReferences/boundInlineClassMemberFun.kt @@ -18,9 +18,9 @@ value class S(val x: String) { } fun box(): String { - if (Z(42)::test.invoke() != 42) throw AssertionError() - if (L(1234L)::test.invoke() != 1234L) throw AssertionError() - if (S("abcdef")::test.invoke() != "abcdef") throw AssertionError() + if (Z(42)::test.let { it.invoke() } != 42) throw AssertionError() + if (L(1234L)::test.let { it.invoke() } != 1234L) throw AssertionError() + if (S("abcdef")::test.let { it.invoke() } != "abcdef") throw AssertionError() return "OK" } \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/callableReferences/boundInlineClassMemberFunGeneric.kt b/compiler/testData/codegen/box/inlineClasses/callableReferences/boundInlineClassMemberFunGeneric.kt index ce3ef300e2d..78bcc21da25 100644 --- a/compiler/testData/codegen/box/inlineClasses/callableReferences/boundInlineClassMemberFunGeneric.kt +++ b/compiler/testData/codegen/box/inlineClasses/callableReferences/boundInlineClassMemberFunGeneric.kt @@ -18,9 +18,9 @@ value class S(val x: T) { } fun box(): String { - if (Z(42)::test.invoke() != 42) throw AssertionError() - if (L(1234L)::test.invoke() != 1234L) throw AssertionError() - if (S("abcdef")::test.invoke() != "abcdef") throw AssertionError() + if (Z(42)::test.let { it.invoke() } != 42) throw AssertionError() + if (L(1234L)::test.let { it.invoke() } != 1234L) throw AssertionError() + if (S("abcdef")::test.let { it.invoke() } != "abcdef") throw AssertionError() return "OK" } \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/callableReferences/constructorWithInlineClassParameters.kt b/compiler/testData/codegen/box/inlineClasses/callableReferences/constructorWithInlineClassParameters.kt index 8da9d5d1fbf..93914908549 100644 --- a/compiler/testData/codegen/box/inlineClasses/callableReferences/constructorWithInlineClassParameters.kt +++ b/compiler/testData/codegen/box/inlineClasses/callableReferences/constructorWithInlineClassParameters.kt @@ -12,8 +12,8 @@ class Outer(val z1: Z) { } fun box(): String { - assertEquals(Z(1), ::Outer.invoke(Z(1)).z1) - assertEquals(Z(2), Outer::Inner.invoke(Outer(Z(1)), Z(2)).z2) + assertEquals(Z(1), ::Outer.let { it.invoke(Z(1)) }.z1) + assertEquals(Z(2), Outer::Inner.let { it.invoke(Outer(Z(1)), Z(2)) }.z2) return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/inlineClasses/callableReferences/constructorWithInlineClassParametersGeneric.kt b/compiler/testData/codegen/box/inlineClasses/callableReferences/constructorWithInlineClassParametersGeneric.kt index 5cdd83fcbe7..ccf6541cc9e 100644 --- a/compiler/testData/codegen/box/inlineClasses/callableReferences/constructorWithInlineClassParametersGeneric.kt +++ b/compiler/testData/codegen/box/inlineClasses/callableReferences/constructorWithInlineClassParametersGeneric.kt @@ -12,8 +12,8 @@ class Outer(val z1: Z) { } fun box(): String { - assertEquals(Z(1), ::Outer.invoke(Z(1)).z1) - assertEquals(Z(2), Outer::Inner.invoke(Outer(Z(1)), Z(2)).z2) + assertEquals(Z(1), ::Outer.let { it.invoke(Z(1)) }.z1) + assertEquals(Z(2), Outer::Inner.let { it.invoke(Outer(Z(1)), Z(2)) }.z2) return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/inlineClasses/callableReferences/funWithInlineClassParameters.kt b/compiler/testData/codegen/box/inlineClasses/callableReferences/funWithInlineClassParameters.kt index 4731e6bd961..10535b95bc8 100644 --- a/compiler/testData/codegen/box/inlineClasses/callableReferences/funWithInlineClassParameters.kt +++ b/compiler/testData/codegen/box/inlineClasses/callableReferences/funWithInlineClassParameters.kt @@ -14,7 +14,7 @@ value class S(val x: String) fun test(aZ: Z, aL: L, aS: S) = "${aZ.x} ${aL.x} ${aS.x}" fun box(): String { - if (::test.invoke(Z(1), L(1L), S("abc")) != "1 1 abc") throw AssertionError() + if (::test.let { it.invoke(Z(1), L(1L), S("abc")) } != "1 1 abc") throw AssertionError() return "OK" } \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/callableReferences/funWithInlineClassParametersGeneric.kt b/compiler/testData/codegen/box/inlineClasses/callableReferences/funWithInlineClassParametersGeneric.kt index dde79693d1d..be8f1ed5030 100644 --- a/compiler/testData/codegen/box/inlineClasses/callableReferences/funWithInlineClassParametersGeneric.kt +++ b/compiler/testData/codegen/box/inlineClasses/callableReferences/funWithInlineClassParametersGeneric.kt @@ -14,7 +14,7 @@ value class S(val x: T) fun test(aZ: Z, aL: L, aS: S) = "${aZ.x} ${aL.x} ${aS.x}" fun box(): String { - if (::test.invoke(Z(1), L(1L), S("abc")) != "1 1 abc") throw AssertionError() + if (::test.let { it.invoke(Z(1), L(1L), S("abc")) } != "1 1 abc") throw AssertionError() return "OK" } \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/callableReferences/inlineClassExtensionFun.kt b/compiler/testData/codegen/box/inlineClasses/callableReferences/inlineClassExtensionFun.kt index 92fbd02a13c..6b2fcb39d4a 100644 --- a/compiler/testData/codegen/box/inlineClasses/callableReferences/inlineClassExtensionFun.kt +++ b/compiler/testData/codegen/box/inlineClasses/callableReferences/inlineClassExtensionFun.kt @@ -16,9 +16,9 @@ fun L.test() = x fun S.test() = x fun box(): String { - if (Z::test.invoke(Z(42)) != 42) throw AssertionError() - if (L::test.invoke(L(1234L)) != 1234L) throw AssertionError() - if (S::test.invoke(S("abcdef")) != "abcdef") throw AssertionError() + if (Z::test.let { it.invoke(Z(42)) } != 42) throw AssertionError() + if (L::test.let { it.invoke(L(1234L)) } != 1234L) throw AssertionError() + if (S::test.let { it.invoke(S("abcdef")) } != "abcdef") throw AssertionError() return "OK" } \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/callableReferences/inlineClassExtensionFunGeneric.kt b/compiler/testData/codegen/box/inlineClasses/callableReferences/inlineClassExtensionFunGeneric.kt index 4c4420a25ad..8657815ddb3 100644 --- a/compiler/testData/codegen/box/inlineClasses/callableReferences/inlineClassExtensionFunGeneric.kt +++ b/compiler/testData/codegen/box/inlineClasses/callableReferences/inlineClassExtensionFunGeneric.kt @@ -16,9 +16,9 @@ fun L.test() = x fun S.test() = x fun box(): String { - if (Z::test.invoke(Z(42)) != 42) throw AssertionError() - if (L::test.invoke(L(1234L)) != 1234L) throw AssertionError() - if (S::test.invoke(S("abcdef")) != "abcdef") throw AssertionError() + if (Z::test.let { it.invoke(Z(42)) } != 42) throw AssertionError() + if (L::test.let { it.invoke(L(1234L)) } != 1234L) throw AssertionError() + if (S::test.let { it.invoke(S("abcdef")) } != "abcdef") throw AssertionError() return "OK" } \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/callableReferences/inlineClassMemberFun.kt b/compiler/testData/codegen/box/inlineClasses/callableReferences/inlineClassMemberFun.kt index 99dc53642de..6906f0174d4 100644 --- a/compiler/testData/codegen/box/inlineClasses/callableReferences/inlineClassMemberFun.kt +++ b/compiler/testData/codegen/box/inlineClasses/callableReferences/inlineClassMemberFun.kt @@ -18,9 +18,9 @@ value class S(val x: String) { } fun box(): String { - if (Z::test.invoke(Z(42)) != 42) throw AssertionError() - if (L::test.invoke(L(1234L)) != 1234L) throw AssertionError() - if (S::test.invoke(S("abcdef")) != "abcdef") throw AssertionError() + if (Z::test.let { it.invoke(Z(42)) } != 42) throw AssertionError() + if (L::test.let { it.invoke(L(1234L)) } != 1234L) throw AssertionError() + if (S::test.let { it.invoke(S("abcdef")) } != "abcdef") throw AssertionError() return "OK" } \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/callableReferences/inlineClassMemberFunGeneric.kt b/compiler/testData/codegen/box/inlineClasses/callableReferences/inlineClassMemberFunGeneric.kt index b74f97f3adf..6d7926f46e1 100644 --- a/compiler/testData/codegen/box/inlineClasses/callableReferences/inlineClassMemberFunGeneric.kt +++ b/compiler/testData/codegen/box/inlineClasses/callableReferences/inlineClassMemberFunGeneric.kt @@ -18,9 +18,9 @@ value class S(val x: T) { } fun box(): String { - if (Z::test.invoke(Z(42)) != 42) throw AssertionError() - if (L::test.invoke(L(1234L)) != 1234L) throw AssertionError() - if (S::test.invoke(S("abcdef")) != "abcdef") throw AssertionError() + if (Z::test.let { it.invoke(Z(42)) } != 42) throw AssertionError() + if (L::test.let { it.invoke(L(1234L)) } != 1234L) throw AssertionError() + if (S::test.let { it.invoke(S("abcdef")) } != "abcdef") throw AssertionError() return "OK" } \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/callableReferencesWithInlineClasses.kt b/compiler/testData/codegen/box/inlineClasses/callableReferencesWithInlineClasses.kt index 08e0058c5af..27acd52d336 100644 --- a/compiler/testData/codegen/box/inlineClasses/callableReferencesWithInlineClasses.kt +++ b/compiler/testData/codegen/box/inlineClasses/callableReferencesWithInlineClasses.kt @@ -14,7 +14,7 @@ fun box(): String { val result1 = function1.invoke(Foo("+argument+"), 42) if (result1.x != "original+argument+42") return "Fail first" - val result2 = Foo::bar.invoke(Foo("explicit"), Foo("+argument2+"), 10) + val result2 = Foo::bar.let { it.invoke(Foo("explicit"), Foo("+argument2+"), 10) } if (result2.x != "explicit+argument2+10") return "Fail second" return "OK" diff --git a/compiler/testData/codegen/box/inlineClasses/callableReferencesWithInlineClassesGeneric.kt b/compiler/testData/codegen/box/inlineClasses/callableReferencesWithInlineClassesGeneric.kt index 7322d033b4c..8f3cc20e4ed 100644 --- a/compiler/testData/codegen/box/inlineClasses/callableReferencesWithInlineClassesGeneric.kt +++ b/compiler/testData/codegen/box/inlineClasses/callableReferencesWithInlineClassesGeneric.kt @@ -14,7 +14,7 @@ fun box(): String { val result1 = function1.invoke(Foo("+argument+"), 42) if (result1.x != "original+argument+42") return "Fail first" - val result2 = Foo::bar.invoke(Foo("explicit"), Foo("+argument2+"), 10) + val result2 = Foo::bar.let { it.invoke(Foo("explicit"), Foo("+argument2+"), 10) } if (result2.x != "explicit+argument2+10") return "Fail second" return "OK" diff --git a/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassMethodFromLambda2.kt b/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassMethodFromLambda2.kt index b4bd8ca428d..a1fa291a00b 100644 --- a/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassMethodFromLambda2.kt +++ b/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassMethodFromLambda2.kt @@ -4,7 +4,7 @@ OPTIONAL_JVM_INLINE_ANNOTATION value class R(private val r: Long) { - fun test() = { ok() }() + fun test() = { ok() }.let { it() } private fun ok() = "OK" } diff --git a/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassMethodFromLambda2Generic.kt b/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassMethodFromLambda2Generic.kt index cf6dac8100e..479e8399419 100644 --- a/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassMethodFromLambda2Generic.kt +++ b/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassMethodFromLambda2Generic.kt @@ -4,7 +4,7 @@ OPTIONAL_JVM_INLINE_ANNOTATION value class R(private val r: T) { - fun test() = { ok() }() + fun test() = { ok() }.let { it() } private fun ok() = "OK" } diff --git a/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/captureInlineClassInstanceInLambda.kt b/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/captureInlineClassInstanceInLambda.kt index ab82ccba613..e4852593a15 100644 --- a/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/captureInlineClassInstanceInLambda.kt +++ b/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/captureInlineClassInstanceInLambda.kt @@ -4,7 +4,7 @@ OPTIONAL_JVM_INLINE_ANNOTATION value class R(private val r: Int) { - fun test() = { ok() }() + fun test() = { ok() }.let { it() } fun ok() = "OK" } diff --git a/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/captureInlineClassInstanceInLambda2.kt b/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/captureInlineClassInstanceInLambda2.kt index 499786dd852..41c3aaa5e86 100644 --- a/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/captureInlineClassInstanceInLambda2.kt +++ b/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/captureInlineClassInstanceInLambda2.kt @@ -4,7 +4,7 @@ OPTIONAL_JVM_INLINE_ANNOTATION value class R(private val r: Long) { - fun test() = { ok() }() + fun test() = { ok() }.let { it() } fun ok() = "OK" } diff --git a/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/captureInlineClassInstanceInLambda2Generic.kt b/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/captureInlineClassInstanceInLambda2Generic.kt index ffe5ae9073e..36d9e042f3f 100644 --- a/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/captureInlineClassInstanceInLambda2Generic.kt +++ b/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/captureInlineClassInstanceInLambda2Generic.kt @@ -4,7 +4,7 @@ OPTIONAL_JVM_INLINE_ANNOTATION value class R(private val r: T) { - fun test() = { ok() }() + fun test() = { ok() }.let { it() } fun ok() = "OK" } diff --git a/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/captureInlineClassInstanceInLambdaGeneric.kt b/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/captureInlineClassInstanceInLambdaGeneric.kt index 13d19bc37d3..7d52a1ffd99 100644 --- a/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/captureInlineClassInstanceInLambdaGeneric.kt +++ b/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/captureInlineClassInstanceInLambdaGeneric.kt @@ -4,7 +4,7 @@ OPTIONAL_JVM_INLINE_ANNOTATION value class R(private val r: T) { - fun test() = { ok() }() + fun test() = { ok() }.let { it() } fun ok() = "OK" } diff --git a/compiler/testData/codegen/box/inlineClasses/propertyDelegation/captureLocalVarDelegatedToInlineClass.kt b/compiler/testData/codegen/box/inlineClasses/propertyDelegation/captureLocalVarDelegatedToInlineClass.kt index 6952e0139e8..f6cea786928 100644 --- a/compiler/testData/codegen/box/inlineClasses/propertyDelegation/captureLocalVarDelegatedToInlineClass.kt +++ b/compiler/testData/codegen/box/inlineClasses/propertyDelegation/captureLocalVarDelegatedToInlineClass.kt @@ -67,7 +67,7 @@ private fun testDelegateStr() { localD = 1234 if (localD != 1234) throw AssertionError() if (backing != 1234) throw AssertionError() - }() + }.let { it() } } private fun testDelegateInt() { @@ -79,7 +79,7 @@ private fun testDelegateInt() { localD = 1234 if (localD != 1234) throw AssertionError() if (backing != 1234) throw AssertionError() - }() + }.let { it() } } private fun testDelegateLong() { @@ -91,5 +91,5 @@ private fun testDelegateLong() { localD = 1234 if (localD != 1234) throw AssertionError() if (backing != 1234) throw AssertionError() - }() + }.let { it() } } \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/propertyDelegation/captureLocalVarDelegatedToInlineClassGeneric.kt b/compiler/testData/codegen/box/inlineClasses/propertyDelegation/captureLocalVarDelegatedToInlineClassGeneric.kt index 3c9e2879fa5..4686adfc6a2 100644 --- a/compiler/testData/codegen/box/inlineClasses/propertyDelegation/captureLocalVarDelegatedToInlineClassGeneric.kt +++ b/compiler/testData/codegen/box/inlineClasses/propertyDelegation/captureLocalVarDelegatedToInlineClassGeneric.kt @@ -67,7 +67,7 @@ private fun testDelegateStr() { localD = 1234 if (localD != 1234) throw AssertionError() if (backing != 1234) throw AssertionError() - }() + }.let { it() } } private fun testDelegateInt() { @@ -79,7 +79,7 @@ private fun testDelegateInt() { localD = 1234 if (localD != 1234) throw AssertionError() if (backing != 1234) throw AssertionError() - }() + }.let { it() } } private fun testDelegateLong() { @@ -91,5 +91,5 @@ private fun testDelegateLong() { localD = 1234 if (localD != 1234) throw AssertionError() if (backing != 1234) throw AssertionError() - }() + }.let { it() } } \ No newline at end of file diff --git a/compiler/testData/codegen/box/intrinsics/kt8666.kt b/compiler/testData/codegen/box/intrinsics/kt8666.kt index 6a29c3439a5..68a8bfed0db 100644 --- a/compiler/testData/codegen/box/intrinsics/kt8666.kt +++ b/compiler/testData/codegen/box/intrinsics/kt8666.kt @@ -18,16 +18,16 @@ fun box(): String { if (MAX_LONG != ("" as String?) + Long.MAX_VALUE) return "fail \"\"? +" if (MAX_LONG != "".plus(Long.MAX_VALUE)) return "fail \"\".plus" if (MAX_LONG != ("" as String?).plus(Long.MAX_VALUE)) return "fail \"\"?.plus" - if (MAX_LONG != (String::plus)("", Long.MAX_VALUE)) return "fail String::plus" + if (MAX_LONG != (String::plus).let { it("", Long.MAX_VALUE) }) return "fail String::plus" // if (MAX_LONG != stringPlus("", Long.MAX_VALUE)) return "fail stringPlus(\"\", Long.MAX_VALUE)" // if (MAX_LONG != customToString("", Long.MAX_VALUE, String::plus)) return "fail customToString(\"\", Long.MAX_VALUE, String::plus)" - if (MAX_LONG != (String?::plus)("", Long.MAX_VALUE)) return "fail String?::plus" + if (MAX_LONG != (String?::plus).let { it("", Long.MAX_VALUE) }) return "fail String?::plus" // if (MAX_LONG != stringNPlus("", Long.MAX_VALUE)) return "fail stringNPlus(\"\", Long.MAX_VALUE)" // if (MAX_LONG != customToString("", Long.MAX_VALUE, String?::plus)) return "fail customToString(\"\", Long.MAX_VALUE, String?::plus)" - if (MAX_LONG != (""::plus)(Long.MAX_VALUE)) return "fail \"\"::plus" + if (MAX_LONG != (""::plus).let { it(Long.MAX_VALUE) }) return "fail \"\"::plus" // if (MAX_LONG != emptyStringPlus(Long.MAX_VALUE)) return "fail emptyStringPlus(Long.MAX_VALUE)" // if (MAX_LONG != customToString(Long.MAX_VALUE, ""::plus)) return "fail customToString(Long.MAX_VALUE, \"\"::plus)" - if (MAX_LONG != (("" as String?)::plus)(Long.MAX_VALUE)) return "fail \"\"?::plus" + if (MAX_LONG != (("" as String?)::plus).let { it(Long.MAX_VALUE) }) return "fail \"\"?::plus" // if (MAX_LONG != emptyStringNPlus(Long.MAX_VALUE)) return "fail emptyStringPlus(Long.MAX_VALUE)" // if (MAX_LONG != customToString(Long.MAX_VALUE, ("" as String?)::plus)) return "fail customToString(Long.MAX_VALUE, (\"\" as String?)::plus)" @@ -36,16 +36,16 @@ fun box(): String { if (PREFIX + MAX_LONG != (PREFIX as String?) + Long.MAX_VALUE) return "fail \"$PREFIX\"? +" if (PREFIX + MAX_LONG != PREFIX.plus(Long.MAX_VALUE)) return "fail \"$PREFIX\".plus" if (PREFIX + MAX_LONG != (PREFIX as String?).plus(Long.MAX_VALUE)) return "fail \"$PREFIX\"?.plus" - if (PREFIX + MAX_LONG != (String::plus)(PREFIX, Long.MAX_VALUE)) return "fail String::plus(\"$PREFIX\", ...)" + if (PREFIX + MAX_LONG != (String::plus).let { it(PREFIX, Long.MAX_VALUE) }) return "fail String::plus(\"$PREFIX\", ...)" // if (PREFIX + MAX_LONG != stringPlus(PREFIX, Long.MAX_VALUE)) return "fail stringPlus(\"$PREFIX\", Long.MAX_VALUE)" // if (PREFIX + MAX_LONG != customToString(PREFIX, Long.MAX_VALUE, String::plus)) return "fail customToString(\"$PREFIX\", Long.MAX_VALUE, String::plus)" - if (PREFIX + MAX_LONG != (String?::plus)(PREFIX, Long.MAX_VALUE)) return "fail String?::plus(\"$PREFIX\", ...)" + if (PREFIX + MAX_LONG != (String?::plus).let { it(PREFIX, Long.MAX_VALUE) }) return "fail String?::plus(\"$PREFIX\", ...)" // if (PREFIX + MAX_LONG != stringNPlus(PREFIX, Long.MAX_VALUE)) return "fail stringNPlus(\"$PREFIX\", Long.MAX_VALUE)" // if (PREFIX + MAX_LONG != customToString(PREFIX, Long.MAX_VALUE, String?::plus)) return "fail customToString(\"$PREFIX\", Long.MAX_VALUE, String?::plus)" - if (PREFIX + MAX_LONG != (PREFIX::plus)(Long.MAX_VALUE)) return "fail \"$PREFIX\"::plus" + if (PREFIX + MAX_LONG != (PREFIX::plus).let { it(Long.MAX_VALUE) }) return "fail \"$PREFIX\"::plus" // if (PREFIX + MAX_LONG != prefixPlus(Long.MAX_VALUE)) return "fail prefixPlus(Long.MAX_VALUE)" // if (PREFIX + MAX_LONG != customToString(Long.MAX_VALUE, PREFIX::plus)) return "fail customToString(Long.MAX_VALUE, \"$PREFIX\"::plus)" - if (PREFIX + MAX_LONG != ((PREFIX as String?)::plus)(Long.MAX_VALUE)) return "fail \"$PREFIX\"?::plus" + if (PREFIX + MAX_LONG != ((PREFIX as String?)::plus).let { it(Long.MAX_VALUE) }) return "fail \"$PREFIX\"?::plus" // if (PREFIX + MAX_LONG != prefixNPlus(Long.MAX_VALUE)) return "fail prefixNPlus(Long.MAX_VALUE)" // if (PREFIX + MAX_LONG != customToString(Long.MAX_VALUE, (PREFIX as String?)::plus)) return "fail customToString(Long.MAX_VALUE, \"$PREFIX\"?::plus)" diff --git a/compiler/testData/codegen/box/jvm8/defaults/accessor.kt b/compiler/testData/codegen/box/jvm8/defaults/accessor.kt index 261e7d5e612..45d0a7859ed 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/accessor.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/accessor.kt @@ -24,7 +24,7 @@ interface Test { return { foo = "O" foo + bar() - } () + }.let { it() } } } diff --git a/compiler/testData/codegen/box/jvm8/defaults/accessorsFromDefaultImpls.kt b/compiler/testData/codegen/box/jvm8/defaults/accessorsFromDefaultImpls.kt index 6cf84e0aafc..0e981766f30 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/accessorsFromDefaultImpls.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/accessorsFromDefaultImpls.kt @@ -14,7 +14,7 @@ interface Test { } fun call(): String { - return { foo + bar()} () + return { foo + bar() }.let { it() } } } diff --git a/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/accessor.kt b/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/accessor.kt index 87c2f848bd7..2dd2c0cc535 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/accessor.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/accessor.kt @@ -21,7 +21,7 @@ interface Test { return { foo = "O" foo + bar() - } () + }.let { it() } } } diff --git a/compiler/testData/codegen/box/jvm8/defaults/callableReference.kt b/compiler/testData/codegen/box/jvm8/defaults/callableReference.kt index 654cc67d916..09dd3df9686 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/callableReference.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/callableReference.kt @@ -12,7 +12,7 @@ interface Test { get() = "K" fun test(): String { - return (::foo)() + (::bar)() + return (::foo).let { it() } + (::bar).let { it() } } } diff --git a/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/accessor.kt b/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/accessor.kt index 62e743f3b3d..60089f0ac0c 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/accessor.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/accessor.kt @@ -21,7 +21,7 @@ interface Test { return { foo = "O" foo + bar() - } () + }.let { it() } } } diff --git a/compiler/testData/codegen/box/jvmField/captureClassFields.kt b/compiler/testData/codegen/box/jvmField/captureClassFields.kt index fa9115892d4..aadb26c0d47 100644 --- a/compiler/testData/codegen/box/jvmField/captureClassFields.kt +++ b/compiler/testData/codegen/box/jvmField/captureClassFields.kt @@ -10,7 +10,7 @@ open class A { fun test(): String { return { publicField + internalField + protectedField - }() + }.let { it() } } } diff --git a/compiler/testData/codegen/box/jvmName/callableReference.kt b/compiler/testData/codegen/box/jvmName/callableReference.kt index 7e326fd7471..520fa8e6617 100644 --- a/compiler/testData/codegen/box/jvmName/callableReference.kt +++ b/compiler/testData/codegen/box/jvmName/callableReference.kt @@ -6,7 +6,7 @@ fun foo() = "foo" fun box(): String { - val f = (::foo)() + val f = (::foo).let { it() } if (f != "foo") return "Fail: $f" return "OK" diff --git a/compiler/testData/codegen/box/jvmStatic/closure.kt b/compiler/testData/codegen/box/jvmStatic/closure.kt index 74005f90e8a..854e82cbec9 100644 --- a/compiler/testData/codegen/box/jvmStatic/closure.kt +++ b/compiler/testData/codegen/box/jvmStatic/closure.kt @@ -9,27 +9,27 @@ object A { @JvmStatic val c: String = "OK" @JvmStatic fun test1() : String { - return {b}() + return {b}.let { it() } } @JvmStatic fun test2() : String { - return {test1()}() + return {test1()}.let { it() } } fun test3(): String { - return {"1".test5()}() + return {"1".test5()}.let { it() } } @JvmStatic fun test4(): String { - return {"1".test5()}() + return {"1".test5()}.let { it() } } @JvmStatic fun String.test5() : String { - return {this + b}() + return {this + b}.let { it() } } fun test6(): String { - return {c}() + return {c}.let { it() } } } diff --git a/compiler/testData/codegen/box/jvmStatic/functionReference.kt b/compiler/testData/codegen/box/jvmStatic/functionReference.kt index 43981108593..549d15105c2 100644 --- a/compiler/testData/codegen/box/jvmStatic/functionReference.kt +++ b/compiler/testData/codegen/box/jvmStatic/functionReference.kt @@ -10,4 +10,4 @@ object O { // FILE: u2.kt -fun box() = (O::foo)() +fun box() = (O::foo).let { it() } diff --git a/compiler/testData/codegen/box/jvmStatic/kt21246a.kt b/compiler/testData/codegen/box/jvmStatic/kt21246a.kt index d2d1d96a158..f5917ba2ab8 100644 --- a/compiler/testData/codegen/box/jvmStatic/kt21246a.kt +++ b/compiler/testData/codegen/box/jvmStatic/kt21246a.kt @@ -3,7 +3,7 @@ object Test { - fun test() = { createWildcard("OK") }() + fun test() = { createWildcard("OK") }.let { it() } @JvmStatic private fun createWildcard(s: String) = Type(s).x diff --git a/compiler/testData/codegen/box/labels/propertyAccessorFunctionLiteral.kt b/compiler/testData/codegen/box/labels/propertyAccessorFunctionLiteral.kt index 6d26e930ed2..1e940302ed0 100644 --- a/compiler/testData/codegen/box/labels/propertyAccessorFunctionLiteral.kt +++ b/compiler/testData/codegen/box/labels/propertyAccessorFunctionLiteral.kt @@ -2,7 +2,7 @@ val Int.getter: Int get() { return { this@getter - }.invoke() + }.let { it.invoke() } } fun box(): String { diff --git a/compiler/testData/codegen/box/multiDecl/forIterator/MultiDeclForValCaptured.kt b/compiler/testData/codegen/box/multiDecl/forIterator/MultiDeclForValCaptured.kt index b1776f685f3..9f268982b45 100644 --- a/compiler/testData/codegen/box/multiDecl/forIterator/MultiDeclForValCaptured.kt +++ b/compiler/testData/codegen/box/multiDecl/forIterator/MultiDeclForValCaptured.kt @@ -7,7 +7,7 @@ class C(val i: Int) { fun doTest(l : ArrayList): String { var s = "" for ((a, b) in l) { - s += {"$a:$b;"}() + s += {"$a:$b;"}.let { it() } } return s } diff --git a/compiler/testData/codegen/box/multiDecl/forIterator/longIterator/MultiDeclForComponentExtensionsValCaptured.kt b/compiler/testData/codegen/box/multiDecl/forIterator/longIterator/MultiDeclForComponentExtensionsValCaptured.kt index 814344fba6e..a2d6603559b 100644 --- a/compiler/testData/codegen/box/multiDecl/forIterator/longIterator/MultiDeclForComponentExtensionsValCaptured.kt +++ b/compiler/testData/codegen/box/multiDecl/forIterator/longIterator/MultiDeclForComponentExtensionsValCaptured.kt @@ -5,7 +5,7 @@ operator fun Long.component2() = this + 2 fun doTest(l : ArrayList): String { var s = "" for ((a, b) in l) { - s += {"$a:$b;"}() + s += {"$a:$b;"}.let { it() } } return s } diff --git a/compiler/testData/codegen/box/multiDecl/forRange/MultiDeclForValCaptured.kt b/compiler/testData/codegen/box/multiDecl/forRange/MultiDeclForValCaptured.kt index 4687822bb09..4d91116e451 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/MultiDeclForValCaptured.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/MultiDeclForValCaptured.kt @@ -23,7 +23,7 @@ class C(val i : Int) { fun doTest(): String { var s = "" for ((a, b) in C(0)..C(2)) { - s += {"$a:$b;"}() + s += {"$a:$b;"}.let { it() } } return s } diff --git a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/MultiDeclForValCaptured.kt b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/MultiDeclForValCaptured.kt index b09acb4b8aa..b312754e485 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/MultiDeclForValCaptured.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/MultiDeclForValCaptured.kt @@ -23,7 +23,7 @@ class C(val i : Int) { fun doTest(): String { var s = "" for ((a, b) in C(0) rangeTo C(2)) { - s += {"$a:$b;"}() + s += {"$a:$b;"}.let { it() } } return s } diff --git a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/int/MultiDeclForComponentExtensionsValCaptured.kt b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/int/MultiDeclForComponentExtensionsValCaptured.kt index f1d711a42e2..d0629e3de8d 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/int/MultiDeclForComponentExtensionsValCaptured.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/int/MultiDeclForComponentExtensionsValCaptured.kt @@ -4,7 +4,7 @@ operator fun Int.component2() = this + 2 fun doTest(): String { var s = "" for ((a, b) in 0.rangeTo(2)) { - s += {"$a:$b;"}() + s += {"$a:$b;"}.let { it() } } return s } diff --git a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/long/MultiDeclForComponentExtensionsValCaptured.kt b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/long/MultiDeclForComponentExtensionsValCaptured.kt index fcb229e7f75..d7a21d08c28 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/long/MultiDeclForComponentExtensionsValCaptured.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeTo/long/MultiDeclForComponentExtensionsValCaptured.kt @@ -4,7 +4,7 @@ operator fun Long.component2() = this + 2 fun doTest(): String { var s = "" for ((a, b) in 0.toLong().rangeTo(2.toLong())) { - s += {"$a:$b;"}() + s += {"$a:$b;"}.let { it() } } return s } diff --git a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/MultiDeclForValCaptured.kt b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/MultiDeclForValCaptured.kt index 8df7e251bf5..747e68b40c9 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/MultiDeclForValCaptured.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/MultiDeclForValCaptured.kt @@ -23,7 +23,7 @@ class C(val i : Int) { fun doTest(): String { var s = "" for ((a, b) in C(0).rangeTo(C(2))) { - s += {"$a:$b;"}() + s += {"$a:$b;"}.let { it() } } return s } diff --git a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/int/MultiDeclForComponentExtensionsValCaptured.kt b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/int/MultiDeclForComponentExtensionsValCaptured.kt index f1d711a42e2..d0629e3de8d 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/int/MultiDeclForComponentExtensionsValCaptured.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/int/MultiDeclForComponentExtensionsValCaptured.kt @@ -4,7 +4,7 @@ operator fun Int.component2() = this + 2 fun doTest(): String { var s = "" for ((a, b) in 0.rangeTo(2)) { - s += {"$a:$b;"}() + s += {"$a:$b;"}.let { it() } } return s } diff --git a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/long/MultiDeclForComponentExtensionsValCaptured.kt b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/long/MultiDeclForComponentExtensionsValCaptured.kt index fcb229e7f75..d7a21d08c28 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/long/MultiDeclForComponentExtensionsValCaptured.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/explicitRangeToWithDot/long/MultiDeclForComponentExtensionsValCaptured.kt @@ -4,7 +4,7 @@ operator fun Long.component2() = this + 2 fun doTest(): String { var s = "" for ((a, b) in 0.toLong().rangeTo(2.toLong())) { - s += {"$a:$b;"}() + s += {"$a:$b;"}.let { it() } } return s } diff --git a/compiler/testData/codegen/box/multiDecl/forRange/int/MultiDeclForComponentExtensionsValCaptured.kt b/compiler/testData/codegen/box/multiDecl/forRange/int/MultiDeclForComponentExtensionsValCaptured.kt index fd0f6dac885..8c0c58e490e 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/int/MultiDeclForComponentExtensionsValCaptured.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/int/MultiDeclForComponentExtensionsValCaptured.kt @@ -4,7 +4,7 @@ operator fun Int.component2() = this + 2 fun doTest(): String { var s = "" for ((a, b) in 0..2) { - s += {"$a:$b;"}() + s += {"$a:$b;"}.let { it() } } return s } diff --git a/compiler/testData/codegen/box/multiDecl/forRange/long/MultiDeclForComponentExtensionsValCaptured.kt b/compiler/testData/codegen/box/multiDecl/forRange/long/MultiDeclForComponentExtensionsValCaptured.kt index 8bf72ec08d7..6d6793f1dd6 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/long/MultiDeclForComponentExtensionsValCaptured.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/long/MultiDeclForComponentExtensionsValCaptured.kt @@ -4,7 +4,7 @@ operator fun Long.component2() = this + 2 fun doTest(): String { var s = "" for ((a, b) in 0.toLong()..2.toLong()) { - s += {"$a:$b;"}() + s += {"$a:$b;"}.let { it() } } return s } diff --git a/compiler/testData/codegen/box/multifileClasses/optimized/callableRefToFun.kt b/compiler/testData/codegen/box/multifileClasses/optimized/callableRefToFun.kt index 9a1ffcf9a6b..f395dc38263 100644 --- a/compiler/testData/codegen/box/multifileClasses/optimized/callableRefToFun.kt +++ b/compiler/testData/codegen/box/multifileClasses/optimized/callableRefToFun.kt @@ -6,7 +6,7 @@ import a.* -fun box(): String = (::ok)() +fun box(): String = (::ok).let { it() } // FILE: part1.kt @file:[JvmName("MultifileClass") JvmMultifileClass] diff --git a/compiler/testData/codegen/box/objects/anonymousObjectPropertyInitialization.kt b/compiler/testData/codegen/box/objects/anonymousObjectPropertyInitialization.kt index 4765e8858ba..7a0478ff30b 100644 --- a/compiler/testData/codegen/box/objects/anonymousObjectPropertyInitialization.kt +++ b/compiler/testData/codegen/box/objects/anonymousObjectPropertyInitialization.kt @@ -6,7 +6,7 @@ val o = object : T { val a = "OK" val f = { a - }() + }.let { it() } override fun foo() = f } diff --git a/compiler/testData/codegen/box/properties/kt2331.kt b/compiler/testData/codegen/box/properties/kt2331.kt index a96dd67bf6d..964c7e12636 100644 --- a/compiler/testData/codegen/box/properties/kt2331.kt +++ b/compiler/testData/codegen/box/properties/kt2331.kt @@ -3,7 +3,7 @@ class P { private set fun foo() { - ({ x = 4 })() + ({ x = 4 }).let { it() } } } diff --git a/compiler/testData/codegen/box/ranges/contains/nullableInPrimitiveRange.kt b/compiler/testData/codegen/box/ranges/contains/nullableInPrimitiveRange.kt index 339a2a3690b..22f037401f6 100644 --- a/compiler/testData/codegen/box/ranges/contains/nullableInPrimitiveRange.kt +++ b/compiler/testData/codegen/box/ranges/contains/nullableInPrimitiveRange.kt @@ -31,8 +31,8 @@ fun box(): String { if (null in 0..2) return "Fail in null const" if (!(null !in 0..2)) return "Fail !in null const" - if ({ x }() in 0..2) return "Fail in complex" - if (!({ x }() !in 0..2)) return "Fail !in complex" + if ({ x }.let { it() } in 0..2) return "Fail in complex" + if (!({ x }.let { it() } !in 0..2)) return "Fail !in complex" return "OK" } \ No newline at end of file diff --git a/compiler/testData/codegen/box/topLevelPrivate/noPrivateNoAccessorsInMultiFileFacade.kt b/compiler/testData/codegen/box/topLevelPrivate/noPrivateNoAccessorsInMultiFileFacade.kt index 99617c00eb1..8870c937cc7 100644 --- a/compiler/testData/codegen/box/topLevelPrivate/noPrivateNoAccessorsInMultiFileFacade.kt +++ b/compiler/testData/codegen/box/topLevelPrivate/noPrivateNoAccessorsInMultiFileFacade.kt @@ -19,5 +19,5 @@ fun box(): String { return { prop + test() - }() + }.let { it() } } diff --git a/compiler/testData/codegen/box/topLevelPrivate/noPrivateNoAccessorsInMultiFileFacade2.kt b/compiler/testData/codegen/box/topLevelPrivate/noPrivateNoAccessorsInMultiFileFacade2.kt index e485623139c..743bbb72ef5 100644 --- a/compiler/testData/codegen/box/topLevelPrivate/noPrivateNoAccessorsInMultiFileFacade2.kt +++ b/compiler/testData/codegen/box/topLevelPrivate/noPrivateNoAccessorsInMultiFileFacade2.kt @@ -24,5 +24,5 @@ fun box(): String { return { prop = "O" prop + test() - }() + }.let { it() } } diff --git a/compiler/testData/codegen/box/traits/traitWithPrivateMemberAccessFromLambda.kt b/compiler/testData/codegen/box/traits/traitWithPrivateMemberAccessFromLambda.kt index 0b2a16072d3..2f6526eaee4 100644 --- a/compiler/testData/codegen/box/traits/traitWithPrivateMemberAccessFromLambda.kt +++ b/compiler/testData/codegen/box/traits/traitWithPrivateMemberAccessFromLambda.kt @@ -1,11 +1,11 @@ interface Z { fun testFun(): String { - return { privateFun() } () + return { privateFun() }.let { it() } } fun testProperty(): String { - return { privateProp } () + return { privateProp }.let { it() } } private fun privateFun(): String { diff --git a/compiler/testData/codegen/box/unit/kt4265.kt b/compiler/testData/codegen/box/unit/kt4265.kt index 3c1aaf9d462..c40775dcdf0 100644 --- a/compiler/testData/codegen/box/unit/kt4265.kt +++ b/compiler/testData/codegen/box/unit/kt4265.kt @@ -1,13 +1,13 @@ -fun T.let(f: (T) -> R): R = f(this) +fun T.myLet(f: (T) -> R): R = f(this) fun box(): String { val o: String? = null var state = 0 - o?.let { + o?.myLet { state = 1 - } ?: ({ state = 2 })() + } ?: { state = 2 }.let { it() } if (state != 2) return "Fail: $state" return "OK" diff --git a/compiler/testData/codegen/box/unit/sillyThings.kt b/compiler/testData/codegen/box/unit/sillyThings.kt index 6ed3a5812fe..68403afe7e0 100644 --- a/compiler/testData/codegen/box/unit/sillyThings.kt +++ b/compiler/testData/codegen/box/unit/sillyThings.kt @@ -30,11 +30,11 @@ fun box(): String { val tmp = Unit { - }() + }.let { it() } val tmp2 = { - }() + }.let { it() } val tmp3 = Blumbs() tmp3.t = Unit diff --git a/compiler/testData/codegen/bytecodeText/capturedVarsOptimization/capturedValInLambdaInitializedOutside.kt b/compiler/testData/codegen/bytecodeText/capturedVarsOptimization/capturedValInLambdaInitializedOutside.kt index b28b0dd844c..283007ee79a 100644 --- a/compiler/testData/codegen/bytecodeText/capturedVarsOptimization/capturedValInLambdaInitializedOutside.kt +++ b/compiler/testData/codegen/bytecodeText/capturedVarsOptimization/capturedValInLambdaInitializedOutside.kt @@ -3,7 +3,7 @@ fun box(): String { x = "OK" { val y = x - }() + }.let { it() } return x } diff --git a/compiler/testData/codegen/bytecodeText/properties/lateinit/companionObjectFromLambda.kt b/compiler/testData/codegen/bytecodeText/properties/lateinit/companionObjectFromLambda.kt index 35fa5bafe41..245d9006ab2 100644 --- a/compiler/testData/codegen/bytecodeText/properties/lateinit/companionObjectFromLambda.kt +++ b/compiler/testData/codegen/bytecodeText/properties/lateinit/companionObjectFromLambda.kt @@ -3,14 +3,14 @@ class Foo { lateinit var x: String fun test() { - consume({ x }()); - { consume(x) }() + consume({ x }.let { it() }); + { consume(x) }.let { it() } } } fun test2() { - consume({ x }()); - { consume(x) }() + consume({ x }.let { it() }); + { consume(x) }.let { it() } } } diff --git a/compiler/testData/codegen/bytecodeText/when/exhaustiveWhenSpecialCases.kt b/compiler/testData/codegen/bytecodeText/when/exhaustiveWhenSpecialCases.kt index b006c3d456a..e1b65a80a17 100644 --- a/compiler/testData/codegen/bytecodeText/when/exhaustiveWhenSpecialCases.kt +++ b/compiler/testData/codegen/bytecodeText/when/exhaustiveWhenSpecialCases.kt @@ -81,7 +81,7 @@ fun testLambdaResultExpression_throws(a: A) { A.V1 -> 1 // else -> throw } - }() + }.let { it() } } // JVM_TEMPLATES