Fix error type for implicit invoke with function literal argument
#KT-11401 Fixed
This commit is contained in:
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_VARIABLE
|
||||
|
||||
class AbstractSelector<S, I>
|
||||
class SelectorFor<S>
|
||||
|
||||
inline operator fun <S, I> SelectorFor<S>.invoke(f: S.() -> I): AbstractSelector<S, I> = TODO()
|
||||
|
||||
class State(val p1: Double, val p2: () -> Int, val p3: String?)
|
||||
|
||||
fun test(s: SelectorFor<State>): Double {
|
||||
val a = s { p1 }
|
||||
a checkType { _<AbstractSelector<State, Double>>() }
|
||||
|
||||
val b = s { p2 }
|
||||
b checkType { _<AbstractSelector<State, () -> Int>>()}
|
||||
|
||||
val c = s { p3 }
|
||||
c checkType { _<AbstractSelector<State, String?>>() }
|
||||
|
||||
val d = s { }
|
||||
d checkType { _<AbstractSelector<State, Unit>>() }
|
||||
|
||||
val e = s { return p1 }
|
||||
e checkType { _<AbstractSelector<State, Nothing>>() }
|
||||
|
||||
<!UNREACHABLE_CODE!>return<!> null!!
|
||||
}
|
||||
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
package
|
||||
|
||||
public fun test(/*0*/ s: SelectorFor<State>): kotlin.Double
|
||||
public operator inline fun </*0*/ S, /*1*/ I> SelectorFor<S>.invoke(/*0*/ f: S.() -> I): AbstractSelector<S, I>
|
||||
|
||||
public final class AbstractSelector</*0*/ S, /*1*/ I> {
|
||||
public constructor AbstractSelector</*0*/ S, /*1*/ I>()
|
||||
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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class SelectorFor</*0*/ S> {
|
||||
public constructor SelectorFor</*0*/ S>()
|
||||
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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class State {
|
||||
public constructor State(/*0*/ p1: kotlin.Double, /*1*/ p2: () -> kotlin.Int, /*2*/ p3: kotlin.String?)
|
||||
public final val p1: kotlin.Double
|
||||
public final val p2: () -> kotlin.Int
|
||||
public final val p3: kotlin.String?
|
||||
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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_VARIABLE
|
||||
|
||||
class TestClass {
|
||||
companion object {
|
||||
inline operator fun <T> invoke(task: () -> T) = task()
|
||||
}
|
||||
}
|
||||
|
||||
fun test(s: String): String {
|
||||
val a = TestClass { "K" }
|
||||
a checkType { _<String>() }
|
||||
|
||||
<!UNREACHABLE_CODE!>val b =<!> TestClass { return s }
|
||||
<!UNREACHABLE_CODE!>b checkType { _<Nothing>() }<!>
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package
|
||||
|
||||
public fun test(/*0*/ s: kotlin.String): kotlin.String
|
||||
|
||||
public final class TestClass {
|
||||
public constructor TestClass()
|
||||
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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
public companion object Companion {
|
||||
private constructor Companion()
|
||||
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 final operator inline fun </*0*/ T> invoke(/*0*/ task: () -> T): T
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_VARIABLE
|
||||
|
||||
object TestClass {
|
||||
inline operator fun <T> invoke(task: () -> T) = task()
|
||||
}
|
||||
|
||||
fun test(s: String): String {
|
||||
val a = TestClass { TestClass { TestClass } }
|
||||
a checkType { _<TestClass>() }
|
||||
|
||||
<!UNREACHABLE_CODE!>val b =<!> TestClass { return s }
|
||||
<!UNREACHABLE_CODE!>b checkType { _<Nothing>() }<!>
|
||||
}
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
package
|
||||
|
||||
public fun test(/*0*/ s: kotlin.String): kotlin.String
|
||||
|
||||
public object TestClass {
|
||||
private constructor TestClass()
|
||||
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 final operator inline fun </*0*/ T> invoke(/*0*/ task: () -> T): T
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_VARIABLE
|
||||
|
||||
class TestClass {
|
||||
inline operator fun <T> invoke(task: () -> T) = task()
|
||||
}
|
||||
|
||||
fun <T> test(value: T, test: TestClass): T {
|
||||
<!UNREACHABLE_CODE!>val x =<!> test { return value }
|
||||
<!UNREACHABLE_CODE!>x checkType { _<Nothing>() }<!>
|
||||
|
||||
<!UNREACHABLE_CODE!>return value<!>
|
||||
}
|
||||
|
||||
// ---
|
||||
|
||||
class Future<T>
|
||||
|
||||
interface FutureCallback<E> {
|
||||
operator fun <T> invoke(f: (E) -> T): Future<T>
|
||||
}
|
||||
|
||||
fun test(cb: FutureCallback<String>) {
|
||||
val a = cb { it[0] }
|
||||
a checkType { _<Future<Char>>() }
|
||||
|
||||
val b = cb { it }
|
||||
b checkType { _<Future<String>>() }
|
||||
|
||||
val c = cb {}
|
||||
c checkType { _<Future<Unit>>() }
|
||||
|
||||
cb.let { callback ->
|
||||
val d = callback { it.length }
|
||||
d checkType { _<Future<Int>>() }
|
||||
}
|
||||
}
|
||||
Vendored
+26
@@ -0,0 +1,26 @@
|
||||
package
|
||||
|
||||
public fun test(/*0*/ cb: FutureCallback<kotlin.String>): kotlin.Unit
|
||||
public fun </*0*/ T> test(/*0*/ value: T, /*1*/ test: TestClass): T
|
||||
|
||||
public final class Future</*0*/ T> {
|
||||
public constructor Future</*0*/ T>()
|
||||
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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface FutureCallback</*0*/ E> {
|
||||
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 operator fun </*0*/ T> invoke(/*0*/ f: (E) -> T): Future<T>
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class TestClass {
|
||||
public constructor TestClass()
|
||||
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 final operator inline fun </*0*/ T> invoke(/*0*/ task: () -> T): T
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Reference in New Issue
Block a user