tests for type inference tasks added
#KT-742 fixed #KT-832 fixed #KT-943 fixed
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
package a
|
||||
|
||||
class List<T>(val head: T, val tail: List<T>? = null)
|
||||
|
||||
fun <T, Q> List<T>.map1(f: (T)-> Q): List<T>? = tail!!.map1(f)
|
||||
|
||||
fun <T, Q> List<T>.map2(f: (T)-> Q): List<T>? = <!TYPE_MISMATCH!>tail<!>.sure<T>().<!TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH!>map2<!>(f)
|
||||
@@ -0,0 +1,9 @@
|
||||
package a
|
||||
|
||||
fun fooT2<T>() : (t : T) -> T {
|
||||
return {it}
|
||||
}
|
||||
|
||||
fun test() {
|
||||
<!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>fooT2<!>()(1) // here 1 should not be marked with an error
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package maze
|
||||
|
||||
//+JDK
|
||||
import java.util.Collections.*
|
||||
import java.util.*
|
||||
|
||||
fun foo(lines: List<String>) {
|
||||
val w = max(lines, comparator {o1, o2 ->
|
||||
val l1 : Int = o1.length // Types of o1 and o2 are ERROR
|
||||
val l2 = o2.length
|
||||
l1 - l2
|
||||
}).sure()
|
||||
w : String
|
||||
}
|
||||
|
||||
//standard library
|
||||
public inline fun <T> comparator(<!UNUSED_PARAMETER!>fn<!>: (T,T) -> Int): Comparator<T> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
Reference in New Issue
Block a user