Files
kotlin-fork/compiler/testData/codegen/box/regressions/kt1800.kt
T
Ivan Kylchik c7435ba760 Replace all occurrences of WITH_RUNTIME with WITH_STDLIB
We are going to deprecate `WITH_RUNTIME` directive. The main reason
behind this change is that `WITH_STDLIB` directive better describes
its meaning, specifically it will add kotlin stdlib to test's classpath.
2021-11-17 15:26:38 +03:00

31 lines
751 B
Kotlin
Vendored

// WITH_STDLIB
//KT-1800 error/NonExistentClass generated on runtime
package i
public class User(val firstName: String,
val lastName: String,
val age: Int) {
override fun toString() = "$firstName $lastName, age $age"
}
public fun <T: Comparable<T>> Collection<T>.testMin(): 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 = arrayListOf(
User("John", "Doe", 30),
User("Jane", "Doe", 27))
val ages = users.map { it.age }
val minAge = ages.testMin()
return if (minAge == 27) "OK" else "fail"
}