[FIR] Add inline checker for bodies of inline functions

This checker doesn't support `@PublishedAPI` yet, so some BB tests for it
 were muted. #KT-46270
This commit is contained in:
Dmitriy Novozhilov
2021-04-23 10:15:36 +03:00
committed by TeamCityServer
parent 7e052c1eb1
commit 32c3f85679
95 changed files with 804 additions and 543 deletions
@@ -1,17 +0,0 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -TYPE_MISMATCH
inline fun inlineFunWithInvoke(s: (p: Int) -> Unit, ext: Int.(p: Int) -> Unit) {
s && ext
s || s
}
inline fun inlineFunWithInvokeNonInline(noinline s: (p: Int) -> Unit, ext: Int.(p: Int) -> Unit) {
s && ext
s || s
}
inline fun Function1<Int, Unit>.inlineExt() {
invoke(11)
this && this
this || this
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -TYPE_MISMATCH
inline fun inlineFunWithInvoke(s: (p: Int) -> Unit, ext: Int.(p: Int) -> Unit) {
@@ -14,4 +15,4 @@ inline fun Function1<Int, Unit>.inlineExt() {
invoke(11)
this && this
this || this
}
}
@@ -17,6 +17,6 @@ operator fun <T, U, V, W> @ExtensionFunctionType Function3<T, U, V, W>.get(index
}
inline fun <T, U, V, W> inlineFunWithInvoke(s: (p: T, l: U) -> V, ext: T.(p: U, l: V) -> W) {
s[1]
ext[1]
<!USAGE_IS_NOT_INLINABLE!>s[1]<!>
<!USAGE_IS_NOT_INLINABLE!>ext[1]<!>
}
@@ -8,8 +8,8 @@ inline operator fun <T, U> Function1<T, U>.modAssign(p: Function1<T, U>) = {
}
inline operator fun <T, U> Function1<T, U>.plusAssign(p: Function1<T, U>) {
this -= p
p -= this
this -= <!USAGE_IS_NOT_INLINABLE!>p<!>
p <!USAGE_IS_NOT_INLINABLE!>-=<!> this
}
operator fun <T, U, V> @ExtensionFunctionType Function2<T, U, V>.minusAssign(ext : @ExtensionFunctionType Function2<T, U, V>) {}
@@ -20,11 +20,11 @@ inline operator fun <T, U, V> @ExtensionFunctionType Function2<T, U, V>.modAssig
}
inline operator fun <T, U, V> @ExtensionFunctionType Function2<T, U, V>.plusAssign(ext : @ExtensionFunctionType Function2<T, U, V>) {
this -= ext
ext -= this
this -= <!USAGE_IS_NOT_INLINABLE!>ext<!>
ext <!USAGE_IS_NOT_INLINABLE!>-=<!> this
}
inline fun <T, U, V> inlineFunWithInvoke(s: (p: T) -> U, ext: T.(p: U) -> V) {
s += s
ext += ext
}
}
@@ -14,13 +14,13 @@ operator fun <T, U, V> Function2<T, U, V>.compareTo(index : Function2<T, U, V>)
operator fun <T, U, V, W> @ExtensionFunctionType Function3<T, U, V, W>.compareTo(index : @ExtensionFunctionType Function3<T, U, V, W>) = 1
inline fun <T, U, V, W> inlineFunWithInvoke(s: (p: T, l: U) -> V, ext: T.(p: U, l: V) -> W) {
s < s
s <= s
s > s
s >= s
s <!USAGE_IS_NOT_INLINABLE!><<!> <!USAGE_IS_NOT_INLINABLE!>s<!>
s <!USAGE_IS_NOT_INLINABLE!><=<!> <!USAGE_IS_NOT_INLINABLE!>s<!>
s <!USAGE_IS_NOT_INLINABLE!>><!> <!USAGE_IS_NOT_INLINABLE!>s<!>
s <!USAGE_IS_NOT_INLINABLE!>>=<!> <!USAGE_IS_NOT_INLINABLE!>s<!>
ext < ext
ext > ext
ext <= ext
ext >= ext
ext <!USAGE_IS_NOT_INLINABLE!><<!> <!USAGE_IS_NOT_INLINABLE!>ext<!>
ext <!USAGE_IS_NOT_INLINABLE!>><!> <!USAGE_IS_NOT_INLINABLE!>ext<!>
ext <!USAGE_IS_NOT_INLINABLE!><=<!> <!USAGE_IS_NOT_INLINABLE!>ext<!>
ext <!USAGE_IS_NOT_INLINABLE!>>=<!> <!USAGE_IS_NOT_INLINABLE!>ext<!>
}
@@ -3,7 +3,7 @@ inline operator fun <T, U> Function1<T, U>.component1() = 1
inline operator fun <T, U> Function1<T, U>.component2() = 2
inline fun <T, U, V> inlineFunWithInvoke(s: (p: T) -> U) {
val (d1, e1) = s
val (d1, e1) = <!USAGE_IS_NOT_INLINABLE!>s<!>
}
operator fun <T, U, V> Function2<T, U, V>.component1() = 1
@@ -13,6 +13,6 @@ operator fun <T, U, V, W> @ExtensionFunctionType Function3<T, U, V, W>.component
operator fun <T, U, V, W> @ExtensionFunctionType Function3<T, U, V, W>.component2() = 2
inline fun <T, U, V, W> inlineFunWithInvoke(s: (p: T, l: U) -> V, ext: T.(p: U, l: V) -> W) {
val (d1, e1) = s
val (d2, e2) = ext
val (d1, e1) = <!USAGE_IS_NOT_INLINABLE!>s<!>
val (d2, e2) = <!USAGE_IS_NOT_INLINABLE!>ext<!>
}
@@ -16,9 +16,9 @@ operator fun <T, U, V> Function2<T, U, V>.contains(p: Function2<T, U, V>): Boole
operator fun <T, U, V, W> @ExtensionFunctionType Function3<T, U, V, W>.contains(ext: @ExtensionFunctionType Function3<T, U, V, W>): Boolean = false
inline fun <T, U, V> inlineFunWithInvoke(s: (p: T, l: U) -> U, ext: T.(p: U, l: U) -> V) {
s in s
s !in s
<!USAGE_IS_NOT_INLINABLE!>s<!> <!USAGE_IS_NOT_INLINABLE!>in<!> s
<!USAGE_IS_NOT_INLINABLE!>s<!> <!USAGE_IS_NOT_INLINABLE!>!in<!> s
ext in ext
ext !in ext
<!USAGE_IS_NOT_INLINABLE!>ext<!> <!USAGE_IS_NOT_INLINABLE!>in<!> ext
<!USAGE_IS_NOT_INLINABLE!>ext<!> <!USAGE_IS_NOT_INLINABLE!>!in<!> ext
}
@@ -1,34 +0,0 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -CONFLICTING_JVM_DECLARATIONS -CONFLICTING_OVERLOADS
operator fun <T, U> Function1<T, U>.minus(p: Function1<T, U>) {
}
operator fun <T, U, V> @ExtensionFunctionType Function2<T, U, V>.minus(p: T.(p: U) -> V) {
}
inline operator fun <T, U> Function1<T, U>.plus(p: Function1<T, U>) {
this - p
}
inline operator fun <T, U, V> @ExtensionFunctionType Function2<T, U, V>.plus(p: T.(p: U) -> V) {
this - p
}
inline fun <T, U, V> inlineFunWithInvoke(s: (p: T) -> U, ext: T.(p: U) -> V) {
s + s
ext + ext
}
inline fun <T, U, V> inlineFunWithInvoke(s: (p: T) -> U, ext: T.(p: U) -> V) {
s + s
ext + ext
}
inline fun <T, U> Function1<T, U>.submit() {
this + this
}
inline fun <T, U, V> @ExtensionFunctionType Function2<T, U, V>.submit() {
this + this
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -CONFLICTING_JVM_DECLARATIONS -CONFLICTING_OVERLOADS
operator fun <T, U> Function1<T, U>.minus(p: Function1<T, U>) {
@@ -21,9 +21,9 @@ operator fun <T, U, V, W> @ExtensionFunctionType Function3<T, U, V, W>.rangeTo(e
}
inline fun <T, U, V> inlineFunWithInvoke(s: (p: T, l: U) -> U, ext: T.(p: U, l: U) -> V) {
s..s
s..s
s<!USAGE_IS_NOT_INLINABLE!>..<!><!USAGE_IS_NOT_INLINABLE!>s<!>
s<!USAGE_IS_NOT_INLINABLE!>..<!><!USAGE_IS_NOT_INLINABLE!>s<!>
ext..ext
ext..ext
ext<!USAGE_IS_NOT_INLINABLE!>..<!><!USAGE_IS_NOT_INLINABLE!>ext<!>
ext<!USAGE_IS_NOT_INLINABLE!>..<!><!USAGE_IS_NOT_INLINABLE!>ext<!>
}