Generate accessor for private companion object
This commit is contained in:
+17
@@ -0,0 +1,17 @@
|
||||
// !LANGUAGE: +ProperVisibilityForCompanionObjectInstanceField
|
||||
|
||||
class Outer {
|
||||
private companion object {
|
||||
val result = "OK"
|
||||
}
|
||||
|
||||
class Nested {
|
||||
fun foo() = object {
|
||||
override fun toString(): String = result
|
||||
}
|
||||
}
|
||||
|
||||
fun test() = Nested().foo().toString()
|
||||
}
|
||||
|
||||
fun box() = Outer().test()
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// !LANGUAGE: +ProperVisibilityForCompanionObjectInstanceField
|
||||
|
||||
inline fun <T> run(fn: () -> T) = fn()
|
||||
|
||||
class Outer {
|
||||
private companion object {
|
||||
val result = "OK"
|
||||
}
|
||||
|
||||
class Nested {
|
||||
fun foo() = run { result }
|
||||
}
|
||||
|
||||
fun test() = Nested().foo()
|
||||
}
|
||||
|
||||
fun box() = Outer().test()
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// !LANGUAGE: +ProperVisibilityForCompanionObjectInstanceField
|
||||
|
||||
class Outer {
|
||||
private companion object {
|
||||
val result = "OK"
|
||||
}
|
||||
|
||||
class Nested {
|
||||
fun foo() = { result }()
|
||||
}
|
||||
|
||||
fun test() = Nested().foo()
|
||||
}
|
||||
|
||||
fun box() = Outer().test()
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// !LANGUAGE: +ProperVisibilityForCompanionObjectInstanceField
|
||||
|
||||
class Outer {
|
||||
private companion object {
|
||||
val result = "OK"
|
||||
}
|
||||
|
||||
private inline fun bar() = result
|
||||
|
||||
class Nested {
|
||||
fun foo(x: Outer) = x.bar()
|
||||
}
|
||||
|
||||
fun test() = Nested().foo(this)
|
||||
}
|
||||
|
||||
fun box() = Outer().test()
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// !LANGUAGE: +ProperVisibilityForCompanionObjectInstanceField
|
||||
|
||||
class Outer {
|
||||
private companion object {
|
||||
val result = "OK"
|
||||
}
|
||||
|
||||
class Nested {
|
||||
fun foo() = result
|
||||
}
|
||||
|
||||
fun test() = Nested().foo()
|
||||
}
|
||||
|
||||
fun box() = Outer().test()
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// !LANGUAGE: +ProperVisibilityForCompanionObjectInstanceField
|
||||
|
||||
class Outer {
|
||||
private companion object {
|
||||
fun xo() = "O"
|
||||
fun xk() = "K"
|
||||
}
|
||||
|
||||
class Nested1 {
|
||||
fun foo() = xo()
|
||||
}
|
||||
|
||||
class Nested2 {
|
||||
fun bar() = xk()
|
||||
}
|
||||
|
||||
fun test() = Nested1().foo() + Nested2().bar()
|
||||
}
|
||||
|
||||
fun box() = Outer().test()
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// !LANGUAGE: +ProperVisibilityForCompanionObjectInstanceField
|
||||
|
||||
class Outer {
|
||||
private companion object {
|
||||
override fun toString(): String = "OK"
|
||||
}
|
||||
|
||||
class Nested {
|
||||
fun foo(): Any = Outer.Companion
|
||||
}
|
||||
|
||||
fun test() = Nested().foo().toString()
|
||||
}
|
||||
|
||||
fun box() = Outer().test()
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// !LANGUAGE: +ProperVisibilityForCompanionObjectInstanceField
|
||||
|
||||
class Outer {
|
||||
protected companion object {
|
||||
val result = "OK"
|
||||
}
|
||||
|
||||
class Nested {
|
||||
fun foo() = result
|
||||
}
|
||||
|
||||
fun test() = Nested().foo()
|
||||
}
|
||||
|
||||
fun box() = Outer().test()
|
||||
Reference in New Issue
Block a user