Diagnostics for wrong inlinable usage
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
|
||||
fun Function1<Int, Unit>.noInlineExt(p: Int) {}
|
||||
|
||||
inline fun Function1<Int, Unit>.inlineExt2(p: Int) {
|
||||
{
|
||||
<!USAGE_IS_NOT_INLINABLE!>noInlineExt<!>(11)
|
||||
<!USAGE_IS_NOT_INLINABLE!>this<!>.noInlineExt(11)
|
||||
<!USAGE_IS_NOT_INLINABLE!>this<!> noInlineExt 11
|
||||
<!USAGE_IS_NOT_INLINABLE!>this<!>
|
||||
}()
|
||||
}
|
||||
|
||||
|
||||
inline fun Function1<Int, Unit>.inlineExt() {
|
||||
{
|
||||
inlineExt2(1)
|
||||
this.inlineExt2(1)
|
||||
this inlineExt2 1
|
||||
this(11)
|
||||
}()
|
||||
}
|
||||
|
||||
inline fun inlineFunWithInvoke(s: (p: Int) -> Unit) {
|
||||
{
|
||||
s(11)
|
||||
s.invoke(11)
|
||||
s invoke 11
|
||||
}()
|
||||
}
|
||||
|
||||
inline fun inlineFunWithInvokeNonInline(noinline s: (p: Int) -> Unit) {
|
||||
{
|
||||
s(11)
|
||||
s.invoke(11)
|
||||
s invoke 11
|
||||
}()
|
||||
}
|
||||
|
||||
|
||||
inline fun testExtension(s: (p: Int) -> Unit) {
|
||||
{
|
||||
s.inlineExt()
|
||||
} ()
|
||||
}
|
||||
|
||||
inline fun inlineFunWrongExtension(s: (p: Int) -> Unit) {
|
||||
{
|
||||
<!USAGE_IS_NOT_INLINABLE!>s<!>.noInlineExt(11)
|
||||
} ()
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
class Z(s: (Int) -> Int) {
|
||||
|
||||
}
|
||||
|
||||
public inline fun test(s : (Int) -> Int) {
|
||||
<!INVISIBLE_MEMBER_FROM_INLINE!>Z<!>(<!USAGE_IS_NOT_INLINABLE!>s<!>)
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
|
||||
fun Function1<Int, Unit>.noInlineExt(p: Int) {}
|
||||
|
||||
inline fun Function1<Int, Unit>.inlineExt2(p: Int) {
|
||||
<!USAGE_IS_NOT_INLINABLE!>noInlineExt<!>(11)
|
||||
<!USAGE_IS_NOT_INLINABLE!>this<!>.noInlineExt(11)
|
||||
<!USAGE_IS_NOT_INLINABLE!>this<!> noInlineExt 11
|
||||
<!USAGE_IS_NOT_INLINABLE!>this<!>
|
||||
}
|
||||
|
||||
inline fun Function1<Int, Unit>.inlineExt() {
|
||||
inlineExt2(1)
|
||||
this.inlineExt2(1)
|
||||
this inlineExt2 1
|
||||
}
|
||||
|
||||
inline fun testExtension(s: (p: Int) -> Unit) {
|
||||
s.inlineExt()
|
||||
}
|
||||
|
||||
inline fun inlineFunWrongExtension(s: (p: Int) -> Unit) {
|
||||
<!USAGE_IS_NOT_INLINABLE!>s<!>.noInlineExt(11)
|
||||
}
|
||||
|
||||
inline fun inlineFunNoInline(noinline s: (p: Int) -> Unit) {
|
||||
s.noInlineExt(11)
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -UNNECESSARY_NOT_NULL_ASSERTION -UNNECESSARY_SAFE_CALL
|
||||
|
||||
fun getFun(s: (p: Int) -> Unit): Function1<Int, Int> = {11}
|
||||
|
||||
inline fun getInlineFun(s: (p: Int) -> Unit): Function1<Int, Int> = {11}
|
||||
|
||||
inline fun testExtension(s: (p: Int) -> Unit) {
|
||||
getFun(<!USAGE_IS_NOT_INLINABLE!>s<!>).invoke(10)
|
||||
getInlineFun(s).invoke(10)
|
||||
getInlineFun(s)!!.invoke(10)
|
||||
getInlineFun(s)?.invoke(10)
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
|
||||
inline fun inlineFunWithInvoke(s: (p: Int) -> Unit, ext: Int.(p: Int) -> Unit) {
|
||||
s(11)
|
||||
s.invoke(11)
|
||||
s invoke 11
|
||||
|
||||
11.ext(11)
|
||||
11 ext 11
|
||||
}
|
||||
|
||||
inline fun inlineFunWithInvokeNonInline(noinline s: (p: Int) -> Unit, ext: Int.(p: Int) -> Unit) {
|
||||
s(11)
|
||||
s.invoke(11)
|
||||
s invoke 11
|
||||
|
||||
11.ext(11)
|
||||
11 ext 11
|
||||
}
|
||||
|
||||
inline fun Function1<Int, Unit>.inlineExt() {
|
||||
invoke(11)
|
||||
this.invoke(11)
|
||||
this invoke 11
|
||||
this(11)
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
|
||||
inline fun inlineFunWithInvoke(s: (p: Int) -> Unit, ext: Int.(p: Int) -> Unit) {
|
||||
subInline(s, ext)
|
||||
subNoInline(<!USAGE_IS_NOT_INLINABLE!>s<!>, <!USAGE_IS_NOT_INLINABLE!>ext<!>)
|
||||
}
|
||||
|
||||
inline fun inlineFunWithInvokeClosure(s: (p: Int) -> Unit, ext: Int.(p: Int) -> Unit) {
|
||||
subInline({(p: Int) -> s(p)}, {Int.(p:Int) -> this.ext(p)})
|
||||
subNoInline({(p: Int) -> s(p)}, {Int.(p:Int) -> this.ext(p)})
|
||||
}
|
||||
|
||||
//No inline
|
||||
inline fun inlineFunWithInvokeNonInline(noinline s: (p: Int) -> Unit, noinline ext: Int.(p: Int) -> Unit) {
|
||||
subInline(s, ext)
|
||||
subNoInline(s, ext)
|
||||
}
|
||||
|
||||
inline fun inlineFunWithInvokeClosureNoinline(noinline s: (p: Int) -> Unit, noinline ext: Int.(p: Int) -> Unit) {
|
||||
subInline({(p: Int) -> s(p)}, {Int.(p:Int) -> this.ext(p)})
|
||||
subNoInline({(p: Int) -> s(p)}, {Int.(p:Int) -> this.ext(p)})
|
||||
}
|
||||
|
||||
//ext function
|
||||
inline fun Function1<Int, Unit>.inlineExt(ext: Int.(p: Int) -> Unit) {
|
||||
subInline(this, ext)
|
||||
subNoInline(<!USAGE_IS_NOT_INLINABLE!>this<!>, <!USAGE_IS_NOT_INLINABLE!>ext<!>)
|
||||
}
|
||||
|
||||
inline fun Function1<Int, Unit>.inlineExtWithClosure(ext: Int.(p: Int) -> Unit) {
|
||||
subInline({(p: Int) -> this(p)}, {Int.(p:Int) -> this.ext(p)})
|
||||
subNoInline({(p: Int) -> this(p)}, {Int.(p:Int) -> this.ext(p)})
|
||||
}
|
||||
|
||||
inline fun subInline(s: (p: Int) -> Unit, ext: Int.(p: Int) -> Unit) {}
|
||||
|
||||
fun subNoInline(s: (p: Int) -> Unit, ext: Int.(p: Int) -> Unit) {}
|
||||
@@ -0,0 +1,20 @@
|
||||
inline fun inlineFun(s: (p: Int) -> Unit) : (p: Int) -> Unit {
|
||||
return <!USAGE_IS_NOT_INLINABLE!>s<!>
|
||||
}
|
||||
|
||||
inline fun inlineFun2(s: (p: Int) -> Unit) : (p: Int) -> Unit = <!USAGE_IS_NOT_INLINABLE!>s<!>
|
||||
|
||||
|
||||
inline fun inlineFunWithExt(ext: Int.(p: Int) -> Unit) : Int.(p: Int) -> Unit {
|
||||
return <!USAGE_IS_NOT_INLINABLE!>ext<!>
|
||||
}
|
||||
|
||||
inline fun inlineFunWithExt2(ext: Int.(p: Int) -> Unit) : Int.(p: Int) -> Unit = <!USAGE_IS_NOT_INLINABLE!>ext<!>
|
||||
|
||||
|
||||
|
||||
inline fun Function1<Int, Unit>.inlineExt(): Function1<Int, Unit> {
|
||||
return <!USAGE_IS_NOT_INLINABLE!>this<!>
|
||||
}
|
||||
|
||||
inline fun Function1<Int, Unit>.inlineExt2(): Function1<Int, Unit> = <!USAGE_IS_NOT_INLINABLE!>this<!>
|
||||
@@ -0,0 +1,26 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
|
||||
inline fun unsupported() {
|
||||
|
||||
<!NOT_YET_SUPPORTED_IN_INLINE!>class A {
|
||||
fun a() {
|
||||
class AInner {}
|
||||
}
|
||||
}<!>
|
||||
|
||||
<!NOT_YET_SUPPORTED_IN_INLINE!>object B{
|
||||
object BInner {}
|
||||
}<!>
|
||||
|
||||
val s = <!NOT_YET_SUPPORTED_IN_INLINE!>object {
|
||||
fun a() {
|
||||
val sInner = object {
|
||||
fun aInner() {}
|
||||
}
|
||||
}
|
||||
}<!>
|
||||
|
||||
<!NOT_YET_SUPPORTED_IN_INLINE!>fun local() {
|
||||
fun localInner() {}
|
||||
}<!>
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE
|
||||
|
||||
inline fun inlineFunWrongUsage(s: (p: Int) -> Unit) {
|
||||
<!USAGE_IS_NOT_INLINABLE!>s<!>
|
||||
|
||||
if (true) <!USAGE_IS_NOT_INLINABLE!>s<!> else 0
|
||||
|
||||
var c = <!USAGE_IS_NOT_INLINABLE!>s<!>
|
||||
c = <!USAGE_IS_NOT_INLINABLE!>s<!>
|
||||
}
|
||||
|
||||
inline fun inlineFunWrongUsageExt(ext: Int.(p: Int) -> Unit) {
|
||||
<!USAGE_IS_NOT_INLINABLE!>ext<!>
|
||||
|
||||
if (true) <!USAGE_IS_NOT_INLINABLE!>ext<!> else 0
|
||||
|
||||
var c = <!USAGE_IS_NOT_INLINABLE!>ext<!>
|
||||
c = <!USAGE_IS_NOT_INLINABLE!>ext<!>
|
||||
}
|
||||
|
||||
inline fun inlineFunWrongUsageInClosure(s: (p: Int) -> Unit) {
|
||||
{
|
||||
<!USAGE_IS_NOT_INLINABLE!>s<!>
|
||||
|
||||
if (true) <!USAGE_IS_NOT_INLINABLE!>s<!> else 0
|
||||
|
||||
var c = <!USAGE_IS_NOT_INLINABLE!>s<!>
|
||||
c = <!USAGE_IS_NOT_INLINABLE!>s<!>
|
||||
}()
|
||||
}
|
||||
|
||||
inline fun inlineFunWrongUsageInClosureExt(ext: Int.(p: Int) -> Unit) {
|
||||
{
|
||||
<!USAGE_IS_NOT_INLINABLE!>ext<!>
|
||||
|
||||
if (true) <!USAGE_IS_NOT_INLINABLE!>ext<!> else 0
|
||||
|
||||
var c = <!USAGE_IS_NOT_INLINABLE!>ext<!>
|
||||
c = <!USAGE_IS_NOT_INLINABLE!>ext<!>
|
||||
}()
|
||||
}
|
||||
|
||||
inline fun inlineFunNoInline(noinline s: (p: Int) -> Unit) {
|
||||
s
|
||||
if (true) s else 0
|
||||
var c = s
|
||||
c = s
|
||||
}
|
||||
|
||||
inline fun inlineFunNoInline(noinline ext: Int.(p: Int) -> Unit) {
|
||||
ext
|
||||
if (true) ext else 0
|
||||
var c = ext
|
||||
c = ext
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -UNNECESSARY_SAFE_CALL -UNNECESSARY_NOT_NULL_ASSERTION
|
||||
|
||||
public inline fun assertNot(message: String, block: ()-> Boolean) {}
|
||||
|
||||
public inline fun assertNot(block: ()-> Boolean) : Unit = assertNot(<!USAGE_IS_NOT_INLINABLE!>block<!>.toString(), block)
|
||||
|
||||
|
||||
public fun <T> callable(action: ()-> T) {
|
||||
|
||||
}
|
||||
|
||||
public inline fun <T> String.submit(action: ()->T) {
|
||||
callable(<!USAGE_IS_NOT_INLINABLE!>action<!>)
|
||||
}
|
||||
|
||||
public inline fun <T> Function1<Int, Int>.submit() {
|
||||
<!USAGE_IS_NOT_INLINABLE!>this<!>?.invoke(11)
|
||||
<!USAGE_IS_NOT_INLINABLE, USAGE_IS_NOT_INLINABLE!>this<!>!!.invoke(11)
|
||||
}
|
||||
|
||||
public inline fun <T> submit(action: Function1<Int, Int>) {
|
||||
<!USAGE_IS_NOT_INLINABLE!>action<!>?.invoke(10)
|
||||
<!USAGE_IS_NOT_INLINABLE, USAGE_IS_NOT_INLINABLE!>action<!>!!.invoke(10)
|
||||
}
|
||||
Reference in New Issue
Block a user