tests for type inference

#KT-1800 fixed
 #KT-1029 fixed
 #KT-1031 fixed
 #KT-1558 fixed
 #KT-1944 fixed
 #KT-2179 fixed
 #KT-2294 fixed
 #KT-2320 fixed
 #KT-2324 fixed
This commit is contained in:
Svetlana Isakova
2012-07-03 13:29:09 +04:00
parent e77cc82afd
commit eb82eba121
15 changed files with 332 additions and 3 deletions
@@ -0,0 +1,32 @@
//KT-1800 error/NonExistentClass generated on runtime
package i
import java.util.Collection
import java.util.ArrayList
public class User(val firstName: String,
val lastName: String,
val age: Int) {
fun toString() = "$firstName $lastName, age $age"
}
public fun <T: Comparable<T>> Collection<T>.min(): T? {
var minValue: T? = null
for(value in this) {
if (minValue == null || value.compareTo(minValue!!) < 0) {
minValue = value
}
}
return minValue
}
fun box() : String {
val users = arrayList(
User("John", "Doe", 30),
User("Jane", "Doe", 27))
val ages = users.map { it.age }
val minAge = ages.min()
return if (minAge == 27) "OK" else "fail"
}