KT-44079 [Sealed Interfaces]: move refactoring update
The idea behind this commit is that Move Refactoring should warn developers in case their intention potentially breaks sealed hierarchies (members must share the same module and package). Provided algorithm has two goals: - prevent destruction of correct hierarchies - help in fixing broken ones
This commit is contained in:
-7
@@ -1,7 +0,0 @@
|
||||
package source
|
||||
|
||||
import target.Expr
|
||||
|
||||
data class Const(val number: Double) : Expr()
|
||||
data class Sum(val e1: Expr, val e2: Expr) : Expr()
|
||||
object NotANumber : Expr()
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
package target
|
||||
|
||||
sealed class Expr
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
package source
|
||||
|
||||
sealed class <caret>Expr
|
||||
data class Const(val number: Double) : Expr()
|
||||
data class Sum(val e1: Expr, val e2: Expr) : Expr()
|
||||
object NotANumber : Expr()
|
||||
-1
@@ -1 +0,0 @@
|
||||
Sealed class 'Expr' must be moved with all its subclasses
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"mainFile": "source/Foo.kt",
|
||||
"type": "MOVE_KOTLIN_TOP_LEVEL_DECLARATIONS",
|
||||
"targetPackage": "target"
|
||||
}
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
package source
|
||||
|
||||
sealed class Expr
|
||||
data class Sum(val e1: Expr, val e2: Expr) : Expr()
|
||||
object NotANumber : Expr()
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
package target
|
||||
|
||||
import source.Expr
|
||||
|
||||
data class Const(val number: Double) : Expr()
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
package source
|
||||
|
||||
sealed class Expr
|
||||
data class <caret>Const(val number: Double) : Expr()
|
||||
data class Sum(val e1: Expr, val e2: Expr) : Expr()
|
||||
object NotANumber : Expr()
|
||||
-1
@@ -1 +0,0 @@
|
||||
Class 'Expr' must be moved with sealed parent class and all its subclasses
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"mainFile": "source/Foo.kt",
|
||||
"type": "MOVE_KOTLIN_TOP_LEVEL_DECLARATIONS",
|
||||
"targetPackage": "target"
|
||||
}
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
package bar
|
||||
|
||||
public sealed class SealedClass {
|
||||
public class Impl1 : SealedClass() {}
|
||||
}
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
package foo
|
||||
|
||||
import bar.SealedClass
|
||||
|
||||
val v = SealedClass::Impl1
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
package foo
|
||||
|
||||
import bar.SealedClass
|
||||
|
||||
public class Impl2 : SealedClass() {}
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
package foo
|
||||
|
||||
val v = SealedClass::Impl1
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
package foo
|
||||
|
||||
public sealed class <caret>SealedClass {
|
||||
public class Impl1 : SealedClass() {}
|
||||
}
|
||||
|
||||
public class Impl2 : SealedClass() {}
|
||||
-1
@@ -1 +0,0 @@
|
||||
Sealed class 'SealedClass' must be moved with all its subclasses
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"mainFile": "foo/SealedClass.kt",
|
||||
"type": "MOVE_KOTLIN_TOP_LEVEL_DECLARATIONS",
|
||||
"targetPackage": "bar"
|
||||
}
|
||||
Reference in New Issue
Block a user