Report errors on callable references which contains postponed type variables in the receiver type
This commit is contained in:
Vendored
+113
@@ -0,0 +1,113 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
import kotlin.experimental.ExperimentalTypeInference
|
||||
|
||||
fun <K> FlowCollector<K>.bar(): K = null as K
|
||||
fun <K> FlowCollector<K>.foo(): K = null as K
|
||||
|
||||
fun bar2(): Int = 1
|
||||
fun foo2(): Float = 1f
|
||||
|
||||
fun <T> materialize() = null as T
|
||||
|
||||
interface FlowCollector<in T> {}
|
||||
|
||||
@Suppress("EXPERIMENTAL_API_USAGE_ERROR")
|
||||
fun <L> flow(@BuilderInference block: suspend FlowCollector<L>.() -> Unit) = Flow(block)
|
||||
|
||||
class Flow<out R>(private val block: suspend FlowCollector<R>.() -> Unit)
|
||||
|
||||
fun <R> select(vararg x: R) = x[0]
|
||||
|
||||
fun poll01(): Flow<String> {
|
||||
return flow {
|
||||
val inv = select(::bar2, ::foo2)
|
||||
inv()
|
||||
}
|
||||
}
|
||||
|
||||
fun poll1(flag: Boolean): Flow<String> {
|
||||
return flow {
|
||||
val inv = if (flag) { ::bar2 } else { ::foo2 }
|
||||
inv()
|
||||
}
|
||||
}
|
||||
|
||||
fun poll11(flag: Boolean): Flow<String> {
|
||||
return flow {
|
||||
val inv = if (flag) { ::bar2 } else { ::foo2 }
|
||||
inv()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun poll21(flag: Boolean): Flow<String> {
|
||||
return flow {
|
||||
val inv = when (flag) { true -> ::bar2 else -> ::foo2 }
|
||||
inv()
|
||||
}
|
||||
}
|
||||
|
||||
fun poll31(flag: Boolean): Flow<String> {
|
||||
return flow {
|
||||
val inv = when (flag) { true -> ::bar2 false -> ::foo2 }
|
||||
inv()
|
||||
}
|
||||
}
|
||||
|
||||
fun poll41(): Flow<String> {
|
||||
return flow {
|
||||
val inv = try { ::bar2 } finally { ::foo2 }
|
||||
inv()
|
||||
}
|
||||
}
|
||||
|
||||
fun poll51(): Flow<String> {
|
||||
return flow {
|
||||
val inv = try { ::bar2 } catch (e: Exception) { ::foo2 } finally { ::foo2 }
|
||||
inv()
|
||||
}
|
||||
}
|
||||
|
||||
fun poll61(): Flow<String> {
|
||||
return flow {
|
||||
val inv = ::bar2
|
||||
inv
|
||||
}
|
||||
}
|
||||
|
||||
fun poll71(): Flow<String> {
|
||||
return flow {
|
||||
val inv = ::bar2!!
|
||||
inv()
|
||||
}
|
||||
}
|
||||
|
||||
fun poll81(): Flow<String> {
|
||||
return flow {
|
||||
val inv = ::bar2 in setOf(::foo2)
|
||||
inv
|
||||
}
|
||||
}
|
||||
|
||||
fun poll91(): Flow<String> {
|
||||
return flow {
|
||||
val inv = ::foo2 in setOf(::foo2)
|
||||
inv
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
poll01()
|
||||
poll1(true)
|
||||
poll11(true)
|
||||
poll21(true)
|
||||
poll31(true)
|
||||
poll41()
|
||||
poll51()
|
||||
poll61()
|
||||
poll71()
|
||||
poll81()
|
||||
poll91()
|
||||
return "OK"
|
||||
}
|
||||
+208
@@ -0,0 +1,208 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
import kotlin.experimental.ExperimentalTypeInference
|
||||
|
||||
interface FlowCollector<in T> {}
|
||||
|
||||
@Suppress("EXPERIMENTAL_API_USAGE_ERROR")
|
||||
fun <L> flow(@BuilderInference block: suspend FlowCollector<L>.() -> Unit) = Flow(block)
|
||||
|
||||
class Flow<out R>(private val block: suspend FlowCollector<R>.() -> Unit)
|
||||
|
||||
fun <R> select(vararg x: R) = x[0]
|
||||
|
||||
fun poll0(): Flow<String> {
|
||||
return flow {
|
||||
val inv = select({}, {})
|
||||
inv()
|
||||
}
|
||||
}
|
||||
|
||||
fun poll01(): Flow<String> {
|
||||
return flow {
|
||||
val inv = select({ 1 }, { 1f })
|
||||
inv()
|
||||
}
|
||||
}
|
||||
|
||||
fun poll1(flag: Boolean): Flow<String> {
|
||||
return flow {
|
||||
val inv = if (flag) { {} } else { {} }
|
||||
inv()
|
||||
}
|
||||
}
|
||||
|
||||
fun poll11(flag: Boolean): Flow<String> {
|
||||
return flow {
|
||||
val inv = if (flag) { { 1 } } else { { 1f } }
|
||||
inv()
|
||||
}
|
||||
}
|
||||
|
||||
fun poll12(flag: Boolean): Flow<String> {
|
||||
return flow {
|
||||
val inv = if (flag) ({ }) else ({ })
|
||||
inv()
|
||||
}
|
||||
}
|
||||
|
||||
fun poll13(flag: Boolean): Flow<String> {
|
||||
return flow {
|
||||
val inv = if (flag) ({ 1 }) else ({ 1f })
|
||||
inv()
|
||||
}
|
||||
}
|
||||
|
||||
fun poll2(flag: Boolean): Flow<String> {
|
||||
return flow {
|
||||
val inv = when (flag) { true -> {{}} else -> {{}} }
|
||||
inv()
|
||||
}
|
||||
}
|
||||
|
||||
fun poll21(flag: Boolean): Flow<String> {
|
||||
return flow {
|
||||
val inv = when (flag) { true -> {{1}} else -> {{1f}} }
|
||||
inv()
|
||||
}
|
||||
}
|
||||
|
||||
fun poll22(flag: Boolean): Flow<String> {
|
||||
return flow {
|
||||
val inv = when (flag) { true -> ({}) else -> ({}) }
|
||||
inv()
|
||||
}
|
||||
}
|
||||
|
||||
fun poll23(flag: Boolean): Flow<String> {
|
||||
return flow {
|
||||
val inv = when (flag) { true -> ({1}) else -> ({1f}) }
|
||||
inv()
|
||||
}
|
||||
}
|
||||
|
||||
fun poll4(): Flow<String> {
|
||||
return flow {
|
||||
val inv = try { {} } finally { {} }
|
||||
inv()
|
||||
}
|
||||
}
|
||||
|
||||
fun poll41(): Flow<String> {
|
||||
return flow {
|
||||
val inv = try { {1} } finally { {1f} }
|
||||
inv()
|
||||
}
|
||||
}
|
||||
|
||||
fun poll42(): Flow<String> {
|
||||
return flow {
|
||||
val inv = try { ({1}) } finally { ({1f}) }
|
||||
inv()
|
||||
}
|
||||
}
|
||||
|
||||
fun poll43(): Flow<String> {
|
||||
return flow {
|
||||
val inv = try { ({}) } finally { ({}) }
|
||||
inv()
|
||||
}
|
||||
}
|
||||
|
||||
fun poll5(): Flow<String> {
|
||||
return flow {
|
||||
val inv = try { {1} } catch (e: Exception) { {1f} } finally { {} }
|
||||
inv()
|
||||
}
|
||||
}
|
||||
|
||||
fun poll7(): Flow<String> {
|
||||
return flow {
|
||||
val inv = {}!!
|
||||
inv()
|
||||
}
|
||||
}
|
||||
|
||||
fun poll71(): Flow<String> {
|
||||
return flow {
|
||||
val inv = {1f}!!
|
||||
inv()
|
||||
}
|
||||
}
|
||||
|
||||
fun poll72(): Flow<String> {
|
||||
return flow {
|
||||
val inv = {{}}!!
|
||||
inv()
|
||||
}
|
||||
}
|
||||
|
||||
fun poll73(): Flow<String> {
|
||||
return flow {
|
||||
val inv = ({})!!
|
||||
inv
|
||||
}
|
||||
}
|
||||
|
||||
fun poll81(): Flow<String> {
|
||||
return flow {
|
||||
val inv = {} in setOf({})
|
||||
inv
|
||||
}
|
||||
}
|
||||
|
||||
fun poll82(): Flow<String> {
|
||||
return flow {
|
||||
val inv = {{}} in setOf({{}})
|
||||
inv
|
||||
}
|
||||
}
|
||||
|
||||
fun poll83(): Flow<String> {
|
||||
return flow {
|
||||
val inv = {({})} in setOf({({})})
|
||||
inv
|
||||
}
|
||||
}
|
||||
|
||||
fun poll85(): Flow<String> {
|
||||
return flow {
|
||||
val inv = {({"1"})} in setOf({({"1f"})})
|
||||
inv
|
||||
}
|
||||
}
|
||||
|
||||
fun poll86(): Flow<String> {
|
||||
return flow {
|
||||
val inv = {({"1"})}!! in setOf({({"1f"})})!!
|
||||
inv
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
poll0()
|
||||
poll01()
|
||||
poll1(true)
|
||||
poll11(true)
|
||||
poll12(true)
|
||||
poll13(true)
|
||||
poll2(true)
|
||||
poll21(true)
|
||||
poll22(true)
|
||||
poll23(true)
|
||||
poll4()
|
||||
poll41()
|
||||
poll42()
|
||||
poll43()
|
||||
poll5()
|
||||
poll7()
|
||||
poll71()
|
||||
poll72()
|
||||
poll73()
|
||||
poll81()
|
||||
poll82()
|
||||
poll83()
|
||||
poll85()
|
||||
poll86()
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user