From 24d99eb33f8b37de7ee51d734da8f6abe6d5f0d4 Mon Sep 17 00:00:00 2001 From: Maxim Shafirov Date: Tue, 12 Feb 2013 20:04:22 +0400 Subject: [PATCH] adopt to broken inference --- libraries/stdlib/test/CompareTest.kt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/libraries/stdlib/test/CompareTest.kt b/libraries/stdlib/test/CompareTest.kt index 38cd0873177..54372c6cff6 100644 --- a/libraries/stdlib/test/CompareTest.kt +++ b/libraries/stdlib/test/CompareTest.kt @@ -8,7 +8,9 @@ class Item(val name: String, val rating: Int): Comparable { fun toString() = "Item($name, $rating)" public override fun compareTo(other: Item): Int { - return compareBy(this, other, { rating }, { name }) + var x : Comparable = rating + + return compareBy(this, other, { rating }, { name }) } } @@ -22,17 +24,17 @@ class CompareTest { } Test fun compareByNameFirst() { - val diff = compareBy(v1, v2, { name }, { rating }) + val diff = compareBy(v1, v2, { name }, { rating }) assertTrue(diff > 0) } Test fun compareByRatingFirst() { - val diff = compareBy(v1, v2, { rating }, { name }) + val diff = compareBy(v1, v2, { rating }, { name }) assertTrue(diff < 0) } Test fun compareSameObjectsByRatingFirst() { - val diff = compareBy(v1, v1, { rating }, { name }) + val diff = compareBy(v1, v1, { rating }, { name }) assertTrue(diff == 0) } @@ -50,7 +52,7 @@ class CompareTest { Test fun sortUsingCustomComparator() { val c = object : Comparator{ override fun compare(o1: Item, o2: Item): Int { - return compareBy(o1, o2, { name }, { rating }) + return compareBy(o1, o2, { name }, { rating }) } override fun equals(obj: Any?): Boolean { return this == obj @@ -65,4 +67,4 @@ class CompareTest { println("Sorted list in rating order $items") } -} \ No newline at end of file +}