Add toString() to Any, fix all tests
#KT-4517 Fixed
This commit is contained in:
@@ -100,6 +100,7 @@ public class IntrinsicMethods {
|
||||
declareIntrinsicFunction(typeName, Name.identifier("dec"), 0, DEC);
|
||||
declareIntrinsicFunction(typeName, Name.identifier("hashCode"), 0, HASH_CODE);
|
||||
declareIntrinsicFunction(typeName, Name.identifier("equals"), 1, EQUALS);
|
||||
declareIntrinsicFunction(typeName, Name.identifier("toString"), 0, TO_STRING);
|
||||
}
|
||||
|
||||
declareBinaryOp(Name.identifier("plus"), IADD);
|
||||
@@ -116,6 +117,7 @@ public class IntrinsicMethods {
|
||||
|
||||
declareIntrinsicFunction(Name.identifier("Boolean"), Name.identifier("not"), 0, new Not());
|
||||
declareIntrinsicFunction(Name.identifier("Boolean"), Name.identifier("equals"), 1, EQUALS);
|
||||
declareIntrinsicFunction(Name.identifier("Boolean"), Name.identifier("toString"), 0, TO_STRING);
|
||||
|
||||
declareIntrinsicFunction(Name.identifier("String"), Name.identifier("plus"), 1, new Concat());
|
||||
declareIntrinsicFunction(Name.identifier("CharSequence"), Name.identifier("get"), 1, new StringGetChar());
|
||||
|
||||
+8
-4
@@ -30,7 +30,8 @@ class JavaToKotlinMethodMapGenerated {
|
||||
|
||||
put(b, "java.lang.Object", "Any",
|
||||
pair("equals(java.lang.Object)", "fun equals(other: jet.Any?): jet.Boolean"),
|
||||
pair("hashCode()", "fun hashCode(): jet.Int")
|
||||
pair("hashCode()", "fun hashCode(): jet.Int"),
|
||||
pair("toString()", "fun toString(): jet.String")
|
||||
);
|
||||
|
||||
put(b, "java.lang.String", "String",
|
||||
@@ -47,7 +48,8 @@ class JavaToKotlinMethodMapGenerated {
|
||||
put(b, "java.lang.Throwable", "Throwable",
|
||||
pair("getCause()", "fun getCause(): jet.Throwable?"),
|
||||
pair("getMessage()", "fun getMessage(): jet.String?"),
|
||||
pair("printStackTrace()", "fun printStackTrace(): jet.Unit")
|
||||
pair("printStackTrace()", "fun printStackTrace(): jet.Unit"),
|
||||
pair("toString()", "fun toString(): jet.String")
|
||||
);
|
||||
|
||||
put(b, "java.lang.Comparable", "Comparable",
|
||||
@@ -58,12 +60,14 @@ class JavaToKotlinMethodMapGenerated {
|
||||
pair("equals(java.lang.Object)", "fun equals(other: jet.Any?): jet.Boolean"),
|
||||
pair("hashCode()", "fun hashCode(): jet.Int"),
|
||||
pair("name()", "fun name(): jet.String"),
|
||||
pair("ordinal()", "fun ordinal(): jet.Int")
|
||||
pair("ordinal()", "fun ordinal(): jet.Int"),
|
||||
pair("toString()", "fun toString(): jet.String")
|
||||
);
|
||||
|
||||
put(b, "java.lang.annotation.Annotation", "Annotation",
|
||||
pair("equals(java.lang.Object)", "fun equals(other: jet.Any?): jet.Boolean"),
|
||||
pair("hashCode()", "fun hashCode(): jet.Int")
|
||||
pair("hashCode()", "fun hashCode(): jet.Int"),
|
||||
pair("toString()", "fun toString(): jet.String")
|
||||
);
|
||||
|
||||
put(b, "java.lang.Iterable", "Iterable",
|
||||
|
||||
@@ -27,6 +27,7 @@ private val emptyUnaryFun: Function1<Long, Long> = { a -> 1.toLong() }
|
||||
private val unaryOperations: HashMap<UnaryOperationKey<*>, Pair<Function1<Any?, Any>, Function1<Long, Long>>>
|
||||
= hashMapOf<UnaryOperationKey<*>, Pair<Function1<Any?, Any>, Function1<Long, Long>>>(
|
||||
unaryOperation(BOOLEAN, "not", { a -> a.not() }, emptyUnaryFun),
|
||||
unaryOperation(BOOLEAN, "toString", { a -> a.toString() }, emptyUnaryFun),
|
||||
unaryOperation(BYTE, "toInt", { a -> a.toInt() }, emptyUnaryFun),
|
||||
unaryOperation(BYTE, "minus", { a -> a.minus() }, { a -> a.minus() }),
|
||||
unaryOperation(BYTE, "toChar", { a -> a.toChar() }, emptyUnaryFun),
|
||||
@@ -36,6 +37,7 @@ private val unaryOperations: HashMap<UnaryOperationKey<*>, Pair<Function1<Any?,
|
||||
unaryOperation(BYTE, "toFloat", { a -> a.toFloat() }, emptyUnaryFun),
|
||||
unaryOperation(BYTE, "toShort", { a -> a.toShort() }, emptyUnaryFun),
|
||||
unaryOperation(BYTE, "toByte", { a -> a.toByte() }, emptyUnaryFun),
|
||||
unaryOperation(BYTE, "toString", { a -> a.toString() }, emptyUnaryFun),
|
||||
unaryOperation(CHAR, "toInt", { a -> a.toInt() }, emptyUnaryFun),
|
||||
unaryOperation(CHAR, "minus", { a -> a.minus() }, emptyUnaryFun),
|
||||
unaryOperation(CHAR, "toChar", { a -> a.toChar() }, emptyUnaryFun),
|
||||
@@ -45,6 +47,7 @@ private val unaryOperations: HashMap<UnaryOperationKey<*>, Pair<Function1<Any?,
|
||||
unaryOperation(CHAR, "toFloat", { a -> a.toFloat() }, emptyUnaryFun),
|
||||
unaryOperation(CHAR, "toShort", { a -> a.toShort() }, emptyUnaryFun),
|
||||
unaryOperation(CHAR, "toByte", { a -> a.toByte() }, emptyUnaryFun),
|
||||
unaryOperation(CHAR, "toString", { a -> a.toString() }, emptyUnaryFun),
|
||||
unaryOperation(DOUBLE, "toInt", { a -> a.toInt() }, emptyUnaryFun),
|
||||
unaryOperation(DOUBLE, "minus", { a -> a.minus() }, emptyUnaryFun),
|
||||
unaryOperation(DOUBLE, "toChar", { a -> a.toChar() }, emptyUnaryFun),
|
||||
@@ -54,6 +57,7 @@ private val unaryOperations: HashMap<UnaryOperationKey<*>, Pair<Function1<Any?,
|
||||
unaryOperation(DOUBLE, "toFloat", { a -> a.toFloat() }, emptyUnaryFun),
|
||||
unaryOperation(DOUBLE, "toShort", { a -> a.toShort() }, emptyUnaryFun),
|
||||
unaryOperation(DOUBLE, "toByte", { a -> a.toByte() }, emptyUnaryFun),
|
||||
unaryOperation(DOUBLE, "toString", { a -> a.toString() }, emptyUnaryFun),
|
||||
unaryOperation(FLOAT, "toInt", { a -> a.toInt() }, emptyUnaryFun),
|
||||
unaryOperation(FLOAT, "minus", { a -> a.minus() }, emptyUnaryFun),
|
||||
unaryOperation(FLOAT, "toChar", { a -> a.toChar() }, emptyUnaryFun),
|
||||
@@ -63,6 +67,7 @@ private val unaryOperations: HashMap<UnaryOperationKey<*>, Pair<Function1<Any?,
|
||||
unaryOperation(FLOAT, "toFloat", { a -> a.toFloat() }, emptyUnaryFun),
|
||||
unaryOperation(FLOAT, "toShort", { a -> a.toShort() }, emptyUnaryFun),
|
||||
unaryOperation(FLOAT, "toByte", { a -> a.toByte() }, emptyUnaryFun),
|
||||
unaryOperation(FLOAT, "toString", { a -> a.toString() }, emptyUnaryFun),
|
||||
unaryOperation(INT, "inv", { a -> a.inv() }, emptyUnaryFun),
|
||||
unaryOperation(INT, "toInt", { a -> a.toInt() }, emptyUnaryFun),
|
||||
unaryOperation(INT, "minus", { a -> a.minus() }, { a -> a.minus() }),
|
||||
@@ -73,6 +78,7 @@ private val unaryOperations: HashMap<UnaryOperationKey<*>, Pair<Function1<Any?,
|
||||
unaryOperation(INT, "toDouble", { a -> a.toDouble() }, emptyUnaryFun),
|
||||
unaryOperation(INT, "toShort", { a -> a.toShort() }, emptyUnaryFun),
|
||||
unaryOperation(INT, "toByte", { a -> a.toByte() }, emptyUnaryFun),
|
||||
unaryOperation(INT, "toString", { a -> a.toString() }, emptyUnaryFun),
|
||||
unaryOperation(LONG, "inv", { a -> a.inv() }, emptyUnaryFun),
|
||||
unaryOperation(LONG, "toInt", { a -> a.toInt() }, emptyUnaryFun),
|
||||
unaryOperation(LONG, "minus", { a -> a.minus() }, { a -> a.minus() }),
|
||||
@@ -83,6 +89,7 @@ private val unaryOperations: HashMap<UnaryOperationKey<*>, Pair<Function1<Any?,
|
||||
unaryOperation(LONG, "toDouble", { a -> a.toDouble() }, emptyUnaryFun),
|
||||
unaryOperation(LONG, "toShort", { a -> a.toShort() }, emptyUnaryFun),
|
||||
unaryOperation(LONG, "toByte", { a -> a.toByte() }, emptyUnaryFun),
|
||||
unaryOperation(LONG, "toString", { a -> a.toString() }, emptyUnaryFun),
|
||||
unaryOperation(SHORT, "toInt", { a -> a.toInt() }, emptyUnaryFun),
|
||||
unaryOperation(SHORT, "minus", { a -> a.minus() }, { a -> a.minus() }),
|
||||
unaryOperation(SHORT, "toChar", { a -> a.toChar() }, emptyUnaryFun),
|
||||
@@ -92,6 +99,7 @@ private val unaryOperations: HashMap<UnaryOperationKey<*>, Pair<Function1<Any?,
|
||||
unaryOperation(SHORT, "toFloat", { a -> a.toFloat() }, emptyUnaryFun),
|
||||
unaryOperation(SHORT, "toShort", { a -> a.toShort() }, emptyUnaryFun),
|
||||
unaryOperation(SHORT, "toByte", { a -> a.toByte() }, emptyUnaryFun),
|
||||
unaryOperation(SHORT, "toString", { a -> a.toString() }, emptyUnaryFun),
|
||||
unaryOperation(STRING, "toString", { a -> a.toString() }, emptyUnaryFun)
|
||||
)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
trait Trait {
|
||||
fun foo() = "O"
|
||||
fun toString() = "K"
|
||||
override fun toString() = "K"
|
||||
}
|
||||
|
||||
class SimpleClass : Trait
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class mInt(val i : Int) {
|
||||
fun toString() : String = "mint: $i"
|
||||
override fun toString() : String = "mint: $i"
|
||||
fun plus(i : Int) = mInt(this.i + i)
|
||||
fun inc() = mInt(i + 1)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ class MyString {
|
||||
return this
|
||||
}
|
||||
|
||||
fun toString(): String {
|
||||
override fun toString(): String {
|
||||
return s
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ class MyString {
|
||||
return this
|
||||
}
|
||||
|
||||
fun toString(): String {
|
||||
override fun toString(): String {
|
||||
return s
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ class MyString {
|
||||
return this
|
||||
}
|
||||
|
||||
fun toString(): String {
|
||||
override fun toString(): String {
|
||||
return s
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ class MyString {
|
||||
return this
|
||||
}
|
||||
|
||||
fun toString(): String {
|
||||
override fun toString(): String {
|
||||
return s
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ class A {
|
||||
|
||||
{
|
||||
a = object {
|
||||
fun toString(): String = "OK"
|
||||
override fun toString(): String = "OK"
|
||||
}.toString()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class A(
|
||||
val a: String = object {
|
||||
fun toString(): String = "OK"
|
||||
override fun toString(): String = "OK"
|
||||
}.toString()
|
||||
)
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package pack
|
||||
open class A(val value: String )
|
||||
|
||||
class B(value: String) : A(value) {
|
||||
fun toString() = "B($value)";
|
||||
override fun toString() = "B($value)";
|
||||
}
|
||||
|
||||
fun box() = if (B("4").toString() == "B(4)") "OK" else "fail"
|
||||
|
||||
@@ -7,7 +7,7 @@ class JsonArray {
|
||||
}
|
||||
|
||||
class ProjectInfo {
|
||||
public fun toString(): String = "OK"
|
||||
override fun toString(): String = "OK"
|
||||
}
|
||||
|
||||
public trait Parser<in IN: Any, out OUT: Any> {
|
||||
|
||||
@@ -4,7 +4,7 @@ trait Trait : Base {
|
||||
private val value : String
|
||||
get() = "OK"
|
||||
|
||||
fun toString() = object {
|
||||
override fun toString() = object {
|
||||
fun foo() = value
|
||||
}.foo()
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
data class A(val x: Int) {
|
||||
fun toString(): String = "!"
|
||||
override fun toString(): String = "!"
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
trait SuperTrait {
|
||||
public fun toString(): String = "!"
|
||||
override fun toString(): String = "!"
|
||||
}
|
||||
|
||||
data class A(val x: Int): SuperTrait {
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.util.ArrayList
|
||||
public class User(val firstName: String,
|
||||
val lastName: String,
|
||||
val age: Int) {
|
||||
fun toString() = "$firstName $lastName, age $age"
|
||||
override fun toString() = "$firstName $lastName, age $age"
|
||||
}
|
||||
|
||||
public fun <T: Comparable<T>> Collection<T>.testMin(): T? {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class A(private var v1: String) {
|
||||
private var v2 = v1
|
||||
fun toString(): String { return "A[v1=$v1,v2=$v2]" }
|
||||
override fun toString(): String { return "A[v1=$v1,v2=$v2]" }
|
||||
}
|
||||
@@ -52,7 +52,7 @@ fun main(args : Array<String>) {
|
||||
trait Element {
|
||||
fun render(builder : StringBuilder, indent : String)
|
||||
|
||||
fun toString() : String? {
|
||||
override fun toString() : String {
|
||||
val builder = StringBuilder()
|
||||
render(builder, "")
|
||||
return builder.toString()
|
||||
|
||||
@@ -183,7 +183,7 @@ fun returnFunctionLiteral(a: Any?): Function0<Int> =
|
||||
fun mergeAutocasts(a: Any?) {
|
||||
if (a is String || a is Int) {
|
||||
a.<!UNRESOLVED_REFERENCE!>compareTo<!>("")
|
||||
a.toString()
|
||||
<!DEBUG_INFO_AUTOCAST!>a<!>.toString()
|
||||
}
|
||||
if (a is Int || a is String) {
|
||||
a.<!UNRESOLVED_REFERENCE!>compareTo<!>("")
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
class Test(private val a: Int b: Int private val c: Int) {
|
||||
fun toString() = "$a $c"
|
||||
override fun toString() = "$a $c"
|
||||
}
|
||||
@@ -53,6 +53,9 @@ JetFile: MissingCommaInConstructorValueParameterList.kt
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiWhiteSpace('\n ')
|
||||
FUN
|
||||
MODIFIER_LIST
|
||||
PsiElement(override)('override')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(fun)('fun')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('toString')
|
||||
|
||||
@@ -52,33 +52,44 @@ Trait:ClassDescriptorWithResolutionScopes
|
||||
a:ValueParameterDescriptor
|
||||
fake <class-object-for-Class>.equals:SimpleFunctionDescriptor
|
||||
fake <class-object-for-Class>.hashCode:SimpleFunctionDescriptor
|
||||
fake <class-object-for-Class>.toString:SimpleFunctionDescriptor
|
||||
fake <class-object-for-NestedClass>.equals:SimpleFunctionDescriptor
|
||||
fake <class-object-for-NestedClass>.hashCode:SimpleFunctionDescriptor
|
||||
fake <class-object-for-NestedClass>.toString:SimpleFunctionDescriptor
|
||||
fake <class-object-for-NestedObject>.equals:SimpleFunctionDescriptor
|
||||
fake <class-object-for-NestedObject>.hashCode:SimpleFunctionDescriptor
|
||||
fake <class-object-for-NestedObject>.nestedFunc:SimpleFunctionDescriptor
|
||||
fake <class-object-for-NestedObject>.toString:SimpleFunctionDescriptor
|
||||
fake <class-object-for-Object>.<get-objProp>:PropertyGetterDescriptor
|
||||
fake <class-object-for-Object>.equals:SimpleFunctionDescriptor
|
||||
fake <class-object-for-Object>.hashCode:SimpleFunctionDescriptor
|
||||
fake <class-object-for-Object>.objFunc:SimpleFunctionDescriptor
|
||||
fake <class-object-for-Object>.objProp:PropertyDescriptor
|
||||
fake <class-object-for-Object>.toString:SimpleFunctionDescriptor
|
||||
fake Class.<get-traitProp>:PropertyGetterDescriptor
|
||||
fake Class.equals:SimpleFunctionDescriptor
|
||||
fake Class.hashCode:SimpleFunctionDescriptor
|
||||
fake Class.toString:SimpleFunctionDescriptor
|
||||
fake Class.traitFunc:SimpleFunctionDescriptor
|
||||
fake Class.traitProp:PropertyDescriptor
|
||||
fake NestedClass.equals:SimpleFunctionDescriptor
|
||||
fake NestedClass.hashCode:SimpleFunctionDescriptor
|
||||
fake NestedClass.toString:SimpleFunctionDescriptor
|
||||
fake NestedObject.equals:SimpleFunctionDescriptor
|
||||
fake NestedObject.hashCode:SimpleFunctionDescriptor
|
||||
fake NestedObject.toString:SimpleFunctionDescriptor
|
||||
fake NestedTrait.equals:SimpleFunctionDescriptor
|
||||
fake NestedTrait.hashCode:SimpleFunctionDescriptor
|
||||
fake NestedTrait.toString:SimpleFunctionDescriptor
|
||||
fake Object.equals:SimpleFunctionDescriptor
|
||||
fake Object.hashCode:SimpleFunctionDescriptor
|
||||
fake Object.toString:SimpleFunctionDescriptor
|
||||
fake Outer.equals:SimpleFunctionDescriptor
|
||||
fake Outer.hashCode:SimpleFunctionDescriptor
|
||||
fake Outer.toString:SimpleFunctionDescriptor
|
||||
fake Trait.equals:SimpleFunctionDescriptor
|
||||
fake Trait.hashCode:SimpleFunctionDescriptor
|
||||
fake Trait.toString:SimpleFunctionDescriptor
|
||||
func.this:ReceiverParameterDescriptor
|
||||
innerTest.<get-prop>:PropertyGetterDescriptor
|
||||
innerTest.<get-propVar>:PropertyGetterDescriptor
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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}"
|
||||
}
|
||||
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
+2
-2
@@ -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()!!
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ class GenerateProgressions(out: PrintWriter) : BuiltInsSourceGenerator(out) {
|
||||
|
||||
override fun hashCode(): Int $hashCode
|
||||
|
||||
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}\""}
|
||||
}""")
|
||||
out.println()
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ fun returnFunctionLiteral(<info>a</info>: Any?): Function0<Int> =
|
||||
fun merge<TYPO descr="Typo: In word 'Autocasts'">Autocasts</TYPO>(a: Any?) {
|
||||
if (a is String || a is Int) {
|
||||
a.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: compareTo">compareTo</error>("")
|
||||
a.toString()
|
||||
<info descr="Automatically cast to jet.Any"><info>a</info></info>.toString()
|
||||
}
|
||||
if (a is Int || a is String) {
|
||||
a.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: compareTo">compareTo</error>("")
|
||||
|
||||
@@ -19,4 +19,7 @@ class C : Base<String, C, Unit>() {
|
||||
return super<Base>.hashCode()
|
||||
}
|
||||
override val method: (String?) -> String = ?
|
||||
override fun toString(): String {
|
||||
return super<Base>.toString()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,4 +30,7 @@ class C : A(), B {
|
||||
super<A>.publicFun()
|
||||
}
|
||||
override val publicProperty: Int = 0
|
||||
override fun toString(): String {
|
||||
return super<A>.toString()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,4 +17,7 @@ class C : A {
|
||||
override fun hashCode(): Int {
|
||||
return super<A>.hashCode()
|
||||
}
|
||||
override fun toString(): String {
|
||||
return super<A>.toString()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,9 @@ class C : A() {
|
||||
override fun hashCode(): Int {
|
||||
return super<A>.hashCode()
|
||||
}
|
||||
override fun toString(): String {
|
||||
return super<A>.toString()
|
||||
}
|
||||
|
||||
/*
|
||||
Some another comment
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
val x = 5.<ref>toString()
|
||||
//jet/Library.kt:toString
|
||||
//jet/Any.kt:toString
|
||||
|
||||
@@ -51,5 +51,5 @@ public class StringBuilder() : Appendable {
|
||||
//TODO
|
||||
//override fun append(csq: CharSequence?, start: Int, end: Int): StringBuilder = js.noImpl
|
||||
public fun append(obj: Any?): StringBuilder = js.noImpl
|
||||
public fun toString(): String = js.noImpl
|
||||
override fun toString(): String = js.noImpl
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public abstract class AbstractList<E>() : AbstractCollection<E>(), MutableList<E
|
||||
|
||||
override fun equals(other: Any?): Boolean = js.noImpl
|
||||
|
||||
fun toString(): String = js.noImpl
|
||||
override fun toString(): String = js.noImpl
|
||||
}
|
||||
|
||||
library
|
||||
|
||||
@@ -8,8 +8,7 @@ public class Pair<A, B> (
|
||||
public fun component1(): A = first
|
||||
public fun component2(): B = second
|
||||
|
||||
public fun toString(): String = "($first, $second)"
|
||||
|
||||
override fun toString(): String = "($first, $second)"
|
||||
}
|
||||
|
||||
public class Triple<A, B, C> (
|
||||
@@ -21,5 +20,5 @@ public class Triple<A, B, C> (
|
||||
public fun component2(): B = second
|
||||
public fun component3(): C = third
|
||||
|
||||
public fun toString(): String = "($first, $second, $third)"
|
||||
override fun toString(): String = "($first, $second, $third)"
|
||||
}
|
||||
@@ -49,7 +49,7 @@ trait CallInfo {
|
||||
|
||||
fun constructSafeCallIsNeeded(result: JsExpression): JsExpression
|
||||
|
||||
fun toString(): String {
|
||||
override fun toString(): String {
|
||||
val location = DiagnosticUtils.atLocation(context.bindingContext(), callableDescriptor)
|
||||
val name = callableDescriptor.getName().asString()
|
||||
return "callableDescriptor: $name at $location; thisObject: $thisObject; receiverObject: $receiverObject"
|
||||
|
||||
@@ -7,13 +7,13 @@ public fun toString(): String = ""
|
||||
public class PublicClass {
|
||||
override fun equals(a: Any?): Boolean = this.identityEquals(a)
|
||||
override fun hashCode(): Int = 0
|
||||
public fun toString(): String = "PublicClass"
|
||||
override fun toString(): String = "PublicClass"
|
||||
}
|
||||
|
||||
internal class InternalClass {
|
||||
override fun equals(a: Any?): Boolean = this.identityEquals(a)
|
||||
override fun hashCode(): Int = 1
|
||||
public fun toString(): String = "InternalClass"
|
||||
override fun toString(): String = "InternalClass"
|
||||
|
||||
// overloads
|
||||
public fun equals(a: Any?, b: Any?): Boolean = a == b
|
||||
@@ -24,7 +24,7 @@ internal class InternalClass {
|
||||
private class PrivateClass {
|
||||
override fun equals(a: Any?): Boolean = this.identityEquals(a)
|
||||
override fun hashCode(): Int = 2
|
||||
public fun toString(): String = "InternalClass"
|
||||
override fun toString(): String = "InternalClass"
|
||||
|
||||
// overloads
|
||||
public fun equals(a: Any?, b: Any?): Boolean = a == b
|
||||
|
||||
@@ -3,7 +3,7 @@ package foo
|
||||
var i = 0
|
||||
|
||||
class A() {
|
||||
fun toString(): String {
|
||||
override fun toString(): String {
|
||||
i++
|
||||
return "bar"
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package foo
|
||||
|
||||
class A(var i : Int) {
|
||||
fun toString() = "a$i"
|
||||
override fun toString() = "a$i"
|
||||
}
|
||||
|
||||
fun box() : Boolean {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package foo
|
||||
|
||||
class Foo(val name: String) {
|
||||
public fun toString(): String {
|
||||
override fun toString(): String {
|
||||
return name + "S"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ fun main(args: Array<String>) {
|
||||
trait Element {
|
||||
fun render(builder: StringBuilder, indent: String)
|
||||
|
||||
fun toString(): String? {
|
||||
override fun toString(): String {
|
||||
val builder = StringBuilder()
|
||||
render(builder, "")
|
||||
return builder.toString()
|
||||
|
||||
@@ -62,7 +62,7 @@ abstract class Tag(val name : String) : Element() {
|
||||
|
||||
}
|
||||
|
||||
fun toString(): String {
|
||||
override fun toString(): String {
|
||||
val builder = StringBuilder()
|
||||
appendTo(builder)
|
||||
return builder.toString()!!
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.util.ArrayList
|
||||
public class ChangeEvent(val source: Any, val name: String, val oldValue: Any?, val newValue: Any?) {
|
||||
var propogationId: Any? = null
|
||||
|
||||
public fun toString() : String = "ChangeEvent($name, $oldValue, $newValue)"
|
||||
override fun toString(): String = "ChangeEvent($name, $oldValue, $newValue)"
|
||||
}
|
||||
|
||||
public trait ChangeListener {
|
||||
|
||||
@@ -15,7 +15,7 @@ class StringTemplate(val values : Array<Any?>) {
|
||||
/**
|
||||
* Converts the template into a String
|
||||
*/
|
||||
public fun toString() : String {
|
||||
override fun toString() : String {
|
||||
val out = StringBuilder()
|
||||
forEach{ out.append(it) }
|
||||
return out.toString()
|
||||
@@ -93,7 +93,7 @@ public open class ToStringFormatter : Formatter {
|
||||
|
||||
var nullString : String = "null"
|
||||
|
||||
public open fun toString() : String = "ToStringFormatter"
|
||||
override fun toString() : String = "ToStringFormatter"
|
||||
|
||||
public override fun format(out : Appendable, value : Any?) {
|
||||
if (value == null) {
|
||||
@@ -121,7 +121,7 @@ public val defaultLocale : Locale = Locale.getDefault()
|
||||
*/
|
||||
public open class LocaleFormatter(val locale : Locale = defaultLocale) : ToStringFormatter() {
|
||||
|
||||
public override fun toString() : String = "LocaleFormatter{$locale}"
|
||||
override fun toString() : String = "LocaleFormatter{$locale}"
|
||||
|
||||
public var numberFormat : NumberFormat = NumberFormat.getInstance(locale)!!
|
||||
|
||||
@@ -151,7 +151,7 @@ public open class LocaleFormatter(val locale : Locale = defaultLocale) : ToStrin
|
||||
*/
|
||||
public class HtmlFormatter(locale : Locale = defaultLocale) : LocaleFormatter(locale) {
|
||||
|
||||
public override fun toString() : String = "HtmlFormatter{$locale}"
|
||||
override fun toString() : String = "HtmlFormatter{$locale}"
|
||||
|
||||
public override fun format(out : Appendable, value : Any?) {
|
||||
if (value is Node) {
|
||||
|
||||
@@ -5,7 +5,7 @@ import kotlin.test.*
|
||||
import org.junit.Test
|
||||
|
||||
class Item(val name: String, val rating: Int): Comparable<Item> {
|
||||
fun toString() = "Item($name, $rating)"
|
||||
override fun toString() = "Item($name, $rating)"
|
||||
|
||||
public override fun compareTo(other: Item): Int {
|
||||
return compareBy(this, other, { rating }, { name })
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.junit.Test as test
|
||||
|
||||
class ListTest {
|
||||
|
||||
test fun toString() {
|
||||
test fun _toString() {
|
||||
val data = arrayList("foo", "bar")
|
||||
assertEquals("[foo, bar]", data.toString())
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ class Customer() : ChangeSupport() {
|
||||
$city = value
|
||||
}
|
||||
|
||||
fun toString() = "Customer($name, $city)"
|
||||
override fun toString() = "Customer($name, $city)"
|
||||
}
|
||||
|
||||
class MyChangeListener() : ChangeListener {
|
||||
|
||||
@@ -33,7 +33,7 @@ class Failure(val message : String) : ParseResult<Nothing> {
|
||||
}
|
||||
|
||||
open class Token(val text : String) {
|
||||
fun toString() = text
|
||||
override fun toString() = text
|
||||
}
|
||||
object LPAR : Token("(")
|
||||
object RPAR : Token(")")
|
||||
|
||||
@@ -934,7 +934,7 @@ abstract class KNamed(val name: String, model: KModel, declarationDescriptor: De
|
||||
|
||||
open fun equals(other: KPackage) = name == other.name
|
||||
|
||||
open fun toString() = name
|
||||
override fun toString() = name
|
||||
}
|
||||
|
||||
|
||||
@@ -957,7 +957,7 @@ class KPackage(model: KModel, val descriptor: PackageFragmentDescriptor,
|
||||
|
||||
fun equals(other: KPackage) = name == other.name
|
||||
|
||||
fun toString() = "KPackage($name)"
|
||||
override fun toString() = "KPackage($name)"
|
||||
|
||||
fun getClass(descriptor: ClassDescriptor): KClass {
|
||||
val name = descriptor.getName().asString()
|
||||
@@ -1089,7 +1089,7 @@ class KClass(
|
||||
|
||||
fun equals(other: KClass) = name == other.name
|
||||
|
||||
fun toString() = "$kind($name)"
|
||||
override fun toString() = "$kind($name)"
|
||||
|
||||
fun isApi(): Boolean {
|
||||
val visibility = descriptor.getVisibility()
|
||||
@@ -1185,7 +1185,7 @@ class KFunction(val descriptor: CallableDescriptor, val owner: KClassOrPackage,
|
||||
fun equals(other: KFunction) = name == other.name && this.parameterTypeText == other.parameterTypeText &&
|
||||
this.extensionClass == other.extensionClass && this.owner == other.owner
|
||||
|
||||
fun toString() = "fun $name($parameterTypeText): $returnType"
|
||||
override fun toString() = "fun $name($parameterTypeText): $returnType"
|
||||
|
||||
public val link: String = "$name($parameterTypeText)"
|
||||
|
||||
@@ -1212,13 +1212,13 @@ class KProperty(val owner: KClassOrPackage, val descriptor: PropertyDescriptor,
|
||||
return visibility.isPublicAPI()
|
||||
}
|
||||
|
||||
fun toString() = "property $name"
|
||||
override fun toString() = "property $name"
|
||||
}
|
||||
|
||||
class KParameter(val descriptor: ValueParameterDescriptor, val name: String,
|
||||
var aType: KType): KAnnotated(aType.model, aType.declarationDescriptor) {
|
||||
|
||||
fun toString() = "$name: ${aType.name}"
|
||||
override fun toString() = "$name: ${aType.name}"
|
||||
|
||||
fun isVarArg(): Boolean = descriptor.getVarargElementType() != null
|
||||
|
||||
@@ -1237,12 +1237,12 @@ class KTypeParameter(val name: String,
|
||||
model: KModel,
|
||||
var extends: List<KClass> = arrayList<KClass>()): KAnnotated(model, descriptor) {
|
||||
|
||||
fun toString() = "$name"
|
||||
override fun toString() = "$name"
|
||||
}
|
||||
|
||||
class KAnnotation(var klass: KClass): KAnnotated(klass.model, klass.descriptor) {
|
||||
|
||||
// TODO add some parameter values?
|
||||
|
||||
fun toString() = "@$klass.simpleName"
|
||||
override fun toString() = "@$klass.simpleName"
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -6,7 +6,7 @@ import org.jetbrains.kotlin.doc.model.*
|
||||
class SearchXmlTemplate(val model: KModel): KDocTemplate() {
|
||||
|
||||
class Search(val name: String, val href: String, val kind: String) {
|
||||
fun toString() = "Search($name, $href, $kind)"
|
||||
override fun toString() = "Search($name, $href, $kind)"
|
||||
}
|
||||
|
||||
override fun render() {
|
||||
|
||||
@@ -2,7 +2,7 @@ package sample
|
||||
|
||||
/** A Comment */
|
||||
public class Person(val name: String, val city: String) {
|
||||
fun toString(): String = "Person($name, $city)"
|
||||
override fun toString(): String = "Person($name, $city)"
|
||||
|
||||
public fun hello(): String = "Hello $name"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user