Intentions: 'Implement abstract member' (Kotlin -> Kotlin)

#KT-8467 In Progress
This commit is contained in:
Alexey Sedunov
2015-12-18 15:07:16 +03:00
parent 123b813073
commit 03641ffbee
51 changed files with 889 additions and 9 deletions
@@ -0,0 +1 @@
org.jetbrains.kotlin.idea.intentions.ImplementAbstractMemberIntention
@@ -0,0 +1,9 @@
// WITH_RUNTIME
// DISABLE-ERRORS
interface T<X> {
fun <caret>foo(x: X): X
}
enum class E : T<Int> {
A, B, C
}
@@ -0,0 +1,13 @@
// WITH_RUNTIME
// DISABLE-ERRORS
interface T<X> {
fun <caret>foo(x: X): X
}
enum class E : T<Int> {
A, B, C;
override fun foo(x: Int): Int {
throw UnsupportedOperationException()
}
}
@@ -0,0 +1,9 @@
// WITH_RUNTIME
// DISABLE-ERRORS
interface T<X> {
fun <caret>foo(x: X): X
}
enum class E : T<Int> {
A, B, C;
}
@@ -0,0 +1,13 @@
// WITH_RUNTIME
// DISABLE-ERRORS
interface T<X> {
fun <caret>foo(x: X): X
}
enum class E : T<Int> {
A, B, C;
override fun foo(x: Int): Int {
throw UnsupportedOperationException()
}
}
@@ -0,0 +1,13 @@
// WITH_RUNTIME
// DISABLE-ERRORS
interface T<X> {
fun <caret>foo(x: X): X
}
enum class E : T<Int> {
A, B, C;
val bar = 1
fun baz() = 2
}
@@ -0,0 +1,17 @@
// WITH_RUNTIME
// DISABLE-ERRORS
interface T<X> {
fun <caret>foo(x: X): X
}
enum class E : T<Int> {
A, B, C;
override fun foo(x: Int): Int {
throw UnsupportedOperationException()
}
val bar = 1
fun baz() = 2
}
@@ -0,0 +1,7 @@
// WITH_RUNTIME
//DISABLE-ERRORS
enum class E {
A, B, C;
abstract fun <caret>foo(x: Int): Int
}
@@ -0,0 +1,19 @@
// WITH_RUNTIME
//DISABLE-ERRORS
enum class E {
A {
override fun foo(x: Int): Int {
throw UnsupportedOperationException()
}
}, B {
override fun foo(x: Int): Int {
throw UnsupportedOperationException()
}
}, C {
override fun foo(x: Int): Int {
throw UnsupportedOperationException()
}
};
abstract fun <caret>foo(x: Int): Int
}
@@ -0,0 +1,7 @@
// WITH_RUNTIME
//DISABLE-ERRORS
enum class E(n: Int) {
A(1), B(2), C(3);
abstract fun <caret>foo(x: Int): Int
}
@@ -0,0 +1,19 @@
// WITH_RUNTIME
//DISABLE-ERRORS
enum class E(n: Int) {
A(1) {
override fun foo(x: Int): Int {
throw UnsupportedOperationException()
}
}, B(2) {
override fun foo(x: Int): Int {
throw UnsupportedOperationException()
}
}, C(3) {
override fun foo(x: Int): Int {
throw UnsupportedOperationException()
}
};
abstract fun <caret>foo(x: Int): Int
}
@@ -0,0 +1,23 @@
// WITH_RUNTIME
// DISABLE-ERRORS
interface T<X> {
fun <caret>foo(x: X): X
}
class U : T<String> {
}
class V : T<Int> {
}
class Z : T<Int> by V() {
}
class W : T<Boolean> {
override fun foo(x: Boolean): Boolean {
throw UnsupportedOperationException()
}
}
@@ -0,0 +1,29 @@
// WITH_RUNTIME
// DISABLE-ERRORS
interface T<X> {
fun <caret>foo(x: X): X
}
class U : T<String> {
override fun foo(x: String): String {
throw UnsupportedOperationException()
}
}
class V : T<Int> {
override fun foo(x: Int): Int {
throw UnsupportedOperationException()
}
}
class Z : T<Int> by V() {
}
class W : T<Boolean> {
override fun foo(x: Boolean): Boolean {
throw UnsupportedOperationException()
}
}
@@ -0,0 +1,5 @@
// IS_APPLICABLE: false
// ERROR: Abstract function 'foo' in non-abstract class 'A'
class A {
abstract fun <caret>foo(): Int
}
@@ -0,0 +1,5 @@
// IS_APPLICABLE: false
// ERROR: Abstract function 'foo' in non-abstract class 'A'
object A {
abstract fun <caret>foo(): Int
}
@@ -0,0 +1,17 @@
// IS_APPLICABLE: false
// ERROR: Class 'C' must be declared abstract or implement abstract base class member public abstract fun foo(): kotlin.Int defined in B
interface A {
fun <caret>foo(): Int
}
class X : A {
override fun foo() = 1
}
abstract class B : A {
abstract override fun foo(): Int
}
class C: B() {
}
@@ -0,0 +1,4 @@
// IS_APPLICABLE: false
interface A {
fun <caret>foo(): Int
}
@@ -0,0 +1,4 @@
// IS_APPLICABLE: false
open class A {
fun <caret>foo() = 1
}
@@ -0,0 +1,4 @@
// IS_APPLICABLE: false
interface A {
fun <caret>foo() = 1
}
@@ -0,0 +1,5 @@
// IS_APPLICABLE: false
// ERROR: Function 'foo' without a body must be abstract
open class A {
fun <caret>foo(): Int
}