Fix with hack bridge codegen for indexOf and lastIndexOf methods. More sophisticated solution is required.

This commit is contained in:
Ilya Gorbunov
2015-10-14 22:48:43 +03:00
parent 5017e54022
commit 935024db4e
2 changed files with 7 additions and 3 deletions
@@ -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);
@@ -32,8 +32,8 @@ public fun <T> CompareContext<List<T>>.listBehavior() {
propertyFails { this[size()] }
propertyEquals { indexOf(elementAtOrNull(0)) }
propertyEquals { lastIndexOf(elementAtOrNull(0)) }
propertyEquals { (this as List<T?>).indexOf(elementAtOrNull(0)) }
propertyEquals { (this as List<T?>).lastIndexOf(elementAtOrNull(0)) }
propertyFails { subList(0, size() + 1)}
propertyFails { subList(-1, 0)}