Move: Nested classes support

#KT-9027 In Progress
This commit is contained in:
Alexey Sedunov
2016-01-12 20:41:02 +03:00
parent 0304bd1dc1
commit d662b02e95
159 changed files with 2588 additions and 197 deletions
@@ -0,0 +1,14 @@
package test
class A {
inner class OuterOuterY
inner class B {
inner class C {
fun test() {
OuterOuterY()
this@A.OuterOuterY()
}
}
}
}
@@ -0,0 +1,14 @@
package test
class A {
inner class OuterOuterY
inner class B {
inner class <caret>C {
fun test() {
OuterOuterY()
this@A.OuterOuterY()
}
}
}
}
@@ -0,0 +1,2 @@
Indirect outer instances won't be extracted: OuterOuterY()
Indirect outer instances won't be extracted: this@A
@@ -0,0 +1,6 @@
{
"mainFile": "test.kt",
"type": "MOVE_KOTLIN_NESTED_CLASS",
"outerInstanceParameter": "a",
"withRuntime": "true"
}
@@ -0,0 +1,26 @@
package test
class C(private val b: A.B) {
fun test() {
A.X()
A.Companion.Y()
A.foo(A.bar)
//1.extFoo(1.extBar) // conflict
b.OuterY()
b.outerFoo(b.outerBar)
b.OuterY()
b.outerFoo(b.outerBar)
A.O.Y()
A.O.foo(A.O.bar)
with (A.O) {
A.Companion.Y()
foo(bar)
1.extFoo(1.extBar)
}
}
}
@@ -0,0 +1,42 @@
package test
inline fun <T, R> with(receiver: T, block: T.() -> R): R = receiver.block()
class A {
class X {
}
companion object {
class Y
fun foo(n: Int) {}
val bar = 1
fun Int.extFoo(n: Int) {}
val Int.extBar: Int get() = 1
}
object O {
class Y
fun foo(n: Int) {}
val bar = 1
fun Int.extFoo(n: Int) {}
val Int.extBar: Int get() = 1
}
inner class B {
inner class OuterY
fun outerFoo(n: Int) {}
val outerBar = 1
}
}
@@ -0,0 +1,10 @@
package test2;
import test.A;
import test.C;
class Test {
C foo() {
return new C(new A().new B());
}
}
@@ -0,0 +1,10 @@
package test2;
import test.A;
import test.C;
class Test {
C foo() {
return new C(new A().new B());
}
}
@@ -0,0 +1,10 @@
package test2;
import test.A;
import test.C;
class Test {
C foo() {
return new C(new A().new B());
}
}
@@ -0,0 +1,8 @@
package test2
import test.A
import test.C
fun foo(): C {
return C(A().B())
}
@@ -0,0 +1,8 @@
package test2
import test.A
import test.C
fun foo2(): C {
return C(A().B())
}
@@ -0,0 +1,9 @@
package test2
import test.A
import test.A.B
import test.C
fun foo2(): C {
return C(A().B())
}
@@ -0,0 +1,66 @@
package test
inline fun <T, R> with(receiver: T, block: T.() -> R): R = receiver.block()
class A {
class X {
}
companion object {
class Y
fun foo(n: Int) {}
val bar = 1
fun Int.extFoo(n: Int) {}
val Int.extBar: Int get() = 1
}
object O {
class Y
fun foo(n: Int) {}
val bar = 1
fun Int.extFoo(n: Int) {}
val Int.extBar: Int get() = 1
}
inner class B {
inner class OuterY
fun outerFoo(n: Int) {}
val outerBar = 1
inner class <caret>C {
fun test() {
X()
Y()
foo(bar)
//1.extFoo(1.extBar) // conflict
OuterY()
outerFoo(outerBar)
this@B.OuterY()
this@B.outerFoo(this@B.outerBar)
O.Y()
O.foo(O.bar)
with (O) {
Y()
foo(bar)
1.extFoo(1.extBar)
}
}
}
}
}
@@ -0,0 +1,9 @@
package test2;
import test.A;
class Test {
A.B.C foo() {
return new A().new B().new C();
}
}
@@ -0,0 +1,10 @@
package test2;
import test.A;
import test.A.B.C;
class Test {
C foo() {
return new A().new B().new C();
}
}
@@ -0,0 +1,10 @@
package test2;
import test.A;
import test.A.B;
class Test {
B.C foo() {
return new A().new B().new C();
}
}
@@ -0,0 +1,7 @@
package test2
import test.A
fun foo(): A.B.C {
return A().B().C()
}
@@ -0,0 +1,8 @@
package test2
import test.A
import test.A.B.C
fun foo2(): C {
return A().B().C()
}
@@ -0,0 +1,8 @@
package test2
import test.A
import test.A.B
fun foo2(): B.C {
return A().B().C()
}
@@ -0,0 +1,6 @@
{
"mainFile": "test.kt",
"type": "MOVE_KOTLIN_NESTED_CLASS",
"outerInstanceParameter": "b",
"withRuntime": "true"
}
@@ -0,0 +1,20 @@
package test
class C {
fun test() {
A.X()
A.Companion.Y()
A.foo(A.bar)
//1.extFoo(1.extBar) // conflict
A.O.Y()
A.O.foo(A.O.bar)
with (A.O) {
A.Companion.Y()
foo(bar)
1.extFoo(1.extBar)
}
}
}
@@ -0,0 +1,36 @@
package test
inline fun <T, R> with(receiver: T, block: T.() -> R): R = receiver.block()
class A {
class X {
}
companion object {
class Y
fun foo(n: Int) {}
val bar = 1
fun Int.extFoo(n: Int) {}
val Int.extBar: Int get() = 1
}
object O {
class Y
fun foo(n: Int) {}
val bar = 1
fun Int.extFoo(n: Int) {}
val Int.extBar: Int get() = 1
}
class B {
}
}
@@ -0,0 +1,9 @@
package test2;
import test.C;
class Test {
C foo() {
return new C();
}
}
@@ -0,0 +1,9 @@
package test2;
import test.C;
class Test {
C foo() {
return new C();
}
}
@@ -0,0 +1,9 @@
package test2;
import test.C;
class Test {
C foo() {
return new C();
}
}
@@ -0,0 +1,8 @@
package test2
import test.A
import test.C
fun foo(): C {
return C()
}
@@ -0,0 +1,7 @@
package test2
import test.C
fun foo(): C {
return C()
}
@@ -0,0 +1,8 @@
package test2
import test.A.B
import test.C
fun foo(): C {
return C()
}
@@ -0,0 +1,54 @@
package test
inline fun <T, R> with(receiver: T, block: T.() -> R): R = receiver.block()
class A {
class X {
}
companion object {
class Y
fun foo(n: Int) {}
val bar = 1
fun Int.extFoo(n: Int) {}
val Int.extBar: Int get() = 1
}
object O {
class Y
fun foo(n: Int) {}
val bar = 1
fun Int.extFoo(n: Int) {}
val Int.extBar: Int get() = 1
}
class B {
class <caret>C {
fun test() {
X()
Y()
foo(bar)
//1.extFoo(1.extBar) // conflict
O.Y()
O.foo(O.bar)
with (O) {
Y()
foo(bar)
1.extFoo(1.extBar)
}
}
}
}
}
@@ -0,0 +1,9 @@
package test2;
import test.A;
class Test {
A.B.C foo() {
return new A.B.C();
}
}
@@ -0,0 +1,9 @@
package test2;
import test.A.B.C;
class Test {
C foo() {
return new C();
}
}
@@ -0,0 +1,9 @@
package test2;
import test.A.B;
class Test {
B.C foo() {
return new B.C();
}
}
@@ -0,0 +1,7 @@
package test2
import test.A
fun foo(): A.B.C {
return A.B.C()
}
@@ -0,0 +1,7 @@
package test2
import test.A.B.C
fun foo(): C {
return C()
}
@@ -0,0 +1,7 @@
package test2
import test.A.B
fun foo(): B.C {
return B.C()
}
@@ -0,0 +1,5 @@
{
"mainFile": "test.kt",
"type": "MOVE_KOTLIN_NESTED_CLASS",
"withRuntime": "true"
}
@@ -0,0 +1,20 @@
package test
class B {
fun test() {
A.X()
A.Companion.Y()
A.foo(A.bar)
//1.extFoo(1.extBar) // conflict
A.O.Y()
A.O.foo(A.O.bar)
with (A.O) {
A.Companion.Y()
foo(bar)
1.extFoo(1.extBar)
}
}
}
@@ -0,0 +1,34 @@
package test
inline fun <T, R> with(receiver: T, block: T.() -> R): R = receiver.block()
class A {
class X {
}
companion object {
class Y
fun foo(n: Int) {}
val bar = 1
fun Int.extFoo(n: Int) {}
val Int.extBar: Int get() = 1
}
object O {
class Y
fun foo(n: Int) {}
val bar = 1
fun Int.extFoo(n: Int) {}
val Int.extBar: Int get() = 1
}
}
@@ -0,0 +1,10 @@
package test2;
import test.A;
import test.B;
class Test {
B foo() {
return new A().new B();
}
}
@@ -0,0 +1,10 @@
package test2;
import test.A;
import test.B;
class Test {
B foo() {
return new A().new B();
}
}
@@ -0,0 +1,8 @@
package test2
import test.A
import test.B
fun foo(): B {
return B()
}
@@ -0,0 +1,8 @@
package test2
import test.A
import test.B
fun foo2(): B {
return B()
}
@@ -0,0 +1,52 @@
package test
inline fun <T, R> with(receiver: T, block: T.() -> R): R = receiver.block()
class A {
class X {
}
companion object {
class Y
fun foo(n: Int) {}
val bar = 1
fun Int.extFoo(n: Int) {}
val Int.extBar: Int get() = 1
}
object O {
class Y
fun foo(n: Int) {}
val bar = 1
fun Int.extFoo(n: Int) {}
val Int.extBar: Int get() = 1
}
inner class <caret>B {
fun test() {
X()
Y()
foo(bar)
//1.extFoo(1.extBar) // conflict
O.Y()
O.foo(O.bar)
with (O) {
Y()
foo(bar)
1.extFoo(1.extBar)
}
}
}
}
@@ -0,0 +1,9 @@
package test2;
import test.A;
class Test {
A.B foo() {
return new A().new B();
}
}
@@ -0,0 +1,10 @@
package test2;
import test.A;
import test.A.B;
class Test {
B foo() {
return new A().new B();
}
}
@@ -0,0 +1,7 @@
package test2
import test.A
fun foo(): A.B {
return A().B()
}
@@ -0,0 +1,8 @@
package test2
import test.A
import test.A.B
fun foo2(): B {
return A().B()
}
@@ -0,0 +1,5 @@
{
"mainFile": "test.kt",
"type": "MOVE_KOTLIN_NESTED_CLASS",
"withRuntime": "true"
}
@@ -0,0 +1,26 @@
package test
class B(private val a: A) {
fun test() {
A.X()
A.Companion.Y()
A.foo(A.bar)
//1.extFoo(1.extBar) // conflict
a.OuterY()
a.outerFoo(a.outerBar)
a.OuterY()
a.outerFoo(a.outerBar)
A.O.Y()
A.O.foo(A.O.bar)
with (A.O) {
A.Companion.Y()
foo(bar)
1.extFoo(1.extBar)
}
}
}
@@ -0,0 +1,40 @@
package test
inline fun <T, R> with(receiver: T, block: T.() -> R): R = receiver.block()
class A {
class X {
}
inner class OuterY
fun outerFoo(n: Int) {}
val outerBar = 1
companion object {
class Y
fun foo(n: Int) {}
val bar = 1
fun Int.extFoo(n: Int) {}
val Int.extBar: Int get() = 1
}
object O {
class Y
fun foo(n: Int) {}
val bar = 1
fun Int.extFoo(n: Int) {}
val Int.extBar: Int get() = 1
}
}
@@ -0,0 +1,10 @@
package test2;
import test.A;
import test.B;
class Test {
B foo() {
return new B(new A());
}
}
@@ -0,0 +1,10 @@
package test2;
import test.A;
import test.B;
class Test {
B foo() {
return new B(new A());
}
}
@@ -0,0 +1,8 @@
package test2
import test.A
import test.B
fun foo(): B {
return B(A())
}
@@ -0,0 +1,8 @@
package test2
import test.A
import test.B
fun foo2(): B {
return B(A())
}
@@ -0,0 +1,64 @@
package test
inline fun <T, R> with(receiver: T, block: T.() -> R): R = receiver.block()
class A {
class X {
}
inner class OuterY
fun outerFoo(n: Int) {}
val outerBar = 1
companion object {
class Y
fun foo(n: Int) {}
val bar = 1
fun Int.extFoo(n: Int) {}
val Int.extBar: Int get() = 1
}
object O {
class Y
fun foo(n: Int) {}
val bar = 1
fun Int.extFoo(n: Int) {}
val Int.extBar: Int get() = 1
}
inner class <caret>B {
fun test() {
X()
Y()
foo(bar)
//1.extFoo(1.extBar) // conflict
OuterY()
outerFoo(outerBar)
this@A.OuterY()
this@A.outerFoo(this@A.outerBar)
O.Y()
O.foo(O.bar)
with (O) {
Y()
foo(bar)
1.extFoo(1.extBar)
}
}
}
}
@@ -0,0 +1,9 @@
package test2;
import test.A;
class Test {
A.B foo() {
return new A().new B();
}
}
@@ -0,0 +1,10 @@
package test2;
import test.A;
import test.A.B;
class Test {
B foo() {
return new A().new B();
}
}
@@ -0,0 +1,7 @@
package test2
import test.A
fun foo(): A.B {
return A().B()
}
@@ -0,0 +1,8 @@
package test2
import test.A
import test.A.B
fun foo2(): B {
return A().B()
}
@@ -0,0 +1,6 @@
{
"mainFile": "test.kt",
"type": "MOVE_KOTLIN_NESTED_CLASS",
"outerInstanceParameter": "a",
"withRuntime": "true"
}
@@ -0,0 +1,19 @@
package test
inline fun <T, R> with(receiver: T, block: T.() -> R): R = receiver.block()
class A() {
fun X.bar() {}
}
class X {
fun Int.foo() {}
inner class Y {
fun test() {
1.foo()
with(1) { foo() }
with(A()) { bar() }
}
}
}
@@ -0,0 +1,19 @@
package test
inline fun <T, R> with(receiver: T, block: T.() -> R): R = receiver.block()
class A() {
fun X.bar() {}
}
class X {
fun Int.foo() {}
inner class <caret>Y {
fun test() {
1.foo()
with(1) { foo() }
with(A()) { bar() }
}
}
}
@@ -0,0 +1,3 @@
Call with two implicit receivers won't be processed: bar()
Call with two implicit receivers won't be processed: foo()
Qualified call won't be processed: 1.foo()
@@ -0,0 +1,6 @@
{
"mainFile": "test.kt",
"type": "MOVE_KOTLIN_NESTED_CLASS",
"outerInstanceParameter": "a",
"withRuntime": "true"
}
@@ -0,0 +1,55 @@
package test
inline fun <T, R> with(receiver: T, block: T.() -> R): R = receiver.block()
class A {
class B {
class X {
}
companion object {
class Y
fun foo(n: Int) {}
val bar = 1
fun Int.extFoo(n: Int) {}
val Int.extBar: Int get() = 1
}
object O {
class Y
fun foo(n: Int) {}
val bar = 1
fun Int.extFoo(n: Int) {}
val Int.extBar: Int get() = 1
}
}
class C {
fun test() {
B.X()
B.Companion.Y()
B.foo(B.bar)
//1.extFoo(1.extBar) // conflict
B.O.Y()
B.O.foo(B.O.bar)
with (B.O) {
B.Companion.Y()
foo(bar)
1.extFoo(1.extBar)
}
}
}
}
@@ -0,0 +1,9 @@
package test2;
import test.A;
class Test {
A.C foo() {
return new A.C();
}
}
@@ -0,0 +1,9 @@
package test2;
import test.A.C;
class Test {
C foo() {
return new C();
}
}
@@ -0,0 +1,9 @@
package test2;
import test.A;
class Test {
A.C foo() {
return new A.C();
}
}
@@ -0,0 +1,7 @@
package test2
import test.A
fun foo(): A.C {
return A.C()
}
@@ -0,0 +1,7 @@
package test2
import test.A.C
fun foo(): C {
return C()
}
@@ -0,0 +1,8 @@
package test2
import test.A
import test.A.B
fun foo(): A.C {
return A.C()
}
@@ -0,0 +1,54 @@
package test
inline fun <T, R> with(receiver: T, block: T.() -> R): R = receiver.block()
class A {
class B {
class X {
}
companion object {
class Y
fun foo(n: Int) {}
val bar = 1
fun Int.extFoo(n: Int) {}
val Int.extBar: Int get() = 1
}
object O {
class Y
fun foo(n: Int) {}
val bar = 1
fun Int.extFoo(n: Int) {}
val Int.extBar: Int get() = 1
}
class <caret>C {
fun test() {
X()
Y()
foo(bar)
//1.extFoo(1.extBar) // conflict
O.Y()
O.foo(O.bar)
with (O) {
Y()
foo(bar)
1.extFoo(1.extBar)
}
}
}
}
}
@@ -0,0 +1,9 @@
package test2;
import test.A;
class Test {
A.B.C foo() {
return new A.B.C();
}
}
@@ -0,0 +1,9 @@
package test2;
import test.A.B.C;
class Test {
C foo() {
return new C();
}
}
@@ -0,0 +1,9 @@
package test2;
import test.A.B;
class Test {
B.C foo() {
return new B.C();
}
}
@@ -0,0 +1,7 @@
package test2
import test.A
fun foo(): A.B.C {
return A.B.C()
}
@@ -0,0 +1,7 @@
package test2
import test.A.B.C
fun foo(): C {
return C()
}
@@ -0,0 +1,7 @@
package test2
import test.A.B
fun foo(): B.C {
return B.C()
}
@@ -0,0 +1,6 @@
{
"mainFile": "test.kt",
"type": "MOVE_KOTLIN_NESTED_CLASS",
"targetClass": "test.A",
"withRuntime": "true"
}
@@ -0,0 +1,55 @@
package test
inline fun <T, R> with(receiver: T, block: T.() -> R): R = receiver.block()
class A {
class X {
}
companion object {
class Y
fun foo(n: Int) {}
val bar = 1
fun Int.extFoo(n: Int) {}
val Int.extBar: Int get() = 1
}
object O {
class Y
fun foo(n: Int) {}
val bar = 1
fun Int.extFoo(n: Int) {}
val Int.extBar: Int get() = 1
}
class B {
}
class C {
fun test() {
X()
Y()
foo(bar)
//1.extFoo(1.extBar) // conflict
O.Y()
O.foo(O.bar)
with (O) {
Y()
foo(bar)
1.extFoo(1.extBar)
}
}
}
}
@@ -0,0 +1,9 @@
package test2;
import test.A;
class Test {
A.C foo() {
return new A.C();
}
}
@@ -0,0 +1,9 @@
package test2;
import test.A.C;
class Test {
C foo() {
return new C();
}
}
@@ -0,0 +1,9 @@
package test2;
import test.A;
class Test {
A.C foo() {
return new A.C();
}
}
@@ -0,0 +1,7 @@
package test2
import test.A
fun foo(): A.C {
return A.C()
}
@@ -0,0 +1,7 @@
package test2
import test.A.C
fun foo(): C {
return C()
}
@@ -0,0 +1,8 @@
package test2
import test.A
import test.A.B
fun foo(): A.C {
return A.C()
}
@@ -0,0 +1,54 @@
package test
inline fun <T, R> with(receiver: T, block: T.() -> R): R = receiver.block()
class A {
class X {
}
companion object {
class Y
fun foo(n: Int) {}
val bar = 1
fun Int.extFoo(n: Int) {}
val Int.extBar: Int get() = 1
}
object O {
class Y
fun foo(n: Int) {}
val bar = 1
fun Int.extFoo(n: Int) {}
val Int.extBar: Int get() = 1
}
class B {
class <caret>C {
fun test() {
X()
Y()
foo(bar)
//1.extFoo(1.extBar) // conflict
O.Y()
O.foo(O.bar)
with (O) {
Y()
foo(bar)
1.extFoo(1.extBar)
}
}
}
}
}
@@ -0,0 +1,9 @@
package test2;
import test.A;
class Test {
A.B.C foo() {
return new A.B.C();
}
}
@@ -0,0 +1,9 @@
package test2;
import test.A.B.C;
class Test {
C foo() {
return new C();
}
}
@@ -0,0 +1,9 @@
package test2;
import test.A.B;
class Test {
B.C foo() {
return new B.C();
}
}
@@ -0,0 +1,7 @@
package test2
import test.A
fun foo(): A.B.C {
return A.B.C()
}
@@ -0,0 +1,7 @@
package test2
import test.A.B.C
fun foo(): C {
return C()
}
@@ -0,0 +1,7 @@
package test2
import test.A.B
fun foo(): B.C {
return B.C()
}
@@ -0,0 +1,6 @@
{
"mainFile": "test.kt",
"type": "MOVE_KOTLIN_NESTED_CLASS",
"targetClass": "test.A",
"withRuntime": "true"
}
@@ -0,0 +1,20 @@
package test
class B {
fun test() {
A.X()
A.Companion.Y()
A.foo(A.bar)
//1.extFoo(1.extBar) // conflict
A.O.Y()
A.O.foo(A.O.bar)
with (A.O) {
A.Companion.Y()
foo(bar)
1.extFoo(1.extBar)
}
}
}
@@ -0,0 +1,34 @@
package test
inline fun <T, R> with(receiver: T, block: T.() -> R): R = receiver.block()
class A {
class X {
}
companion object {
class Y
fun foo(n: Int) {}
val bar = 1
fun Int.extFoo(n: Int) {}
val Int.extBar: Int get() = 1
}
object O {
class Y
fun foo(n: Int) {}
val bar = 1
fun Int.extFoo(n: Int) {}
val Int.extBar: Int get() = 1
}
}
@@ -0,0 +1,9 @@
package test2;
import test.B;
class Test {
B foo() {
return new B();
}
}
@@ -0,0 +1,9 @@
package test2;
import test.B;
class Test {
B foo() {
return new B();
}
}
@@ -0,0 +1,8 @@
package test2
import test.A
import test.B
fun foo(): B {
return B()
}
@@ -0,0 +1,7 @@
package test2
import test.B
fun foo(): B {
return B()
}

Some files were not shown because too many files have changed in this diff Show More