Add toString() to Any, fix all tests

#KT-4517 Fixed
This commit is contained in:
Alexander Udalov
2014-02-06 23:43:12 +04:00
parent 6127d53eac
commit 3dcd85bdb4
55 changed files with 110 additions and 72 deletions
+2
View File
@@ -4,4 +4,6 @@ public open class Any {
public open fun equals(other: Any?): Boolean
public open fun hashCode(): Int
public open fun toString(): String
}
-3
View File
@@ -35,8 +35,6 @@ public trait CharSequence {
public fun get(index : Int) : Char
public val length : Int
public fun toString() : String
}
public class String() : Comparable<String>, CharSequence {
@@ -44,7 +42,6 @@ public class String() : Comparable<String>, CharSequence {
public override fun compareTo(that : String) : Int
public override fun get(index : Int) : Char
public override fun toString() : String
public override val length: Int
}
+7 -7
View File
@@ -34,7 +34,7 @@ public class ByteProgression(
override fun hashCode(): Int = 31 * (31 * start.toInt() + end) + increment
fun toString(): String = if (increment > 0) "$start..$end step $increment" else "$start downTo $end step ${-increment}"
override fun toString(): String = if (increment > 0) "$start..$end step $increment" else "$start downTo $end step ${-increment}"
}
public class CharProgression(
@@ -53,7 +53,7 @@ public class CharProgression(
override fun hashCode(): Int = 31 * (31 * start.toInt() + end) + increment
fun toString(): String = if (increment > 0) "$start..$end step $increment" else "$start downTo $end step ${-increment}"
override fun toString(): String = if (increment > 0) "$start..$end step $increment" else "$start downTo $end step ${-increment}"
}
public class ShortProgression(
@@ -72,7 +72,7 @@ public class ShortProgression(
override fun hashCode(): Int = 31 * (31 * start.toInt() + end) + increment
fun toString(): String = if (increment > 0) "$start..$end step $increment" else "$start downTo $end step ${-increment}"
override fun toString(): String = if (increment > 0) "$start..$end step $increment" else "$start downTo $end step ${-increment}"
}
public class IntProgression(
@@ -91,7 +91,7 @@ public class IntProgression(
override fun hashCode(): Int = 31 * (31 * start + end) + increment
fun toString(): String = if (increment > 0) "$start..$end step $increment" else "$start downTo $end step ${-increment}"
override fun toString(): String = if (increment > 0) "$start..$end step $increment" else "$start downTo $end step ${-increment}"
}
public class LongProgression(
@@ -110,7 +110,7 @@ public class LongProgression(
override fun hashCode(): Int = (31 * (31 * (start xor (start ushr 32)) + (end xor (end ushr 32))) + (increment xor (increment ushr 32))).toInt()
fun toString(): String = if (increment > 0) "$start..$end step $increment" else "$start downTo $end step ${-increment}"
override fun toString(): String = if (increment > 0) "$start..$end step $increment" else "$start downTo $end step ${-increment}"
}
public class FloatProgression(
@@ -130,7 +130,7 @@ public class FloatProgression(
override fun hashCode(): Int = 31 * (31 * java.lang.Float.floatToIntBits(start) + java.lang.Float.floatToIntBits(end)) + java.lang.Float.floatToIntBits(increment)
fun toString(): String = if (increment > 0) "$start..$end step $increment" else "$start downTo $end step ${-increment}"
override fun toString(): String = if (increment > 0) "$start..$end step $increment" else "$start downTo $end step ${-increment}"
}
public class DoubleProgression(
@@ -157,6 +157,6 @@ public class DoubleProgression(
return (31 * result + (temp xor (temp ushr 32))).toInt()
}
fun toString(): String = if (increment > 0) "$start..$end step $increment" else "$start downTo $end step ${-increment}"
override fun toString(): String = if (increment > 0) "$start..$end step $increment" else "$start downTo $end step ${-increment}"
}
+1 -1
View File
@@ -23,5 +23,5 @@ public trait Range<T : Comparable<T>> {
public fun contains(item: T): Boolean
public fun toString(): String = "$start..$end"
override fun toString(): String = "$start..$end"
}
+1 -1
View File
@@ -17,7 +17,7 @@
package jet
public class Unit private() {
fun toString() = "Unit.VALUE"
override fun toString() = "Unit.VALUE"
class object {
public val VALUE: Unit = Unit()
@@ -49,13 +49,13 @@ abstract class LazyJavaType(storageManager: StorageManager) : AbstractJetType(),
override fun getAnnotations() = Annotations.EMPTY
override fun toString(): String? {
override fun toString(): String {
if (!_typeConstructor.isComputed()) {
return "Type constructor is not computed"
}
if (!_arguments.isComputed()) {
return "" + getConstructor() + "<arguments are not computed>"
}
return super<AbstractJetType>.toString()
return super<AbstractJetType>.toString()!!
}
}