For-loop range expression (collection) can not be null
This commit is contained in:
@@ -12,10 +12,5 @@ fun box() : String {
|
||||
System.out?.println(sum)
|
||||
if(sum != 10) return "b failed"
|
||||
|
||||
val d : Array<Int?>? = null
|
||||
for (el in d) {
|
||||
sum = sum + (el ?: 7)
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -10,10 +10,5 @@ fun box() : String {
|
||||
}
|
||||
if(sum != 10) return "a failed"
|
||||
|
||||
val b : IntArray? = null
|
||||
for (el in b) {
|
||||
sum = sum + el
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -2,7 +2,7 @@ abstract class ClassValAbstract {
|
||||
abstract var a: Int
|
||||
|
||||
class object {
|
||||
val methods = (this as java.lang.Object).getClass()?.getClassLoader()?.loadClass("ClassValAbstract")?.getMethods()
|
||||
val methods = (this as java.lang.Object).getClass()?.getClassLoader()?.loadClass("ClassValAbstract")?.getMethods()!!
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ class Test() {
|
||||
|
||||
fun box(): String {
|
||||
val test = Test()
|
||||
for (method in javaClass<Test>().getMethods()) {
|
||||
for (method in javaClass<Test>().getMethods()!!) {
|
||||
val anns = method?.getAnnotations() as Array<Annotation>
|
||||
if (!anns.isEmpty()) {
|
||||
for (ann in anns) {
|
||||
|
||||
@@ -17,7 +17,7 @@ fun <T> fff(x: T) : T { return x }
|
||||
|
||||
fun <T> id(value: T): T = value
|
||||
|
||||
fun foreach(array: Array<Int>?, action: (Int)-> Unit) {
|
||||
fun foreach(array: Array<Int>, action: (Int)-> Unit) {
|
||||
for (el in array) {
|
||||
action(el) //exception through compilation (see below)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ fun Int.plus(a: Int?) = this + a.sure()
|
||||
|
||||
public open class PerfectNumberFinder() {
|
||||
open public fun isPerfect(number : Int) : Boolean {
|
||||
var factors : List<Int?>? = ArrayList<Int?>()
|
||||
var factors : List<Int?> = ArrayList<Int?>()
|
||||
factors?.add(1)
|
||||
factors?.add(number)
|
||||
for (i in 2..(Math.sqrt((number).toDouble()) - 1).toInt())
|
||||
|
||||
Reference in New Issue
Block a user