Allow generic type parameter to have mixed constraints for @InlineOnly functions

#KT-19323 Fixed
This commit is contained in:
Stanislav Erokhin
2018-08-20 11:03:52 +03:00
parent 7d4dfc87b1
commit f3e0470dcd
7 changed files with 51 additions and 2 deletions
@@ -0,0 +1,16 @@
// !CHECK_TYPE
@<!INVISIBLE_MEMBER!>kotlin.internal.<!INVISIBLE_REFERENCE!>InlineOnly<!><!>
public inline fun <C, R> C.ifEmpty(f: () -> R): R where C : Collection<*>, C : R = if (isEmpty()) f() else this
public fun <T> listOf(<!UNUSED_PARAMETER!>t<!>: T): List<T> = TODO()
fun usage(c: List<String>) {
val cn = c.ifEmpty { null }
cn checkType { _<List<String>?>() }
val cs = c.ifEmpty { listOf("x") }
cs checkType { _<List<String>>() }
}
@@ -0,0 +1,5 @@
package
public fun </*0*/ T> listOf(/*0*/ t: T): kotlin.collections.List<T>
public fun usage(/*0*/ c: kotlin.collections.List<kotlin.String>): kotlin.Unit
@kotlin.internal.InlineOnly public inline fun </*0*/ C : kotlin.collections.Collection<*>, /*1*/ R> C.ifEmpty(/*0*/ f: () -> R): R where C : R