Files
kotlin-fork/compiler/testData/codegen/box/regressions/kt998.kt
T
Juan Chen 4f6fe1d0ca [FIR]: fix translation of top-level property accesses like array.indices
This commit addresses the following issues:

* accessors didn't take into account their property's receiver type,
which caused NoSuchMethod due to signature mismatch. Now the property's
receiver type is passed to Fir2Ir translation of accessors.

* property's parent was not class, e.g., kotlin.collections.indices.
Now the symbol table collects WrappedPropertyDescriptorWithContainerSource
besides WrappedFunctionDescriptorWithContainerSource, so that
facade classes for such properties can be generated before codegen.

* accessor's parent was not class. Now the containerSource of
the property descriptor is passed to accessor descriptor.
2020-02-25 12:13:42 +03:00

38 lines
680 B
Kotlin
Vendored

// KJS_WITH_FULL_RUNTIME
// WITH_RUNTIME
fun findPairless(a : IntArray) : Int {
loop@ for (i in a.indices) {
for (j in a.indices) {
if (i != j && a[i] == a[j]) continue@loop
}
return a[i]
}
return -1
}
fun hasDuplicates(a : IntArray) : Boolean {
var duplicate = false
loop@ for (i in a.indices) {
for (j in a.indices) {
if (i != j && a[i] == a[j]) {
duplicate = true
break@loop
}
}
}
return duplicate
}
fun box() : String {
val a = IntArray(5)
a[0] = 0
a[1] = 0
a[2] = 1
a[3] = 1
a[4] = 5
if(findPairless(a) != 5) return "fail"
return if(hasDuplicates(a)) "OK" else "fail"
}