[FIR-TEST] Add new testdata generated after changes in previous commit

This commit is contained in:
Dmitriy Novozhilov
2019-12-11 16:16:22 +03:00
parent e9c02a1cca
commit 2536fa0cd5
4578 changed files with 104067 additions and 1 deletions
@@ -0,0 +1,12 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -NON_LOCAL_RETURN_NOT_ALLOWED
inline fun <R> inlineFun(p: () -> R) {
val s = object {
val z = p()
fun a() {
p()
}
}
}
@@ -0,0 +1,14 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE
inline fun inlineFunWithInvoke(s: (p: Int) -> Unit, ext: Int.(p: Int) -> Unit) {
var d = s
d = s
var e = ext
e = ext
}
inline fun Function1<Int, Unit>.inlineExt() {
var d = this
d = this
}
@@ -0,0 +1,17 @@
// !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
}
@@ -0,0 +1,22 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE
operator inline fun <T, U> Function1<T, U>.get(index : Int) {
}
inline fun <T, U, V> inlineFunWithInvoke(s: (p: T) -> U) {
s[1]
}
//noinline
operator fun <T, U, V> Function2<T, U, V>.get(index : Int) {
}
operator fun <T, U, V, W> @ExtensionFunctionType Function3<T, U, V, W>.get(index : Int) {
}
inline fun <T, U, V, W> inlineFunWithInvoke(s: (p: T, l: U) -> V, ext: T.(p: U, l: V) -> W) {
s[1]
ext[1]
}
@@ -0,0 +1,30 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -NON_LOCAL_RETURN_NOT_ALLOWED
operator fun <T, U> Function1<T, U>.minusAssign(p: Function1<T, U>) {}
inline operator fun <T, U> Function1<T, U>.modAssign(p: Function1<T, U>) = {
this += p
p += this
}
inline operator fun <T, U> Function1<T, U>.plusAssign(p: Function1<T, U>) {
this -= p
p -= this
}
operator fun <T, U, V> @ExtensionFunctionType Function2<T, U, V>.minusAssign(ext : @ExtensionFunctionType Function2<T, U, V>) {}
inline operator fun <T, U, V> @ExtensionFunctionType Function2<T, U, V>.modAssign(ext : @ExtensionFunctionType Function2<T, U, V>) = {
this += ext
ext += this
}
inline operator fun <T, U, V> @ExtensionFunctionType Function2<T, U, V>.plusAssign(ext : @ExtensionFunctionType Function2<T, U, V>) {
this -= ext
ext -= this
}
inline fun <T, U, V> inlineFunWithInvoke(s: (p: T) -> U, ext: T.(p: U) -> V) {
s += s
ext += ext
}
@@ -0,0 +1,26 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE
inline operator fun <T, U> Function1<T, U>.compareTo(p: Function1<T, U>) = 1
inline fun <T, U, V> inlineFunWithInvoke(s: (p: T) -> U) {
s < s
s <= s
s > s
s >= s
}
//noinline
operator fun <T, U, V> Function2<T, U, V>.compareTo(index : Function2<T, U, V>) = 1
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
ext < ext
ext > ext
ext <= ext
ext >= ext
}
@@ -0,0 +1,18 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE
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
}
operator fun <T, U, V> Function2<T, U, V>.component1() = 1
operator fun <T, U, V> Function2<T, U, V>.component2() = 2
operator fun <T, U, V, W> @ExtensionFunctionType Function3<T, U, V, W>.component1() = 1
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
}
@@ -0,0 +1,24 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -RECURSION_IN_INLINE
operator inline fun <T, U> Function1<T, U>.contains(p: Function1<T, U>): Boolean {
this in p
p in this
return false
}
inline fun <T, U, V> inlineFunWithInvoke(s: (p: T) -> U) {
s in s
s !in s
}
operator fun <T, U, V> Function2<T, U, V>.contains(p: Function2<T, U, V>): Boolean = false
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
ext in ext
ext !in ext
}
@@ -0,0 +1,34 @@
// !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
}
@@ -0,0 +1,29 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -RECURSION_IN_INLINE
inline operator fun <T, U> Function1<T, U>.rangeTo(p: Function1<T, U>): ClosedRange<Int> {
this..p
p..this
return 1..2
}
inline fun <T, U, V> inlineFunWithInvoke(s: (p: T) -> U) {
s..s
s..s
}
operator fun <T, U, V> Function2<T, U, V>.rangeTo(p: Function2<T, U, V>): ClosedRange<Int> {
return 1..2
}
operator fun <T, U, V, W> @ExtensionFunctionType Function3<T, U, V, W>.rangeTo(ext: @ExtensionFunctionType Function3<T, U, V, W>): ClosedRange<Int> {
return 1..2
}
inline fun <T, U, V> inlineFunWithInvoke(s: (p: T, l: U) -> U, ext: T.(p: U, l: U) -> V) {
s..s
s..s
ext..ext
ext..ext
}
@@ -0,0 +1,51 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -NON_LOCAL_RETURN_NOT_ALLOWED
infix fun Function1<Int, Unit>.noInlineExt(p: Int) {}
inline infix fun Function1<Int, Unit>.inlineExt2(p: Int) {
<!UNRESOLVED_REFERENCE!>{
noInlineExt(11)
this.noInlineExt(11)
this noInlineExt 11
this
}()<!>
}
inline fun Function1<Int, Unit>.inlineExt() {
<!UNRESOLVED_REFERENCE!>{
inlineExt2(1)
this.inlineExt2(1)
this inlineExt2 1
this(11)
}()<!>
}
inline fun inlineFunWithInvoke(s: (p: Int) -> Unit) {
<!UNRESOLVED_REFERENCE!>{
s(11)
s.invoke(11)
s invoke 11
}()<!>
}
inline fun inlineFunWithInvokeNonInline(noinline s: (p: Int) -> Unit) {
<!UNRESOLVED_REFERENCE!>{
s(11)
s.invoke(11)
s invoke 11
}()<!>
}
inline fun testExtension(s: (p: Int) -> Unit) {
<!UNRESOLVED_REFERENCE!>{
s.inlineExt()
} ()<!>
}
inline fun inlineFunWrongExtension(s: (p: Int) -> Unit) {
<!UNRESOLVED_REFERENCE!>{
s.noInlineExt(11)
} ()<!>
}
@@ -0,0 +1,7 @@
class Z(s: (Int) -> Int) {
}
public inline fun test(s : (Int) -> Int) {
Z(s)
}
@@ -0,0 +1,15 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE
inline fun default(s : Int = 10) {
}
inline fun default2(p: Int, s : String = "OK") {
}
open class Base {
inline final fun foo(a: Int = 1) {}
inline final fun foo2(a: Int = 1, s: String = "OK") {}
}
@@ -0,0 +1,48 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE
// !LANGUAGE: -InlineDefaultFunctionalParameters
fun test() = "OK"
val prop = "OK"
class Foo {
fun test() = "OK"
val prop = "OK"
}
object FooObject {
fun test() = "OK"
val prop = "OK"
}
inline fun default1(s : () -> String = { "OK" }) {}
inline fun default2(s : () -> String = ::test) {}
inline fun default3(s : () -> String = ::prop) {}
inline fun default4(s : () -> String = FooObject::test) {}
inline fun default5(s : () -> String = FooObject::prop) {}
inline fun default6(s : (a: Foo) -> String = Foo::test) {}
inline fun default7(s : (a: Foo) -> String = Foo::prop) {}
val a = Foo()
inline fun default8(s : () -> String = a::test) {}
inline fun default9(s : () -> String = a::prop) {}
inline fun default10(s : () -> String = object : Function0<String> {
override fun invoke(): String {
return "FAIL"
}
}) {}
abstract class Base {
abstract fun foo(f: () -> Unit = { })
}
class Derived : Base() {
override final inline fun foo(f: () -> Unit) {
f()
}
}
inline fun default11(s : () -> Derived = ::Derived) {}
@@ -0,0 +1,10 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE -NOTHING_TO_INLINE
// SKIP_TXT
suspend inline fun test1(s : suspend () -> String = { "OK" }) {}
suspend inline fun test2(s : () -> String = { "OK" }) {}
suspend inline fun test3(crossinline s : suspend () -> String = { "OK" }) {}
suspend inline fun test4(crossinline s : () -> String = { "OK" }) {}
suspend inline fun test5(noinline s : suspend () -> String = { "OK" }) {}
suspend inline fun test6(noinline s : () -> String = { "OK" }) {}
@@ -0,0 +1,47 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE
// !LANGUAGE: +InlineDefaultFunctionalParameters
fun test() = "OK"
val prop = "OK"
class Foo {
fun test() = "OK"
val prop = "OK"
}
object FooObject {
fun test() = "OK"
val prop = "OK"
}
inline fun default1(s : () -> String = {"OK"}) {}
inline fun default2(s : () -> String = ::test) {}
inline fun default3(s : () -> String = ::prop) {}
inline fun default4(s : () -> String = FooObject::test) {}
inline fun default5(s : () -> String = FooObject::prop) {}
inline fun default6(s : (a: Foo) -> String = Foo::test) {}
inline fun default7(s : (a: Foo) -> String = Foo::prop) {}
val a = Foo()
inline fun default8(s : () -> String = a::test) {}
inline fun default9(s : () -> String = a::prop) {}
inline fun default10(s : () -> String = object : Function0<String> {
override fun invoke(): String {
return "FAIL"
}
}) {}
abstract class Base {
abstract fun foo(f: () -> Unit = { })
}
class Derived : Base() {
override final inline fun foo(f: () -> Unit) {
f()
}
}
inline fun default11(s : () -> Derived = ::Derived) {}
@@ -0,0 +1,28 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE
infix fun Function1<Int, Unit>.noInlineExt(p: Int) {}
inline infix fun Function1<Int, Unit>.inlineExt2(p: Int) {
noInlineExt(11)
this.noInlineExt(11)
this noInlineExt 11
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) {
s.noInlineExt(11)
}
inline fun inlineFunNoInline(noinline s: (p: Int) -> Unit) {
s.noInlineExt(11)
}
@@ -0,0 +1,7 @@
inline fun <R> onlyLocal(p: () -> R) {
inlineAll(p)
}
inline fun <R> inlineAll(noinline p: () -> R) {
p()
}
@@ -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(s).invoke(10)
getInlineFun(s).invoke(10)
getInlineFun(s)!!.invoke(10)
getInlineFun(s)?.invoke(10)
}
@@ -0,0 +1,58 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE
// !LANGUAGE: +InlineDefaultFunctionalParameters
inline fun inlineFun(lambda: () -> String) = lambda()
fun noInlineFun(lambda: () -> String) = lambda()
inline fun default0_1(lambda: () -> String, dlambda: () -> String = { lambda; "OK" }) {
lambda() + dlambda()
}
inline fun default0_2(lambda: () -> String, dlambda: () -> String = { noInlineFun (lambda) }) {
lambda() + dlambda()
}
inline fun default0(lambda: () -> String, dlambda: () -> String = { noInlineFun (lambda) }) {
lambda() + dlambda()
}
inline fun default1_0(lambda: () -> String, dlambda: () -> String = { lambda() }) {
lambda() + dlambda()
}
inline fun default1_1(lambda: () -> String, noinline dlambda: () -> String = { lambda() }) {
lambda() + dlambda()
}
inline fun default1_1crossinline(crossinline lambda: () -> String, noinline dlambda: () -> String = { lambda() }) {
lambda() + dlambda()
}
inline fun default1_2(noinline lambda: () -> String, dlambda: () -> String = { lambda() }) {
lambda() + dlambda()
}
inline fun default1_3(noinline lambda: () -> String, noinline dlambda: () -> String = { lambda() }) {
lambda() + dlambda()
}
inline fun default2_1(lambda: () -> String, noinline dlambda: () -> String = { inlineFun(lambda) }) {
lambda() + dlambda()
}
inline fun default2_1crossinline(crossinline lambda: () -> String, noinline dlambda: () -> String = { inlineFun(lambda) }) {
lambda() + dlambda()
}
inline fun default2_2(noinline lambda: () -> String, dlambda: () -> String = { inlineFun(lambda) }) {
lambda() + dlambda()
}
inline fun default2_3(noinline lambda: () -> String, noinline dlambda: () -> String = { inlineFun(lambda) }) {
lambda() + dlambda()
}
@@ -0,0 +1,61 @@
// !WITH_NEW_INFERENCE
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE
// !LANGUAGE: -InlineDefaultFunctionalParameters
inline fun inlineFun(lambda: () -> String) = lambda()
fun noInlineFun(lambda: () -> String) = lambda()
inline fun default0_1(lambda: () -> String, dlambda: () -> String = { lambda }) {
lambda() + dlambda()
}
inline fun default0_2(lambda: () -> String, dlambda: () -> String = { noInlineFun (lambda) }) {
lambda() + dlambda()
}
inline fun default1_0(lambda: () -> String, dlambda: () -> String = { lambda() }) {
lambda() + dlambda()
}
inline fun default1_1(lambda: () -> String, noinline dlambda: () -> String = { lambda() }) {
lambda() + dlambda()
}
inline fun default1_1crossinline(crossinline lambda: () -> String, noinline dlambda: () -> String = { lambda() }) {
lambda() + dlambda()
}
inline fun default1_2(noinline lambda: () -> String, dlambda: () -> String = { lambda() }) {
lambda() + dlambda()
}
inline fun default1_3(noinline lambda: () -> String, noinline dlambda: () -> String = { lambda() }) {
lambda() + dlambda()
}
inline fun default2_0(lambda: () -> String, dlambda: () -> String = { inlineFun(lambda) }) {
lambda() + dlambda()
}
inline fun default2_1(lambda: () -> String, noinline dlambda: () -> String = { inlineFun(lambda) }) {
lambda() + dlambda()
}
inline fun default2_1crossinline(crossinline lambda: () -> String, noinline dlambda: () -> String = { inlineFun(lambda) }) {
lambda() + dlambda()
}
inline fun default2_2(noinline lambda: () -> String, dlambda: () -> String = { inlineFun(lambda) }) {
lambda() + dlambda()
}
inline fun default2_3(noinline lambda: () -> String, noinline dlambda: () -> String = { inlineFun(lambda) }) {
lambda() + dlambda()
}
@@ -0,0 +1,2 @@
inline fun <T1, T2, reified T3, T4> foo(): T3 = null!!
@@ -0,0 +1,26 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE
inline fun inlineFunWithInvoke(s: (p: Int) -> Unit, ext: Int.(p: Int) -> Unit) {
s(11)
s.invoke(11)
s invoke 11
11.<!UNRESOLVED_REFERENCE!>ext<!>(11)
11 <!UNRESOLVED_REFERENCE!>ext<!> 11
}
inline fun inlineFunWithInvokeNonInline(noinline s: (p: Int) -> Unit, ext: Int.(p: Int) -> Unit) {
s(11)
s.invoke(11)
s invoke 11
11.<!UNRESOLVED_REFERENCE!>ext<!>(11)
11 <!UNRESOLVED_REFERENCE!>ext<!> 11
}
inline fun Function1<Int, Unit>.inlineExt() {
invoke(11)
this.invoke(11)
this invoke 11
this(11)
}
@@ -0,0 +1,10 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION
inline public fun reg(converter: (Any) -> Any, flag: Boolean) {
flag
converter("")
}
public inline fun register(converter: (Any) -> Any) {
converter is (Any) -> Any
reg(converter, converter is (Any) -> Any)
}
@@ -0,0 +1,10 @@
// !WITH_NEW_INFERENCE
// !DIAGNOSTICS: -UNUSED_PARAMETER
open class Foo protected constructor()
inline fun foo(f: () -> Unit) = object: Foo() {}
class A : Foo() {
inline fun foo(f: () -> Unit) = Foo()
}
@@ -0,0 +1,4 @@
inline fun test(s: () -> Unit, p: (() -> Unit)?) {
s()
p?.invoke()
}
@@ -0,0 +1,6 @@
inline fun foo(f: () -> Unit) {
val ff = { f: () -> Unit ->
f.invoke()
}
ff(f)
}
@@ -0,0 +1,40 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
inline fun foo(bar1: (String.() -> Int) -> Int, bar2: (()->Int) -> Int) {
bar1 label@ {
this@label.<!UNRESOLVED_REFERENCE!>length<!>
}
bar1 {
this.<!UNRESOLVED_REFERENCE!>length<!>
}
//unmute after KT-4247 fix
//bar1 {
// this@bar1.length
//}
bar2 l@ {
11
}
bar2 {
12
}
}
inline fun foo2(bar1: (String.() -> Int) -> Int) {
l1@ bar1
l2@ bar1 {
11
}
(l3@ bar1) {
11
}
(l5@ (l4@ bar1)) {
11
}
}
@@ -0,0 +1,9 @@
// !DIAGNOSTICS: -UNCHECKED_CAST -USELESS_CAST
inline public fun reg(convertFunc: (Any) -> Any) {
convertFunc("")
}
public inline fun <reified T : Any, reified R : Any> register(converter: (T) -> R) {
converter as (Any) -> Any
reg(converter as (Any) -> Any)
}
@@ -0,0 +1,4 @@
fun main() {
inline fun a(){
}
}
@@ -0,0 +1,18 @@
inline fun inlineFun() {
fun localFun() {}
class LocalClass {}
}
fun outerFun() {
inline fun localInlineFun() {}
}
abstract class Base {
abstract fun withDefault(f: () -> Unit = { -> })
}
class Derived : Base() {
override final inline fun withDefault(
f: () -> Unit
) {}
}
@@ -0,0 +1,23 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE
inline fun <R> inlineFunOnlyLocal(crossinline p: () -> R) {
val s = object {
val z = p()
fun a() {
p()
}
}
}
inline fun <R> inlineFun(p: () -> R) {
val s = object {
val z = p()
fun a() {
p()
}
}
}
@@ -0,0 +1,48 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE
inline fun <R> inlineFunOnlyLocal(crossinline p: () -> R) {
val s = object {
val z = p();
init {
doCall {
p()
}
}
fun a() {
doCall {
p()
}
p()
}
}
}
inline fun <R> inlineFun(p: () -> R) {
val s = object {
val z = p()
init {
doCall {
p()
}
}
fun a() {
doCall {
p()
}
p()
}
}
}
inline fun <R> doCall(p: () -> R) {
p()
}
@@ -0,0 +1,41 @@
fun inlineCallExplicitError(): String {
inlineFun lamba@ {
if (true) {
return@lamba 2
}
1
}
return "x"
}
fun inlineCall(): String {
inlineFun lamba@ {
if (true) {
return@lamba 2
}
1
}
return "x"
}
inline fun inlineFun(s: () -> Int) {
s()
}
fun noInlineCall(): String {
noInline lambda@ {
if (true) {
return@lambda 2
}
1
}
return "x"
}
fun noInline(s: () -> Int) {
s()
}
@@ -0,0 +1,8 @@
inline fun <R> onlyLocal(crossinline p: () -> R) {
inlineAll(p)
}
inline fun <R> inlineAll(p: () -> R) {
p()
}
@@ -0,0 +1,16 @@
inline fun <R> inlineFunWithAnnotation(crossinline p: () -> R) {
inlineFun {
p()
}
}
inline fun <R> inlineFun2(p: () -> R) {
inlineFun {
p()
}
}
inline fun <R> inlineFun(p: () -> R) {
p()
}
@@ -0,0 +1,31 @@
fun inlineCall(): String {
inlineFun {
if (true) {
return@inlineCall ""
}
1
}
return "x"
}
inline fun inlineFun(s: ()->Int) {
s()
}
fun noInlineCall(): String {
noInline {
if (true) {
return@noInlineCall ""
}
1
}
return "x"
}
fun noInline(s: ()->Int) {
s()
}
@@ -0,0 +1,13 @@
// !WITH_NEW_INFERENCE
fun box() : String {
test {
return@box "123"
}
return "OK"
}
inline fun <T> test(p: T) {
p.toString()
}
@@ -0,0 +1,11 @@
fun box() : String {
test {
return@box "123"
}
return "OK"
}
inline fun test(p: Any) {
p.toString()
}
@@ -0,0 +1,9 @@
inline fun testSameCaptured(lambdaWithResultCaptured: () -> Unit) : String {
doWork({lambdaWithResultCaptured()})
return "OK"
}
inline fun <R> doWork(crossinline job: ()-> R) : R {
return job()
}
@@ -0,0 +1,15 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE
inline fun <R> inlineFunOnlyLocal(crossinline p: () -> R) {
fun a() {
val z = p()
}
a()
}
inline fun <R> inlineFun(p: () -> R) {
fun a() {
p()
}
a()
}
@@ -0,0 +1,41 @@
import Kind.EXT_RETURN
import Kind.GLOBAL_RETURN
enum class Kind {
LOCAL,
EXT_RETURN,
GLOBAL_RETURN
}
class Internal(val value: String)
class External(val value: String)
class Global(val value: String)
fun test1(intKind: Kind, extKind: Kind): Global {
var externalResult = doCall ext@ {
val internalResult = doCall int@ {
if (intKind == Kind.LOCAL) {
return@test1 Global("internal to global")
} else if (intKind == EXT_RETURN) {
return@ext External("internal to external")
}
return@int Internal("internal to local")
}
if (extKind == GLOBAL_RETURN || extKind == EXT_RETURN) {
return Global("external to global")
}
External(internalResult.value + " to local");
}
return Global(externalResult.value + " to exit")
}
public inline fun <R> doCall(block: ()-> R) : R {
return block()
}
@@ -0,0 +1,10 @@
// !DIAGNOSTICS: -NOTHING_TO_INLINE
fun main() {
test {
return
}
}
inline fun test(noinline lambda: () -> Unit) {
lambda()
}
@@ -0,0 +1,13 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE
inline fun <R> inlineFunOnlyLocal(crossinline p: () -> R) {
<!UNRESOLVED_REFERENCE!>{
p()
}()<!>
}
inline fun <R> inlineFun(p: () -> R) {
<!UNRESOLVED_REFERENCE!>{
p()
}()<!>
}
@@ -0,0 +1,23 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE
inline fun <R> inlineFunOnlyLocal(crossinline p: () -> R) {
class A {
val z = p()
fun a() {
p()
}
}
}
inline fun <R> inlineFun(p: () -> R) {
class A {
val z = p()
fun a() {
p()
}
}
}
@@ -0,0 +1,43 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE
fun <R> fun1(p: () -> R) {
inlineFun {
p()
}
}
fun <R> fun1ValueArgument(p: () -> R) {
inlineFun ({
p()
})
}
fun <R> fun3(p: () -> R) {
inlineFun {
return;
}
}
fun <R> fun3ValueArgument(p: () -> R) {
inlineFun ({
return;
})
}
fun <R> fun4(p: () -> R) {
inlineFun lambda@ {
return@lambda p();
}
}
fun <R> fun4ValueArgument(p: () -> R) {
inlineFun (lambda@ {
return@lambda p();
})
}
inline fun <R> inlineFun(crossinline p: () -> R) {
p()
}
@@ -0,0 +1,25 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE
class Z {
<!INAPPLICABLE_INFIX_MODIFIER!>inline infix fun <R> inlineFun(crossinline p: () -> R) {
p()
}<!>
}
fun <R> fun1(p: () -> R) {
Z() inlineFun {
p()
}
}
fun <R> fun3(p: () -> R) {
Z() inlineFun {
return;
}
}
fun <R> fun4(p: () -> R) {
Z() inlineFun lambda@ {
return@lambda p();
}
}
@@ -0,0 +1,24 @@
inline fun <R> doCall(p: () -> R) {
p()
}
inline fun <R> doCallInt(p: () -> R): R {
return p()
}
class A {
var result: Int = doCallInt { return this };
var field: Int
get() {
doCall { return 1 }
return 2
}
set(v: Int) {
doCall {
result = v / 2
return
}
result = v
}
}
@@ -0,0 +1,8 @@
inline fun <R> toOnlyLocal(crossinline p: () -> R) {
p()
}
inline fun <R> inlineAll(p: () -> R) {
toOnlyLocal(p)
}
@@ -0,0 +1,47 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -PRIVATE_CLASS_MEMBER_FROM_INLINE
private class Z public constructor(){
public val publicProperty:Int = 12
public fun publicFun() {}
}
public inline fun test() {
Z().publicProperty
Z().publicFun()
}
internal inline fun testInternal() {
Z().publicProperty
Z().publicFun()
}
internal class Z2 {
private val privateProperty = 11;
public val publicProperty:Int = 12
private fun privateFun() {}
public fun publicFun() {}
public inline fun test() {
privateProperty
privateFun()
publicProperty
publicFun()
Z2().publicProperty
Z2().publicFun()
Z2().privateProperty
Z2().privateFun()
}
internal inline fun testInternal() {
privateProperty
privateFun()
publicProperty
publicFun()
Z2().publicProperty
Z2().publicFun()
Z2().privateProperty
Z2().privateFun()
}
}
@@ -0,0 +1,36 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE
internal class Z2 {
private val privateProperty = 11;
public val publicProperty:Int = 12
private fun privateFun() {}
public fun publicFun() {}
internal inner class ZInner {
public inline fun test() {
privateProperty
privateFun()
publicFun()
publicProperty
Z2().publicProperty
Z2().publicFun()
Z2().privateProperty
Z2().privateFun()
}
internal inline fun testInternal() {
privateProperty
privateFun()
publicFun()
publicProperty
Z2().publicProperty
Z2().publicFun()
Z2().privateProperty
Z2().privateFun()
}
}
}
@@ -0,0 +1,27 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE
private val privateProperty = 11;
private fun privateFun() {}
internal val internalProperty = 11;
internal fun internalFun() {}
public inline fun test() {
privateFun()
privateProperty
}
public inline fun test2() {
internalFun()
internalProperty
}
internal inline fun testInternal() {
privateFun()
privateProperty
}
internal inline fun test2Internal() {
internalFun()
internalProperty
}
@@ -0,0 +1,37 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE
public class Z {
internal val privateProperty = 11;
internal fun privateFun() {
}
}
public inline fun test() {
Z().privateProperty
Z().privateFun()
}
internal inline fun testInternal() {
Z().privateProperty
Z().privateFun()
}
public class Z2 {
private val privateProperty = 11;
private fun privateFun() {
}
public inline fun test() {
privateProperty
privateFun()
}
internal inline fun testInternal() {
privateProperty
privateFun()
}
}
@@ -0,0 +1,8 @@
inline fun foo() {
<!UNRESOLVED_REFERENCE!>unresolved<!>().<!UNRESOLVED_REFERENCE!>another<!>
<!UNRESOLVED_REFERENCE!>unresolved<!>().<!UNRESOLVED_REFERENCE!>another<!>()
}
fun main() {
foo()
}
@@ -0,0 +1,15 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -NOTHING_TO_INLINE
public class Z {
private val privateProperty = 11;
public fun privateFun() {
class Local {
public inline fun a() {
<!UNRESOLVED_REFERENCE!>privateProperty<!>
}
}
}
}
@@ -0,0 +1,13 @@
public fun test() {
class Z {
public fun localFun() {
}
}
inline fun localFun2() {
Z().localFun()
}
}
@@ -0,0 +1,11 @@
public fun test() {
fun localFun() {
}
inline fun localFun2() {
localFun()
}
}
@@ -0,0 +1,48 @@
// !DIAGNOSTICS: -EXPOSED_PARAMETER_TYPE -NOTHING_TO_INLINE
inline fun call(a: A) {
a.test()
privateFun()
internalFun()
}
@PublishedApi
internal inline fun callFromPublishedApi(a: A) {
a.test()
privateFun()
internalFun()
}
internal class A {
@PublishedApi
internal fun test() {
test()
privateFun()
internalFun()
}
@PublishedApi
internal fun testInline() {
test()
privateFun()
internalFun()
}
}
private fun privateFun() {
}
internal fun internalFun() {
}
@@ -0,0 +1,47 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE
inline private fun a() {}
inline fun b() {}
inline public fun c() {}
abstract class A {
inline private fun good1() {}
inline public final fun good2() {}
inline protected final fun good3() {}
inline final fun good4() {}
inline open protected fun wrong1() {}
inline open public fun wrong2() {}
inline open fun wrong3() {}
inline abstract protected fun wrong4()
inline abstract public fun wrong5()
inline abstract fun wrong6()
}
interface B {
inline private fun good1() {}
inline fun wrong1() {}
inline open fun wrong2() {}
inline open public fun wrong3() {}
inline open fun wrong4() {}
inline fun wrong5()
inline public fun wrong6()
inline fun wrong7()
}
@@ -0,0 +1,29 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NULLABLE_INLINE_PARAMETER -CONFLICTING_JVM_DECLARATIONS
inline fun test() {
}
inline fun test2(s : (Int) -> Int) {
}
inline fun test3(noinline s : (Int) -> Int) {
}
inline fun test4(noinline s : Int.() -> Int) {
}
inline fun Function1<Int, Int>?.test5() {
}
inline fun Function1<Int, Int>?.test6() {
}
inline fun test2(s : ((Int) -> Int)?) {
}
@@ -0,0 +1,16 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNNECESSARY_SAFE_CALL -UNNECESSARY_NOT_NULL_ASSERTION -CONFLICTING_JVM_DECLARATIONS
inline fun String.submit(action: Function1<Int, Int>) {
}
inline fun Function1<Int, Int>.submit() {
this?.invoke(11)
this!!.invoke(11)
submit(this!!)
}
inline fun submit(action: Function1<Int, Int>) {
action?.invoke(10)
action!!.invoke(10)
}
@@ -0,0 +1,21 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -CONFLICTING_JVM_DECLARATIONS
public inline fun <T> Function1<Int, Int>?.submit(action: ()->T) {
this?.invoke(11)
}
public inline fun <T> submit(action: Function1<Int, Int>?, s: () -> Int) {
action?.invoke(10)
}
public inline fun <T> submitNoInline(noinline action: Function1<Int, Int>?, s: () -> Int) {
action?.invoke(10)
}
public inline fun <T> Function1<Int, Int>?.submit() {
}
public inline fun <T> submit(action: Function1<Int, Int>?) {
}
@@ -0,0 +1,60 @@
// !DIAGNOSTICS: -NOTHING_TO_INLINE -UNUSED_PARAMETER
interface IBase {
fun foo()
fun bar()
fun <T> qux(x: T)
}
class CDerived : IBase {
override inline final fun foo() {}
override inline fun bar() {}
override inline final fun <reified T> qux(x: T) {}
class CNested : IBase {
override inline final fun foo() {}
override inline fun bar() {}
override inline final fun <reified T> qux(x: T) {}
}
val anObject = object : IBase {
override inline final fun foo() {}
override inline fun bar() {}
override inline final fun <reified T> qux(x: T) {}
}
fun aMethod() {
class CLocal : IBase {
override inline final fun foo() {}
override inline fun bar() {}
override inline final fun <reified T> qux(x: T) {}
}
}
}
open class COpen : IBase {
override inline final fun foo() {}
override inline fun bar() {}
override inline final fun <reified T> qux(x: T) {}
open class COpenNested : IBase {
override inline final fun foo() {}
override inline fun bar() {}
override inline final fun <reified T> qux(x: T) {}
}
val anObject = object : IBase {
override inline final fun foo() {}
override inline fun bar() {}
override inline final fun <reified T> qux(x: T) {}
}
fun aMethod() {
open class COpenLocal : IBase {
override inline final fun foo() {}
override inline fun bar() {}
override inline final fun <reified T> qux(x: T) {}
}
}
}
@@ -0,0 +1,27 @@
// !CHECK_TYPE
inline fun inlineFunWithInvoke(s: (p: Int) -> Unit) {
(s)(11)
(s).invoke(11)
(s) invoke 11
(s)
}
inline fun Function1<Int, Unit>.inlineExt() {
(this).invoke(11)
(this) invoke 11
(this)(11)
(this)
}
inline fun inlineFunWithInvoke2(s: (p: Int) -> Unit) {
(((s)))(11)
(((s))).invoke(11)
(((s))) invoke 11
(((s)))
}
inline fun propagation(s: (p: Int) -> Unit) {
inlineFunWithInvoke((label@ s))
inlineFunWithInvoke((label2@ label@ s))
}
@@ -0,0 +1,25 @@
// !DIAGNOSTICS: -EXPOSED_PARAMETER_TYPE
private class S public constructor() {
fun a() {
}
}
internal inline fun x(s: S, z: () -> Unit) {
z()
S()
s.a()
test()
}
private inline fun x2(s: S, z: () -> Unit) {
z()
S()
s.a()
test()
}
private fun test(): S {
return S()
}
@@ -0,0 +1,37 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -NON_LOCAL_RETURN_NOT_ALLOWED
inline fun inlineFunWithInvoke(s: (p: Int) -> Unit, ext: Int.(p: Int) -> Unit) {
subInline(s, ext)
subNoInline(s, ext)
}
inline fun inlineFunWithInvokeClosure(s: (p: Int) -> Unit, ext: Int.(p: Int) -> Unit) {
subInline({p: Int -> s(p)}, { p -> this.<!UNRESOLVED_REFERENCE!>ext<!>(p)})
subNoInline({p: Int -> s(p)}, { p -> this.<!UNRESOLVED_REFERENCE!>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)}, { p -> this.<!UNRESOLVED_REFERENCE!>ext<!>(p)})
subNoInline({p: Int -> s(p)}, { p -> this.<!UNRESOLVED_REFERENCE!>ext<!>(p)})
}
//ext function
inline fun Function1<Int, Unit>.inlineExt(ext: Int.(p: Int) -> Unit) {
subInline(this, ext)
subNoInline(this, ext)
}
inline fun Function1<Int, Unit>.inlineExtWithClosure(ext: Int.(p: Int) -> Unit) {
subInline({p: Int -> this(p)}, { p -> this.<!UNRESOLVED_REFERENCE!>ext<!>(p)})
subNoInline({p: Int -> this(p)}, { p -> this.<!UNRESOLVED_REFERENCE!>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 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE -INFIX_MODIFIER_REQUIRED
inline var value: (p: Int) -> String
get() = {"123" }
set(s: (p: Int) -> String) {
s(11)
s.invoke(11)
s invoke 11
val z = s
}
inline var value2: Int.(p: Int) -> String
get() = {"123" }
set(ext: Int.(p: Int) -> String) {
11.<!UNRESOLVED_REFERENCE!>ext<!>(11)
11.<!UNRESOLVED_REFERENCE!>ext<!>(11)
val p = ext
}
@@ -0,0 +1,21 @@
// WITH_REFLECT
import kotlin.reflect.KProperty
class Delegate {
operator fun getValue(t: Any?, p: KProperty<*>): Int = 1
}
open class A {
inline val z1 = 1
val z1_1 = 1
inline get() = field + 1
inline var z2 = 1
var z2_1 = 1
inline set(p: Int) {}
inline val z by Delegate()
}
@@ -0,0 +1,20 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE
inline val z: Int
get() {
class A {
fun a() {
class AInner {}
}
}
object B{
object BInner {}
}
fun local() {
fun localInner() {}
}
return 1
}
@@ -0,0 +1,38 @@
final class FinalProperty {
inline val valProp: Int
get() = 1
val valProp_1: Int
inline get() = 1
inline var varProp: Int
get() = 1
set(p: Int) {}
var varProp_2: Int
get() = 1
inline set(p: Int) {}
}
open class OpenProperty {
inline open val valProp: Int
get() = 1
open val valProp_1: Int
inline get() = 1
inline open var varProp: Int
get() = 1
set(p: Int) {}
open var varProp_2: Int
get() = 1
inline set(p: Int) {}
}
interface AbstractProperty {
inline abstract val valProp: Int
inline abstract var varProp: Int
}
@@ -0,0 +1,102 @@
// !LANGUAGE: -ProhibitProtectedCallFromInline
// !DIAGNOSTICS: -EXPOSED_PARAMETER_TYPE -NOTHING_TO_INLINE
// FILE: JavaClass.java
public abstract class JavaClass {
protected void bind() {}
}
// FILE: main.kt
open class A {
protected fun test() {}
protected val z: String = "1"
public var zVar: String = "1"
protected set(value) {}
inline fun call() {
test()
z
zVar
zVar = "123"
}
internal inline fun callFromInternal() {
test()
zVar
zVar = "123"
}
@PublishedApi
internal inline fun callFromPublished() {
test()
z
zVar
zVar = "123"
}
protected inline fun callFromProtected() {
test()
zVar
zVar = "123"
}
}
class B : A() {
inline fun testB() {
test()
}
}
class C : JavaClass() {
inline fun call() {
bind()
}
internal inline fun callFromInternal() {
bind()
}
protected inline fun callFromProtected() {
bind()
}
@PublishedApi
internal inline fun callFromPublished() {
bind()
}
}
internal class AInternal {
protected fun test() {}
protected val z: String = "1"
public var zVar: String = "1"
protected set(value) {}
inline fun call() {
test()
}
@PublishedApi
internal inline fun call2() {
test()
}
}
private class X {
public class Z : A() {
public inline fun effictivelyNonPublic() {
test()
}
}
}
@@ -0,0 +1,102 @@
// !LANGUAGE: +ProhibitProtectedCallFromInline
// !DIAGNOSTICS: -EXPOSED_PARAMETER_TYPE -NOTHING_TO_INLINE
// FILE: JavaClass.java
public abstract class JavaClass {
protected void bind() {}
}
// FILE: main.kt
open class A {
protected fun test() {}
protected val z: String = "1"
public var zVar: String = "1"
protected set(value) {}
inline fun call() {
test()
z
zVar
zVar = "123"
}
internal inline fun callFromInternal() {
test()
zVar
zVar = "123"
}
@PublishedApi
internal inline fun callFromPublished() {
test()
z
zVar
zVar = "123"
}
protected inline fun callFromProtected() {
test()
zVar
zVar = "123"
}
}
class B : A() {
inline fun testB() {
test()
}
}
class C : JavaClass() {
inline fun call() {
bind()
}
internal inline fun callFromInternal() {
bind()
}
protected inline fun callFromProtected() {
bind()
}
@PublishedApi
internal inline fun callFromPublished() {
bind()
}
}
internal class AInternal {
protected fun test() {}
protected val z: String = "1"
public var zVar: String = "1"
protected set(value) {}
inline fun call() {
test()
}
@PublishedApi
internal inline fun call2() {
test()
}
}
private class X {
public class Z : A() {
public inline fun effictivelyNonPublic() {
test()
}
}
}
@@ -0,0 +1,175 @@
// !DIAGNOSTICS: -EXPOSED_PARAMETER_TYPE -NOTHING_TO_INLINE
inline fun call(a: A) {
a.test()
publishedTopLevel()
a.publishedVar
a.publishedVar = 1
publishedVarTopLevel
publishedVarTopLevel = 1
}
inline var inlineVar: Int
get() {
val a = A()
a.test()
publishedTopLevel()
a.publishedVar
a.publishedVar = 1
publishedVarTopLevel
publishedVarTopLevel = 1
return 1
}
set(value) {
val a = A()
a.test()
publishedTopLevel()
a.publishedVar
a.publishedVar = 1
publishedVarTopLevel
publishedVarTopLevel = 1
}
@PublishedApi
internal class A {
@PublishedApi
internal fun test() {
publicFun()
internalFun()
privateFun()
publicVarTopLevel
publicVarTopLevel = 1
internalVarTopLevel
internalVarTopLevel = 1
privateVarTopLevel
privateVarTopLevel = 1
publishedVar
publishedVar = 1
}
@PublishedApi
internal inline fun testInline() {
publicFun()
internalFun()
privateFun()
publicVarTopLevel
publicVarTopLevel = 1
internalVarTopLevel
internalVarTopLevel = 1
privateVarTopLevel
privateVarTopLevel = 1
publishedVar
publishedVar = 1
}
@PublishedApi
internal inline var publishedVar: Int
get() {
publicFun()
internalFun()
privateFun()
publicVarTopLevel
publicVarTopLevel = 1
internalVarTopLevel
internalVarTopLevel = 1
privateVarTopLevel
privateVarTopLevel = 1
return 1
}
set(value) {
publicFun()
internalFun()
privateFun()
publicVarTopLevel
publicVarTopLevel = 1
internalVarTopLevel
internalVarTopLevel = 1
privateVarTopLevel
privateVarTopLevel = 1
}
}
@PublishedApi
internal fun publishedTopLevel() {
publicFun()
internalFun()
privateFun()
publicVarTopLevel
publicVarTopLevel = 1
internalVarTopLevel
internalVarTopLevel = 1
privateVarTopLevel
privateVarTopLevel = 1
}
@PublishedApi
inline internal fun publishedTopLevelInline() {
publicFun()
internalFun()
privateFun()
publicVarTopLevel
publicVarTopLevel = 1
internalVarTopLevel
internalVarTopLevel = 1
privateVarTopLevel
privateVarTopLevel = 1
}
@PublishedApi
inline internal var publishedVarTopLevel: Int
get() {
publicFun()
internalFun()
privateFun()
publicVarTopLevel
publicVarTopLevel = 1
internalVarTopLevel
internalVarTopLevel = 1
privateVarTopLevel
privateVarTopLevel = 1
return 1
}
set(value) {
publicFun()
internalFun()
privateFun()
publicVarTopLevel
publicVarTopLevel = 1
internalVarTopLevel
internalVarTopLevel = 1
privateVarTopLevel
privateVarTopLevel = 1
}
fun publicFun() {}
internal fun internalFun() {}
private fun privateFun() {}
var publicVarTopLevel = 1
internal var internalVarTopLevel = 1
private var privateVarTopLevel = 1
@@ -0,0 +1,24 @@
// !CHECK_TYPE
// !DIAGNOSTICS: -NOTHING_TO_INLINE -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -VARIABLE_EXPECTED
inline fun inlineFun(s: (p: Int) -> Unit) {
inlineFun(s)
}
inline fun <T> inlineFun(s: T) {
inlineFun<Int>(11)
}
inline fun <T> Function0<T>.inlineExt() {
(checkSubtype<Function0<Int>>({11})).inlineExt();
{11}.inlineExt()
}
inline operator fun <T, V> Function1<T, V>.not() : Boolean {
return !this
}
inline operator fun <T, V> Function1<T, V>.inc() : Function1<T, V> {
return this++
}
@@ -0,0 +1,6 @@
//KT-4341 No resolved call for right-hand side of equals expression
package g
inline fun <T, U, V> inlineFunWithInvoke(s: (p: T) -> U) {
s == s //resolved call for right-hand side 's' not traced
}
@@ -0,0 +1,20 @@
inline fun inlineFun(s: (p: Int) -> Unit) : (p: Int) -> Unit {
return s
}
inline fun inlineFun2(s: (p: Int) -> Unit) : (p: Int) -> Unit = s
inline fun inlineFunWithExt(ext: Int.(p: Int) -> Unit) : Int.(p: Int) -> Unit {
return ext
}
inline fun inlineFunWithExt2(ext: Int.(p: Int) -> Unit) : Int.(p: Int) -> Unit = ext
inline fun Function1<Int, Unit>.inlineExt(): Function1<Int, Unit> {
return this
}
inline fun Function1<Int, Unit>.inlineExt2(): Function1<Int, Unit> = this
+58
View File
@@ -0,0 +1,58 @@
// !DIAGNOSTICS: -NON_LOCAL_RETURN_NOT_ALLOWED
// FILE: Run.java
public interface Run {
public int run();
}
// FILE: Test.java
public class Test {
public void test(Run r) {
}
}
// FILE: test.kt
inline fun inlineFunWithInvoke(s: (p: Int) -> Unit, ext: Int.(p: Int) -> Unit) {
Test().test(){
s(11)
s.invoke(11)
s invoke 11
11.<!UNRESOLVED_REFERENCE!>ext<!>(11)
11 <!UNRESOLVED_REFERENCE!>ext<!> 11
s
ext
11
}
}
inline fun inlineFunWithInvokeNonInline(noinline s: (p: Int) -> Unit, ext: Int.(p: Int) -> Unit) {
Test().test(){
s(11)
s.invoke(11)
s invoke 11
11.<!UNRESOLVED_REFERENCE!>ext<!>(11)
11 <!UNRESOLVED_REFERENCE!>ext<!> 11
s
ext
11
}
}
inline fun Function1<Int, Unit>.inlineExt() {
Test().test(){
invoke(11)
this.invoke(11)
this invoke 11
this(11)
this
11
}
}
@@ -0,0 +1,10 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION
inline public fun reg(converter: (Any) -> Any, str: String) {
str
converter("")
}
public inline fun register(converter: (Any) -> Any) {
"123$converter"
reg(converter, "123$converter")
}
@@ -0,0 +1,35 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -VAL_REASSIGNMENT -UNUSED_CHANGED_VALUE -VARIABLE_EXPECTED
inline operator fun <T, V> Function1<T, V>.unaryPlus() = this
operator fun <T, V> Function1<T, V>.unaryMinus() = this
inline operator fun <T, V> Function1<T, V>.inc() = this
operator fun <T, V> Function1<T, V>.dec() = this
inline operator fun <T, V> @ExtensionFunctionType Function2<T, T, V>.unaryPlus(){}
operator fun <T, V> @ExtensionFunctionType Function2<T, T, V>.unaryMinus(){}
inline operator fun <T, V> @ExtensionFunctionType Function2<T, T, V>.inc() = this
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
-s
s++
++s
s--
--s
+ext
-ext
ext++
++ext
ext--
--ext
}
inline fun <T, V> Function1<T, V>.inlineFunWithInvoke() {
+this
-this
this++
++this
this--
--this
}
@@ -0,0 +1,3 @@
public inline fun test(predicate: (Char) -> Boolean) {
!predicate('c')
}
@@ -0,0 +1,21 @@
// !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) {
!s
!ext
}
@@ -0,0 +1,33 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE
// !LANGUAGE: -InlineDefaultFunctionalParameters
inline fun unsupported() {
class A {
fun a() {
class AInner {}
}
}
object B{
object BInner {}
}
fun local() {
fun localInner() {}
}
}
inline fun unsupportedDefault(s : ()->Unit = {}) {
}
open class Base {
open fun foo(a: Int = 1) {}
}
class Derived: Base() {
inline final override fun foo(a: Int) {
}
}
@@ -0,0 +1,16 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE
inline fun inlineFun(s: (p: Int) -> Unit, noinline b: (p: Int) -> Unit) {
subInline(s, b)
subNoInline(s, b)
}
inline fun Function1<Int, Unit>.inlineExt(s: (p: Int) -> Unit, noinline b: (p: Int) -> Unit) {
subInline(this, s, b)
subNoInline(this, s, b)
}
inline fun subInline(vararg s: (p: Int) -> Unit) {}
fun subNoInline(vararg s: (p: Int) -> Unit) {}
+11
View File
@@ -0,0 +1,11 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION
inline public fun reg(converter: (Any) -> Any) {
converter("")
}
public inline fun register(converter: (Any) -> Any) {
reg(when(converter) {
is (Any) -> Any -> converter
else -> converter
})
}
@@ -0,0 +1,51 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -NOTHING_TO_INLINE -USELESS_ELVIS
inline fun inlineFunWrongUsage(s: (p: Int) -> Unit) {
s
if (true) s else 0
s ?: s
}
inline fun inlineFunWrongUsageExt(ext: Int.(p: Int) -> Unit) {
ext
if (true) ext else 0
ext ?: ext
}
inline fun inlineFunWrongUsageInClosure(s: (p: Int) -> Unit) {
<!UNRESOLVED_REFERENCE!>{
s
if (true) s else 0
s ?: s
}()<!>
}
inline fun inlineFunWrongUsageInClosureExt(ext: Int.(p: Int) -> Unit) {
<!UNRESOLVED_REFERENCE!>{
ext
if (true) ext else 0
ext ?: ext
}()<!>
}
inline fun inlineFunNoInline(noinline s: (p: Int) -> Unit) {
s
if (true) s else 0
s ?: s
}
inline fun inlineFunNoInline(noinline ext: Int.(p: Int) -> Unit) {
ext
if (true) ext else 0
ext ?: ext
}