diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java index f5d63e78780..f93656c9125 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java @@ -887,7 +887,11 @@ public class FunctionCodegen { iv.ifne(afterBarrier); - StackValue.none().put(bridge.getReturnType(), iv); + String shortName = getFqName(descriptor).shortName().asString(); + StackValue returnValue = + ("indexOf".equals(shortName) || "lastIndexOf".equals(shortName)) ? StackValue.constant(-1, Type.INT_TYPE) : StackValue.none(); + + returnValue.put(bridge.getReturnType(), iv); iv.areturn(bridge.getReturnType()); iv.visitLabel(afterBarrier); diff --git a/libraries/stdlib/test/collections/CollectionBehaviors.kt b/libraries/stdlib/test/collections/CollectionBehaviors.kt index 7f83aaf8b4a..432c03eaf6e 100644 --- a/libraries/stdlib/test/collections/CollectionBehaviors.kt +++ b/libraries/stdlib/test/collections/CollectionBehaviors.kt @@ -32,8 +32,8 @@ public fun CompareContext>.listBehavior() { propertyFails { this[size()] } - propertyEquals { indexOf(elementAtOrNull(0)) } - propertyEquals { lastIndexOf(elementAtOrNull(0)) } + propertyEquals { (this as List).indexOf(elementAtOrNull(0)) } + propertyEquals { (this as List).lastIndexOf(elementAtOrNull(0)) } propertyFails { subList(0, size() + 1)} propertyFails { subList(-1, 0)}