FE: forbid extension calls on inline functional parameters

Extension receivers are currently implicitly noinline, and changing that
would require modifying the syntax to allow marking them noinline or
crossinline.

^KT-5837 Open
^KT-25787 Fixed
^KT-47965 Fixed
^KT-50107 Fixed
^KT-52403 Fixed
This commit is contained in:
pyos
2022-05-19 13:09:52 +02:00
committed by Space
parent efa267bf86
commit fad35b95d4
32 changed files with 59 additions and 356 deletions
@@ -11,18 +11,18 @@ inline operator fun <T, V> @ExtensionFunctionType Function2<T, T, V>.inc() = thi
operator fun <T, V> @ExtensionFunctionType Function2<T, T, V>.dec() = this
inline fun <T, V> inlineFunWithInvoke(s: (p: T) -> V, ext: T.(p: T) -> V) {
+s
<!USAGE_IS_NOT_INLINABLE!>-<!>s
+<!USAGE_IS_NOT_INLINABLE!>s<!>
-<!USAGE_IS_NOT_INLINABLE!>s<!>
<!USAGE_IS_NOT_INLINABLE!>s<!>++
<!USAGE_IS_NOT_INLINABLE!>++<!>s
<!USAGE_IS_NOT_INLINABLE!>++<!><!USAGE_IS_NOT_INLINABLE!>s<!>
<!USAGE_IS_NOT_INLINABLE!>s<!>--
<!USAGE_IS_NOT_INLINABLE, USAGE_IS_NOT_INLINABLE!>--<!>s
+ext
<!USAGE_IS_NOT_INLINABLE!>-<!>ext
<!USAGE_IS_NOT_INLINABLE!>--<!><!USAGE_IS_NOT_INLINABLE!>s<!>
+<!USAGE_IS_NOT_INLINABLE!>ext<!>
-<!USAGE_IS_NOT_INLINABLE!>ext<!>
<!USAGE_IS_NOT_INLINABLE!>ext<!>++
<!USAGE_IS_NOT_INLINABLE!>++<!>ext
<!USAGE_IS_NOT_INLINABLE!>++<!><!USAGE_IS_NOT_INLINABLE!>ext<!>
<!USAGE_IS_NOT_INLINABLE!>ext<!>--
<!USAGE_IS_NOT_INLINABLE, USAGE_IS_NOT_INLINABLE!>--<!>ext
<!USAGE_IS_NOT_INLINABLE!>--<!><!USAGE_IS_NOT_INLINABLE!>ext<!>
}
inline fun <T, V> Function1<T, V>.inlineFunWithInvoke() {
@@ -11,16 +11,16 @@ inline operator fun <T, V> @ExtensionFunctionType Function2<T, T, V>.inc() = thi
operator fun <T, V> @ExtensionFunctionType Function2<T, T, V>.dec() = this
inline fun <T, V> inlineFunWithInvoke(s: (p: T) -> V, ext: T.(p: T) -> V) {
+s
+<!USAGE_IS_NOT_INLINABLE!>s<!>
-<!USAGE_IS_NOT_INLINABLE!>s<!>
s++
++s
<!USAGE_IS_NOT_INLINABLE!>s<!>++
++<!USAGE_IS_NOT_INLINABLE!>s<!>
<!USAGE_IS_NOT_INLINABLE!>s<!>--
--<!USAGE_IS_NOT_INLINABLE!>s<!>
+ext
+<!USAGE_IS_NOT_INLINABLE!>ext<!>
-<!USAGE_IS_NOT_INLINABLE!>ext<!>
ext++
++ext
<!USAGE_IS_NOT_INLINABLE!>ext<!>++
++<!USAGE_IS_NOT_INLINABLE!>ext<!>
<!USAGE_IS_NOT_INLINABLE!>ext<!>--
--<!USAGE_IS_NOT_INLINABLE!>ext<!>
}
@@ -1,21 +0,0 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -RECURSION_IN_INLINE
inline operator fun <T, V> Function1<T, V>.not() : Boolean {
return !this
}
inline fun <T, V> inlineFunWithInvoke(s: (p: T) -> V) {
!s
}
operator fun <T, U, V> Function2<T, U, V>.not() : Boolean {
return !this
}
operator fun <T, U, V, W> @ExtensionFunctionType Function3<T, U, V, W>.not() : Boolean {
return !this
}
inline fun <T, U, V> inlineFunWithInvoke(s: (p: T, l: U) -> V, ext: T.(p: T, l : U) -> V) {
<!USAGE_IS_NOT_INLINABLE!>!<!>s
<!USAGE_IS_NOT_INLINABLE!>!<!>ext
}
@@ -1,10 +1,11 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -RECURSION_IN_INLINE
inline operator fun <T, V> Function1<T, V>.not() : Boolean {
return !this
}
inline fun <T, V> inlineFunWithInvoke(s: (p: T) -> V) {
!s
!<!USAGE_IS_NOT_INLINABLE!>s<!>
}
operator fun <T, U, V> Function2<T, U, V>.not() : Boolean {