diff --git a/compiler/testData/builtin-classes.txt b/compiler/testData/builtin-classes.txt index d03c764dfbc..4719ad693b9 100644 --- a/compiler/testData/builtin-classes.txt +++ b/compiler/testData/builtin-classes.txt @@ -762,6 +762,42 @@ public trait Function9 { + /*primary*/ private constructor InlineOption() + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + + public class object { + /*primary*/ private constructor () + public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): kotlin.InlineOption + public final /*synthesized*/ fun values(): kotlin.Array + } + + public enum entry LOCAL_CONTINUE_AND_BREAK : kotlin.InlineOption { + /*primary*/ private constructor LOCAL_CONTINUE_AND_BREAK() + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + + public class object : kotlin.InlineOption.LOCAL_CONTINUE_AND_BREAK { + /*primary*/ private constructor () + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + } + } + + public enum entry ONLY_LOCAL_RETURN : kotlin.InlineOption { + /*primary*/ private constructor ONLY_LOCAL_RETURN() + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + + public class object : kotlin.InlineOption.ONLY_LOCAL_RETURN { + /*primary*/ private constructor () + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + } + } +} + public final enum class InlineStrategy : kotlin.Enum { /*primary*/ private constructor InlineStrategy() public final override /*1*/ /*fake_override*/ fun name(): kotlin.String @@ -1440,6 +1476,12 @@ public final annotation class inline : kotlin.Annotation { public final fun (): kotlin.InlineStrategy } +public final annotation class inlineOptions : kotlin.Annotation { + /*primary*/ public constructor inlineOptions(/*0*/ vararg value: kotlin.InlineOption /*kotlin.Array*/) + internal final val value: kotlin.Array + internal final fun (): kotlin.Array +} + public final annotation class noinline : kotlin.Annotation { /*primary*/ public constructor noinline() } diff --git a/compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectOnDeclarationSite.2.kt b/compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectOnDeclarationSite.2.kt index 9a811742b29..1e63a0de218 100644 --- a/compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectOnDeclarationSite.2.kt +++ b/compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectOnDeclarationSite.2.kt @@ -1,5 +1,7 @@ package test +import kotlin.InlineOption.* + abstract class A { abstract fun getO() : R @@ -8,7 +10,7 @@ abstract class A { abstract fun getParam() : R } -inline fun doWork(jobO: ()-> R, jobK: ()-> R, param: R) : A { +inline fun doWork(inlineOptions(ONLY_LOCAL_RETURN) jobO: ()-> R, inlineOptions(ONLY_LOCAL_RETURN) jobK: ()-> R, param: R) : A { val s = object : A() { override fun getO(): R { @@ -25,7 +27,7 @@ inline fun doWork(jobO: ()-> R, jobK: ()-> R, param: R) : A { return s; } -inline fun doWorkInConstructor(jobO: ()-> R, jobK: ()-> R, param: R) : A { +inline fun doWorkInConstructor(inlineOptions(ONLY_LOCAL_RETURN) jobO: ()-> R, inlineOptions(ONLY_LOCAL_RETURN) jobK: ()-> R, param: R) : A { val s = object : A() { val p = param; diff --git a/compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectOnDeclarationSiteSuperParams.2.kt b/compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectOnDeclarationSiteSuperParams.2.kt index 5c7af7ad686..60aec4858bb 100644 --- a/compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectOnDeclarationSiteSuperParams.2.kt +++ b/compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectOnDeclarationSiteSuperParams.2.kt @@ -1,12 +1,14 @@ package test +import kotlin.InlineOption.* + abstract class A(val param : R) { abstract fun getO() : R abstract fun getK() : R } -inline fun doWork(jobO: ()-> R, jobK: ()-> R, param: R) : A { +inline fun doWork(inlineOptions(ONLY_LOCAL_RETURN) jobO: ()-> R, inlineOptions(ONLY_LOCAL_RETURN) jobK: ()-> R, param: R) : A { val s = object : A(param) { override fun getO(): R { @@ -19,7 +21,7 @@ inline fun doWork(jobO: ()-> R, jobK: ()-> R, param: R) : A { return s; } -inline fun doWorkInConstructor(jobO: ()-> R, jobK: ()-> R, param: () -> R) : A { +inline fun doWorkInConstructor(inlineOptions(ONLY_LOCAL_RETURN) jobO: ()-> R, inlineOptions(ONLY_LOCAL_RETURN) jobK: ()-> R, inlineOptions(ONLY_LOCAL_RETURN) param: () -> R) : A { val s = object : A(param()) { val o1 = jobO() diff --git a/compiler/testData/codegen/boxInline/builders/buildersAndLambdaCapturing.1.kt b/compiler/testData/codegen/boxInline/builders/buildersAndLambdaCapturing.1.kt index 0c4eb3d1ba0..8a29493b425 100644 --- a/compiler/testData/codegen/boxInline/builders/buildersAndLambdaCapturing.1.kt +++ b/compiler/testData/codegen/boxInline/builders/buildersAndLambdaCapturing.1.kt @@ -1,4 +1,5 @@ import builders.* +import kotlin.InlineOption.* inline fun testAllInline(f: () -> String) : String { val args = array("1", "2", "3") @@ -40,7 +41,7 @@ inline fun testAllInline(f: () -> String) : String { return result.toString()!! } -inline fun testHtmlNoInline(f: () -> String) : String { +inline fun testHtmlNoInline(inlineOptions(ONLY_LOCAL_RETURN) f: () -> String) : String { val args = array("1", "2", "3") val result = htmlNoInline() { @@ -80,7 +81,7 @@ inline fun testHtmlNoInline(f: () -> String) : String { return result.toString()!! } -inline fun testBodyNoInline(f: () -> String) : String { +inline fun testBodyNoInline(inlineOptions(ONLY_LOCAL_RETURN) f: () -> String) : String { val args = array("1", "2", "3") val result = html { @@ -120,7 +121,7 @@ inline fun testBodyNoInline(f: () -> String) : String { return result.toString()!! } -inline fun testBodyHtmlNoInline(f: () -> String) : String { +inline fun testBodyHtmlNoInline(inlineOptions(ONLY_LOCAL_RETURN) f: () -> String) : String { val args = array("1", "2", "3") val result = htmlNoInline { diff --git a/compiler/testData/codegen/boxInline/builders/buildersAndLambdaCapturing.2.kt b/compiler/testData/codegen/boxInline/builders/buildersAndLambdaCapturing.2.kt index f2c29052b97..c19b0284c3b 100644 --- a/compiler/testData/codegen/boxInline/builders/buildersAndLambdaCapturing.2.kt +++ b/compiler/testData/codegen/boxInline/builders/buildersAndLambdaCapturing.2.kt @@ -69,7 +69,7 @@ class Title() : TagWithText("title") abstract class BodyTag(name: String) : TagWithText(name) { inline fun b(init: B.() -> Unit) = initTag(B(), init) inline fun p(init: P.() -> Unit) = initTag(P(), init) - inline fun pNoInline(init: P.() -> Unit) = initTag(P(), init) + fun pNoInline(init: P.() -> Unit) = initTag(P(), init) inline fun h1(init: H1.() -> Unit) = initTag(H1(), init) inline fun ul(init: UL.() -> Unit) = initTag(UL(), init) inline fun a(href: String, init: A.() -> Unit) { diff --git a/compiler/testData/codegen/boxInline/capture/captureInlinable.2.kt b/compiler/testData/codegen/boxInline/capture/captureInlinable.2.kt index 8d35830e78b..469f479423c 100644 --- a/compiler/testData/codegen/boxInline/capture/captureInlinable.2.kt +++ b/compiler/testData/codegen/boxInline/capture/captureInlinable.2.kt @@ -1,6 +1,8 @@ package test -inline fun doWork(job: ()-> R) : R { +import kotlin.InlineOption.* + +inline fun doWork(inlineOptions(ONLY_LOCAL_RETURN) job: ()-> R) : R { return notInline({job()}) } diff --git a/compiler/testData/codegen/boxInline/capture/captureInlinableAndOther.2.kt b/compiler/testData/codegen/boxInline/capture/captureInlinableAndOther.2.kt index 513e63606c4..be7716e8776 100644 --- a/compiler/testData/codegen/boxInline/capture/captureInlinableAndOther.2.kt +++ b/compiler/testData/codegen/boxInline/capture/captureInlinableAndOther.2.kt @@ -1,6 +1,8 @@ package test -inline fun doWork(job: ()-> R) : R { +import kotlin.InlineOption.* + +inline fun doWork(inlineOptions(ONLY_LOCAL_RETURN) job: ()-> R) : R { val k = 10; return notInline({k; job()}) } diff --git a/compiler/testData/codegen/boxInline/complex/with.2.kt b/compiler/testData/codegen/boxInline/complex/with.2.kt index f0746c03958..0684df6c177 100644 --- a/compiler/testData/codegen/boxInline/complex/with.2.kt +++ b/compiler/testData/codegen/boxInline/complex/with.2.kt @@ -1,5 +1,7 @@ package test +import kotlin.InlineOption.* + public class Data() public class Input(val d: Data) : Closeable { @@ -27,4 +29,4 @@ public fun Input.copyTo(output: Output, size: Int): Long { } -public inline fun with2(receiver : T, body : T.() -> Unit) : Unit = {receiver.body()}() +public inline fun with2(receiver : T, inlineOptions(ONLY_LOCAL_RETURN) body : T.() -> Unit) : Unit = {receiver.body()}() diff --git a/compiler/testData/codegen/boxInline/lambdaClassClash/lambdaClassClash.2.kt b/compiler/testData/codegen/boxInline/lambdaClassClash/lambdaClassClash.2.kt index 76f1b12511f..4821ce2eca4 100644 --- a/compiler/testData/codegen/boxInline/lambdaClassClash/lambdaClassClash.2.kt +++ b/compiler/testData/codegen/boxInline/lambdaClassClash/lambdaClassClash.2.kt @@ -1,6 +1,8 @@ package zzz -inline fun calc(lambda: () -> Int): Int { +import kotlin.InlineOption.* + +inline fun calc(inlineOptions(ONLY_LOCAL_RETURN) lambda: () -> Int): Int { return doCalc { lambda() } } diff --git a/compiler/testData/codegen/boxInline/lambdaTransformation/lambdaInLambdaNoInline.1.kt b/compiler/testData/codegen/boxInline/lambdaTransformation/lambdaInLambdaNoInline.1.kt index 5b87bb844e2..40c19f1c1e6 100644 --- a/compiler/testData/codegen/boxInline/lambdaTransformation/lambdaInLambdaNoInline.1.kt +++ b/compiler/testData/codegen/boxInline/lambdaTransformation/lambdaInLambdaNoInline.1.kt @@ -1,5 +1,7 @@ import test.* +import kotlin.InlineOption.* + fun test1(param: String): String { var result = "fail1" noInlineFun(param) { a -> @@ -22,7 +24,7 @@ fun test11(param: String): String { return result } -inline fun test2(param: () -> String): String { +inline fun test2(inlineOptions(ONLY_LOCAL_RETURN) param: () -> String): String { var result = "fail1" noInlineFun("stub") { a -> concat(param()) { @@ -33,7 +35,7 @@ inline fun test2(param: () -> String): String { return result } -inline fun test22(param: () -> String): String { +inline fun test22(inlineOptions(ONLY_LOCAL_RETURN) param: () -> String): String { var result = "fail1" {{result = param()}()}() diff --git a/compiler/testData/codegen/boxInline/lambdaTransformation/regeneratedLambdaName.2.kt b/compiler/testData/codegen/boxInline/lambdaTransformation/regeneratedLambdaName.2.kt index f063e5ec7e7..4a4786abaec 100644 --- a/compiler/testData/codegen/boxInline/lambdaTransformation/regeneratedLambdaName.2.kt +++ b/compiler/testData/codegen/boxInline/lambdaTransformation/regeneratedLambdaName.2.kt @@ -1,5 +1,7 @@ package test -inline fun call(f: () -> R) : R { +import kotlin.InlineOption.* + +inline fun call(inlineOptions(ONLY_LOCAL_RETURN) f: () -> R) : R { return {f()} () } diff --git a/compiler/testData/codegen/boxInline/lambdaTransformation/sameCaptured.2.kt b/compiler/testData/codegen/boxInline/lambdaTransformation/sameCaptured.2.kt index c9c21a55892..a9907ead483 100644 --- a/compiler/testData/codegen/boxInline/lambdaTransformation/sameCaptured.2.kt +++ b/compiler/testData/codegen/boxInline/lambdaTransformation/sameCaptured.2.kt @@ -1,11 +1,13 @@ package test -inline fun doWork(job: ()-> R) : R { +import kotlin.InlineOption.* + +inline fun doWork(inlineOptions(ONLY_LOCAL_RETURN) job: ()-> R) : R { val k = 10; return notInline({k; job()}) } -inline fun doWork(job: ()-> R, job2: () -> R) : R { +inline fun doWork(inlineOptions(ONLY_LOCAL_RETURN) job: ()-> R, inlineOptions(ONLY_LOCAL_RETURN) job2: () -> R) : R { val k = 10; return notInline({k; job(); job2()}) } diff --git a/compiler/testData/codegen/boxInline/noInline/noInlineLambdaChainWithCapturedInline.1.kt b/compiler/testData/codegen/boxInline/noInline/noInlineLambdaChainWithCapturedInline.1.kt index 2c24fa025ff..6c67851060d 100644 --- a/compiler/testData/codegen/boxInline/noInline/noInlineLambdaChainWithCapturedInline.1.kt +++ b/compiler/testData/codegen/boxInline/noInline/noInlineLambdaChainWithCapturedInline.1.kt @@ -1,6 +1,8 @@ import test.* -inline fun test1(param: () -> String): String { +import kotlin.InlineOption.* + +inline fun test1(inlineOptions(ONLY_LOCAL_RETURN) param: () -> String): String { var result = "fail" inlineFun("1") { c -> { @@ -18,7 +20,7 @@ inline fun test1(param: () -> String): String { } -inline fun test2(param: () -> String): String { +inline fun test2(inlineOptions(ONLY_LOCAL_RETURN) param: () -> String): String { var result = "fail" inlineFun("2") { a -> { @@ -31,7 +33,7 @@ inline fun test2(param: () -> String): String { return result } -inline fun test3(param: () -> String): String { +inline fun test3(inlineOptions(ONLY_LOCAL_RETURN) param: () -> String): String { var result = "fail" inlineFun("2") { d -> inlineFun("1") { c -> diff --git a/compiler/testData/codegen/boxInline/simple/rootConstructor.2.kt b/compiler/testData/codegen/boxInline/simple/rootConstructor.2.kt index 8d35830e78b..469f479423c 100644 --- a/compiler/testData/codegen/boxInline/simple/rootConstructor.2.kt +++ b/compiler/testData/codegen/boxInline/simple/rootConstructor.2.kt @@ -1,6 +1,8 @@ package test -inline fun doWork(job: ()-> R) : R { +import kotlin.InlineOption.* + +inline fun doWork(inlineOptions(ONLY_LOCAL_RETURN) job: ()-> R) : R { return notInline({job()}) } diff --git a/compiler/testData/codegen/outerClassInfo/inlineLambda.kt b/compiler/testData/codegen/outerClassInfo/inlineLambda.kt index 9b62696451a..15c982629b8 100644 --- a/compiler/testData/codegen/outerClassInfo/inlineLambda.kt +++ b/compiler/testData/codegen/outerClassInfo/inlineLambda.kt @@ -1,8 +1,10 @@ package foo; +import kotlin.InlineOption.* + class Foo { - inline fun inlineFoo(s: () -> Unit) { + inline fun inlineFoo(inlineOptions(ONLY_LOCAL_RETURN) s: () -> Unit) { { s() }() diff --git a/compiler/testData/codegen/outerClassInfo/inlineObject.kt b/compiler/testData/codegen/outerClassInfo/inlineObject.kt index 59f7260e5af..baa6dacfcff 100644 --- a/compiler/testData/codegen/outerClassInfo/inlineObject.kt +++ b/compiler/testData/codegen/outerClassInfo/inlineObject.kt @@ -1,8 +1,10 @@ package foo; +import kotlin.InlineOption.* + class Foo { - inline fun inlineFoo(s: () -> Unit) { + inline fun inlineFoo(inlineOptions(ONLY_LOCAL_RETURN) s: () -> Unit) { val localObject = object { fun run() { s() diff --git a/compiler/testData/diagnostics/tests/inline/anonymousObjects.kt b/compiler/testData/diagnostics/tests/inline/anonymousObjects.kt index 126946fb0bd..af6c62677c6 100644 --- a/compiler/testData/diagnostics/tests/inline/anonymousObjects.kt +++ b/compiler/testData/diagnostics/tests/inline/anonymousObjects.kt @@ -1,4 +1,4 @@ -// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE +// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -NON_LOCAL_RETURN_NOT_ALLOWED inline fun inlineFun(p: () -> R) { val s = object { diff --git a/compiler/testData/diagnostics/tests/inline/binaryExpressions/assignment.kt b/compiler/testData/diagnostics/tests/inline/binaryExpressions/assignment.kt index f10bd226d96..8ea305e5521 100644 --- a/compiler/testData/diagnostics/tests/inline/binaryExpressions/assignment.kt +++ b/compiler/testData/diagnostics/tests/inline/binaryExpressions/assignment.kt @@ -1,4 +1,4 @@ -// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -ONLY_LOCAL_RETURN +// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -NON_LOCAL_RETURN_NOT_ALLOWED fun Function1.minusAssign(p: Function1) {} diff --git a/compiler/testData/diagnostics/tests/inline/capture.kt b/compiler/testData/diagnostics/tests/inline/capture.kt index 5b821c1407c..55bd44aa557 100644 --- a/compiler/testData/diagnostics/tests/inline/capture.kt +++ b/compiler/testData/diagnostics/tests/inline/capture.kt @@ -1,4 +1,4 @@ -// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE +// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -NON_LOCAL_RETURN_NOT_ALLOWED fun Function1.noInlineExt(p: Int) {} diff --git a/compiler/testData/diagnostics/tests/inline/propagation.kt b/compiler/testData/diagnostics/tests/inline/propagation.kt index 658dede57d4..c994f4a92cd 100644 --- a/compiler/testData/diagnostics/tests/inline/propagation.kt +++ b/compiler/testData/diagnostics/tests/inline/propagation.kt @@ -1,4 +1,4 @@ -// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE +// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -NON_LOCAL_RETURN_NOT_ALLOWED inline fun inlineFunWithInvoke(s: (p: Int) -> Unit, ext: Int.(p: Int) -> Unit) { subInline(s, ext) diff --git a/compiler/testData/diagnostics/tests/inline/sam.kt b/compiler/testData/diagnostics/tests/inline/sam.kt index 5704f82ab31..6be31f27356 100644 --- a/compiler/testData/diagnostics/tests/inline/sam.kt +++ b/compiler/testData/diagnostics/tests/inline/sam.kt @@ -1,3 +1,4 @@ +// !DIAGNOSTICS: -NON_LOCAL_RETURN_NOT_ALLOWED // FILE: Run.java public interface Run { public int run();