Introduce Type Parameter

#KT-13155 Fixed
This commit is contained in:
Alexey Sedunov
2016-08-26 20:14:12 +03:00
parent cd717467f0
commit 2f9a911624
23 changed files with 367 additions and 14 deletions
@@ -0,0 +1,9 @@
class A
fun foo(x: List<A>, f: (<selection>A</selection>) -> Int) {
val a: A? = x.firstOrNull()
}
fun test() {
foo(listOf(A())) { 1 }
}
@@ -0,0 +1,9 @@
class A
fun <T : A> foo(x: List<T>, f: (T) -> Int) {
val a: T? = x.firstOrNull()
}
fun test() {
foo(listOf(A())) { 1 }
}
@@ -0,0 +1,9 @@
class A
fun foo(x: List<<selection>(A?) -> List<Int></selection>>) {
}
fun test() {
foo(listOf({ a -> listOf(1) }))
}
@@ -0,0 +1,9 @@
class A
fun <T : (A?) -> List<Int>> foo(x: List<T>) {
}
fun test() {
foo(listOf({ a -> listOf(1) }))
}
@@ -0,0 +1,11 @@
class A
open class X(x: List<A>, f: (<selection>A</selection>) -> Int) {
val a: A? = x.firstOrNull()
}
class Y : X(listOf(A()), { 1 })
fun test() {
X(listOf(A())) { 1 }
}
@@ -0,0 +1,11 @@
class A
open class X<T : A>(x: List<T>, f: (T) -> Int) {
val a: T? = x.firstOrNull()
}
class Y : X<A>(listOf(A()), { 1 })
fun test() {
X(listOf(A())) { 1 }
}
@@ -0,0 +1,11 @@
class A
val List<<selection>A</selection>>.foo: (A) -> Int
get() {
val a: A? = firstOrNull()
return { 0 }
}
fun test() {
val t = listOf(A()).foo
}
@@ -0,0 +1,11 @@
class A
val <T : A> List<T>.foo: (T) -> Int
get() {
val a: T? = firstOrNull()
return { 0 }
}
fun test() {
val t = listOf(A()).foo
}
@@ -0,0 +1,9 @@
class A
fun foo(x: List<<selection>A?</selection>>) {
}
fun test() {
foo(listOf(A()))
}
@@ -0,0 +1,9 @@
class A
fun <T : A?> foo(x: List<T>) {
}
fun test() {
foo(listOf(A()))
}
@@ -0,0 +1,9 @@
class A
fun foo(x: (<selection>List<A?></selection>) -> Int) {
}
fun test() {
foo { 1 }
}
@@ -0,0 +1,9 @@
class A
fun <T : List<A?>> foo(x: (T) -> Int) {
}
fun test() {
foo<List<A?>> { 1 }
}