Introduce call checker for Unit-conversions

This commit is contained in:
Mikhail Zarechenskiy
2020-06-02 16:15:36 +03:00
parent 6b0a803d14
commit bfa648972f
14 changed files with 210 additions and 1 deletions
@@ -0,0 +1,29 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
object Test1 {
fun foo(f: () -> Int) {}
object Scope {
fun foo(f: () -> Unit) {}
fun test(f: () -> Int) {
<!DEBUG_INFO_CALL("fqName: Test1.foo; typeCall: function")!>foo(f)<!>
}
}
}
object Test2 {
fun interface KRunnable {
fun run()
}
fun foo(f: () -> Unit) {}
object Scope1 {
fun foo(f: KRunnable) {}
fun test(f: () -> Int) {
<!DEBUG_INFO_CALL("fqName: fqName is unknown; typeCall: unresolved")!><!INAPPLICABLE_CANDIDATE!>foo<!>(f)<!>
}
}
}
@@ -0,0 +1,29 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
object Test1 {
fun foo(f: () -> Int) {}
object Scope {
fun foo(f: () -> Unit) {}
fun test(f: () -> Int) {
<!DEBUG_INFO_CALL("fqName: Test1.foo; typeCall: function")!><!COMPATIBILITY_WARNING!>foo<!>(f)<!>
}
}
}
object Test2 {
fun interface KRunnable {
fun run()
}
fun foo(f: () -> Unit) {}
object Scope1 {
fun foo(f: KRunnable) {}
fun test(f: () -> Int) {
<!DEBUG_INFO_CALL("fqName: Test2.Scope1.foo; typeCall: function")!>foo(<!UNSUPPORTED_FEATURE!>f<!>)<!>
}
}
}
@@ -0,0 +1,42 @@
package
public object Test1 {
private constructor Test1()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final fun foo(/*0*/ f: () -> kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public object Scope {
private constructor Scope()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final fun foo(/*0*/ f: () -> kotlin.Unit): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final fun test(/*0*/ f: () -> kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
public object Test2 {
private constructor Test2()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final fun foo(/*0*/ f: () -> kotlin.Unit): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public fun interface KRunnable {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public abstract fun run(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public object Scope1 {
private constructor Scope1()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final fun foo(/*0*/ f: Test2.KRunnable): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final fun test(/*0*/ f: () -> kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
@@ -0,0 +1,16 @@
// !LANGUAGE: -SuspendConversion
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
fun foo(f: () -> Unit) {}
fun bar(): Int = 0
abstract class SubInt : () -> Int
fun test(f: () -> String, s: SubInt) {
foo { "lambda" }
foo(::bar)
<!INAPPLICABLE_CANDIDATE!>foo<!>(f)
<!INAPPLICABLE_CANDIDATE!>foo<!>(s)
}
@@ -0,0 +1,16 @@
// !LANGUAGE: -SuspendConversion
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
fun foo(f: () -> Unit) {}
fun bar(): Int = 0
abstract class SubInt : () -> Int
fun test(f: () -> String, s: SubInt) {
foo { "lambda" }
foo(::bar)
foo(<!UNSUPPORTED_FEATURE!>f<!>)
foo(<!UNSUPPORTED_FEATURE!>s<!>)
}
@@ -0,0 +1,13 @@
package
public fun bar(): kotlin.Int
public fun foo(/*0*/ f: () -> kotlin.Unit): kotlin.Unit
public fun test(/*0*/ f: () -> kotlin.String, /*1*/ s: SubInt): kotlin.Unit
public abstract class SubInt : () -> kotlin.Int {
public constructor SubInt()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public abstract override /*1*/ /*fake_override*/ fun invoke(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}