default -> companion: replace all mentions of default and default object

This commit is contained in:
Pavel V. Talanov
2015-03-16 14:56:06 +03:00
parent a0783757e8
commit 06916d98c6
1019 changed files with 2468 additions and 2469 deletions
@@ -1,5 +1,5 @@
class A {
default object {
companion object {
var xi = 0
var xin : Int? = 0
var xinn : Int? = null
@@ -1,5 +1,5 @@
class C() {
default object {
companion object {
fun create() = C()
}
}
@@ -1,7 +1,7 @@
fun Any.foo() = 1
class A {
default object
companion object
}
fun box() = if (A.foo() == 1) "OK" else "fail"
@@ -1,7 +1,7 @@
var global = 0;
class C {
default object {
companion object {
{
global = 1;
}
@@ -1,5 +1,5 @@
class A() {
default object {
companion object {
val value = 10
}
}
@@ -1,7 +1,7 @@
// EA-38323 - Illegal field modifiers in class: classObject field in C must be static and final
trait C {
default object {
companion object {
public val FOO: String = "OK"
}
}
@@ -1,5 +1,5 @@
class A {
default object {
companion object {
fun values() = "O"
fun valueOf() = "K"
}
@@ -1,7 +1,7 @@
class SomeClass { default object }
class SomeClass { companion object }
fun box() =
if ((SomeClass.toString() as java.lang.String).matches("SomeClass\\\$Default@[0-9a-fA-F]+"))
if ((SomeClass.toString() as java.lang.String).matches("SomeClass\\\$Companion@[0-9a-fA-F]+"))
"OK"
else
"Fail: $SomeClass"
@@ -1,5 +1,5 @@
class C() {
default object {
companion object {
private fun <T> create() = C()
}
@@ -1,5 +1,5 @@
open class Test {
default object {
companion object {
fun testStatic(ic: InnerClass): NotInnerClass = NotInnerClass(ic.value)
}
@@ -2,7 +2,7 @@ class A {
private val p: Int
get() = 4
default object B {
companion object B {
val p: Int
get() = 6
}
@@ -1,5 +1,5 @@
class C() {
default object Foo
companion object Foo
}
fun C.Foo.create() = 3
@@ -4,7 +4,7 @@ public class StockMarketTableModel() {
return COLUMN_TITLES?.size()!!
}
default object {
companion object {
private val COLUMN_TITLES : Array<Int?> = arrayOfNulls<Int>(10)
}
}
@@ -1,5 +1,5 @@
class A {
default object {
companion object {
val b = 0
val c = b
@@ -1,13 +1,13 @@
package x
class Outer() {
default object {
companion object {
class Inner() {
}
}
}
fun box (): String {
val inner = Outer.Default.Inner()
val inner = Outer.Companion.Inner()
return "OK"
}
@@ -1,7 +1,7 @@
open class Factory(p: Int)
class A {
default object : Factory(1)
companion object : Factory(1)
}
fun box() : String {
@@ -2,7 +2,7 @@ package mult_constructors_3_bug
public open class Identifier() {
private var myNullable : Boolean = true
default object {
companion object {
open public fun init(isNullable : Boolean) : Identifier {
val __ = Identifier()
__.myNullable = isNullable
@@ -1,5 +1,5 @@
class C() {
default object Foo {
companion object Foo {
fun create() = 3
}
}
@@ -1,5 +1,5 @@
class Foo private(val param: String = "OK") {
default object {
companion object {
val s = Foo()
}
}
@@ -1,5 +1,5 @@
class A {
default object {
companion object {
fun Int.foo(a: Int = 1): Int {
return a
}
@@ -1,4 +1,4 @@
fun foo(a: String = "Default", b: Int = 1, c: Long = 2): String {
fun foo(a: String = "Companion", b: Int = 1, c: Long = 2): String {
return "$a $b $c"
}
@@ -5,14 +5,14 @@ class Delegate<T>(var inner: T) {
class Foo (val f: Int) {
default object {
companion object {
val A: Foo by Delegate(Foo(11))
var B: Foo by Delegate(Foo(11))
}
}
trait FooTrait {
default object {
companion object {
val A: Foo by Delegate(Foo(11))
var B: Foo by Delegate(Foo(11))
}
@@ -3,7 +3,7 @@ import java.util.IdentityHashMap
class A {
var foo: Int by IntHandler
default object {
companion object {
var bar: Any? by AnyHandler
}
}
@@ -1,5 +1,5 @@
class A {
default object {
companion object {
fun invoke(i: Int) = i
}
}
@@ -8,8 +8,8 @@ internal final class A {
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
internal default object Default {
private constructor Default()
internal companion object Companion {
private constructor Companion()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
internal final fun invoke(/*0*/ i: kotlin.Int): kotlin.Int
@@ -3,7 +3,7 @@ trait B
fun B.invoke(i: Int) = i
class A {
default object: B {
companion object: B {
}
}
@@ -9,8 +9,8 @@ internal final class A {
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
internal default object Default : B {
private constructor Default()
internal companion object Companion : B {
private constructor Companion()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
@@ -1,6 +1,6 @@
class A {
class Nested {
default object {
companion object {
fun invoke(i: Int) = i
}
}
@@ -14,8 +14,8 @@ internal final class A {
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
internal default object Default {
private constructor Default()
internal companion object Companion {
private constructor Companion()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
internal final fun invoke(/*0*/ i: kotlin.Int): kotlin.Int
@@ -2,7 +2,7 @@ import A.Nested
class A {
class Nested {
default object {
companion object {
fun invoke(i: Int) = i
}
}
@@ -14,8 +14,8 @@ internal final class A {
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
internal default object Default {
private constructor Default()
internal companion object Companion {
private constructor Companion()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
internal final fun invoke(/*0*/ i: kotlin.Int): kotlin.Int
@@ -3,7 +3,7 @@ enum class Game {
PAPER
SCISSORS
default object {
companion object {
fun foo() = ROCK
val bar = PAPER
}
@@ -1,8 +1,8 @@
fun box() = if(Context.operatingSystemType == Context.Default.OsType.OTHER) "OK" else "fail"
fun box() = if(Context.operatingSystemType == Context.Companion.OsType.OTHER) "OK" else "fail"
public class Context
{
default object
companion object
{
public enum class OsType {
LINUX;
@@ -1,5 +1,5 @@
class A {
default object {}
companion object {}
enum class E {
OK
}
@@ -1,5 +1,5 @@
class A {
default object
companion object
}
val foo: Any.() -> Unit = {}
@@ -1,6 +1,6 @@
class Test(val prop: String) {
default object {
companion object {
public val prop : String = "CO";
}
@@ -1,7 +1,7 @@
package someTest
public class Some private(val v: String) {
default object {
companion object {
public fun init(v: String): Some {
return Some(v)
}
@@ -1,6 +1,6 @@
class Outer {
class Nested {
default object {
companion object {
val O = "O"
val K = "K"
}
@@ -2,7 +2,7 @@ package foo
fun box(): String {
try {
testDefaultObjectAccess()
testCompanionObjectAccess()
testInCall()
testDoubleConstants()
testFloatConstants()
@@ -18,7 +18,7 @@ fun box(): String {
return "OK"
}
fun testDefaultObjectAccess() {
fun testCompanionObjectAccess() {
val i = Int
val d = Double
val f = Float
@@ -73,7 +73,7 @@ fun testCallInterface() {
}
fun testLocalFun() {
fun Int.Default.LocalFun() : String = "LocalFun"
fun Int.Companion.LocalFun() : String = "LocalFun"
myAssertEquals("LocalFun", Int.LocalFun())
}
@@ -94,11 +94,11 @@ fun testVarTopField() {
fun test(a: Any) {}
var _field: Int = 0
var Int.Default.TopField : Int
var Int.Companion.TopField : Int
get() = _field
set(value) { _field = value };
fun Int.Default.TopFun() : String = "TopFun"
fun Int.Companion.TopFun() : String = "TopFun"
fun myAssertEquals<T>(a: T, b: T) {
if (a != b) throw Exception("$a != $b")
@@ -3,7 +3,7 @@ public abstract class FList<T>() {
public abstract val tail: FList<T>
public abstract val empty: Boolean
default object {
companion object {
val emptyFList = object: FList<Any>() {
public override val head: Any
get() = throw UnsupportedOperationException();
@@ -2,7 +2,7 @@ public open class Test() {
open public fun test() : Unit {
System.out?.println(hello)
}
default object {
companion object {
private val hello : String? = "Hello"
}
}
@@ -1,5 +1,5 @@
class Clazz {
default object {
companion object {
val a = object {
fun run(x: String) = x
}
@@ -3,7 +3,7 @@ class Identifier<T>(t : T?, myHasDollar : Boolean) {
public fun getName() : T? { return myT }
default object {
companion object {
open public fun init<T>(name : T?) : Identifier<T> {
val __ = Identifier<T>(name, false)
return __
@@ -4,7 +4,7 @@ import java.io.*
open class AllEvenNum() {
default object {
companion object {
open public fun main(args : Array<String?>?) : Unit {
var i : Int = 1
while ((i <= 100)) {
@@ -14,7 +14,7 @@ public open class Identifier<T>(myName : T?, myHasDollar : Boolean) {
return myName
}
default object {
companion object {
open public fun init<T>(name : T?) : Identifier<T> {
val __ = Identifier<T>(name, false)
return __
@@ -1,6 +1,6 @@
class Test {
default object {
companion object {
public val prop1 : Int = 10
@@ -1,7 +1,7 @@
abstract class ClassValAbstract {
abstract var a: Int
default object {
companion object {
val methods = (this as java.lang.Object).getClass()?.getClassLoader()?.loadClass("ClassValAbstract")?.getMethods()!!
}
}
@@ -8,7 +8,7 @@ class Identifier() {
return myNullable
}
default object {
companion object {
fun init(isNullable : Boolean) : Identifier {
val id = Identifier()
id.myNullable = isNullable
@@ -1,6 +1,6 @@
class TestObject()
{
default object {
companion object {
var prop: Int = 1
get() = $prop++
}
@@ -2,7 +2,7 @@ class CallbackBlock {}
public class Foo
{
default object {
companion object {
private var bar = 0
}
@@ -1,5 +1,5 @@
class Foo() {
default object {
companion object {
val bar = "OK";
var boo = "FAIL";
}
@@ -1,5 +1,5 @@
class Foo {
default object {
companion object {
val bar: String
{
@@ -1,6 +1,6 @@
class A {
default object {
companion object {
private var r: Int = 1;
fun test(): Int {
@@ -1,6 +1,6 @@
open class Bar<T>(val prop: String)
class Foo {
default object : Bar<Foo>("OK") {
companion object : Bar<Foo>("OK") {
val p = Foo.prop
val p2 = prop
val p3 = this.prop