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
@@ -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