Introduce warning for private inline functions which return anonymous objects without specified supertypes (KT-33917)

This commit is contained in:
Victor Petukhov
2020-09-25 13:59:24 +03:00
parent 63d825fa24
commit 09f1764f82
11 changed files with 83 additions and 1 deletions
@@ -0,0 +1,11 @@
private inline fun foo(crossinline f: () -> Int) = object {
fun bar(): Int = f()
}
fun test(b: Boolean) {
var x = foo { 1 }
if (b) {
x = foo { 2 }
}
x.bar()
}
@@ -0,0 +1,11 @@
private inline fun <!PRIVATE_INLINE_FUNCTIONS_RETURNING_ANONYMOUS_OBJECTS!>foo<!>(crossinline f: () -> Int) = object {
fun bar(): Int = f()
}
fun test(b: Boolean) {
var x = foo { 1 }
if (b) {
x = foo { 2 }
}
x.bar()
}
@@ -0,0 +1,4 @@
package
private inline fun foo(/*0*/ crossinline f: () -> kotlin.Int): foo.<no name provided>
public fun test(/*0*/ b: kotlin.Boolean): kotlin.Unit