Added checking for ONLY_LOCAL_RETURN in actual parameter of inline function
This commit is contained in:
+10
@@ -0,0 +1,10 @@
|
||||
import kotlin.InlineOption.ONLY_LOCAL_RETURN
|
||||
|
||||
inline fun testSameCaptured(lambdaWithResultCaptured: () -> Unit) : String {
|
||||
doWork({<!NON_LOCAL_RETURN_NOT_ALLOWED!>lambdaWithResultCaptured<!>()})
|
||||
return "OK"
|
||||
}
|
||||
|
||||
inline fun <R> doWork(inlineOptions(ONLY_LOCAL_RETURN) job: ()-> R) : R {
|
||||
return job()
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE
|
||||
import kotlin.InlineOption.*
|
||||
|
||||
fun <R> fun1(p: () -> R) {
|
||||
inlineFun {
|
||||
p()
|
||||
}
|
||||
}
|
||||
|
||||
fun <R> fun1ValueArgument(p: () -> R) {
|
||||
inlineFun ({
|
||||
p()
|
||||
})
|
||||
}
|
||||
|
||||
fun <R> fun3(p: () -> R) {
|
||||
inlineFun {
|
||||
<!RETURN_NOT_ALLOWED!>return<!>;
|
||||
}
|
||||
}
|
||||
|
||||
fun <R> fun3ValueArgument(p: () -> R) {
|
||||
inlineFun ({
|
||||
<!RETURN_NOT_ALLOWED!>return<!>;
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
fun <R> fun4(p: () -> R) {
|
||||
inlineFun @lambda {(): R ->
|
||||
return@lambda p();
|
||||
}
|
||||
}
|
||||
|
||||
fun <R> fun4ValueArgument(p: () -> R) {
|
||||
inlineFun (@lambda {(): R ->
|
||||
return@lambda p();
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
inline fun <R> inlineFun(inlineOptions(ONLY_LOCAL_RETURN) p: () -> R) {
|
||||
p()
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE
|
||||
import kotlin.InlineOption.*
|
||||
|
||||
class Z {
|
||||
inline fun <R> inlineFun(inlineOptions(ONLY_LOCAL_RETURN) p: () -> R) {
|
||||
p()
|
||||
}
|
||||
}
|
||||
|
||||
fun <R> fun1(p: () -> R) {
|
||||
Z() inlineFun {
|
||||
p()
|
||||
}
|
||||
}
|
||||
|
||||
fun <R> fun3(p: () -> R) {
|
||||
Z() inlineFun {
|
||||
<!RETURN_NOT_ALLOWED!>return<!>;
|
||||
}
|
||||
}
|
||||
|
||||
fun <R> fun4(p: () -> R) {
|
||||
Z() inlineFun @lambda {(): R ->
|
||||
return@lambda p();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user