Create from Usage: Implement "Create type parameter" quickfix

#KT-11525 Fixed
This commit is contained in:
Alexey Sedunov
2016-08-24 11:49:05 +03:00
parent 6a2edabbd4
commit 63092f6985
43 changed files with 693 additions and 49 deletions
@@ -1,6 +1,7 @@
// "Create class 'A'" "false"
// ACTION: Create interface 'A'
// ACTION: Create type alias 'A'
// ACTION: Create type parameter 'A' in class 'Foo'
// ACTION: Create test
// ERROR: Unresolved reference: A
package p
@@ -6,6 +6,7 @@
// ACTION: Create type alias 'A'
// ACTION: Convert to block body
// ACTION: Remove explicit type specification
// ACTION: Create type parameter 'A' in function 'foo'
// ERROR: Unresolved reference: A
package p
@@ -2,6 +2,7 @@
// ACTION: Create class 'NotExistent'
// ACTION: Create interface 'NotExistent'
// ACTION: Create type alias 'NotExistent'
// ACTION: Create type parameter 'NotExistent' in class 'TPB'
// ACTION: Create test
// ERROR: Unresolved reference: NotExistent
class TPB<X : <caret>NotExistent>
@@ -2,6 +2,7 @@
// ACTION: Create class 'NotExistent'
// ACTION: Create interface 'NotExistent'
// ACTION: Create type alias 'NotExistent'
// ACTION: Create type parameter 'NotExistent' in class 'TPB'
// ACTION: Create test
// ERROR: Unresolved reference: NotExistent
class TPB<X> where X : <caret>NotExistent
@@ -2,6 +2,7 @@
// ACTION: Create class 'NotExistent'
// ACTION: Create interface 'NotExistent'
// ACTION: Create type alias 'NotExistent'
// ACTION: Create type parameter 'NotExistent' in class 'TPB'
// ACTION: Create test
// ERROR: Unresolved reference: NotExistent
class TPB<X : <caret>NotExistent>
@@ -2,6 +2,7 @@
// ACTION: Create class 'NotExistent'
// ACTION: Create interface 'NotExistent'
// ACTION: Create type alias 'NotExistent'
// ACTION: Create type parameter 'NotExistent' in class 'TPB'
// ACTION: Create test
// ERROR: Unresolved reference: NotExistent
class TPB<X> where X : <caret>NotExistent
@@ -2,6 +2,7 @@
// ACTION: Create class 'NotExistent'
// ACTION: Create interface 'NotExistent'
// ACTION: Create type alias 'NotExistent'
// ACTION: Create type parameter 'NotExistent' in class 'TPB'
// ACTION: Create test
// ERROR: Unresolved reference: NotExistent
class TPB<X : <caret>NotExistent>
@@ -2,6 +2,7 @@
// ACTION: Create class 'NotExistent'
// ACTION: Create interface 'NotExistent'
// ACTION: Create type alias 'NotExistent'
// ACTION: Create type parameter 'NotExistent' in class 'TPB'
// ACTION: Create test
// ERROR: Unresolved reference: NotExistent
class TPB<X> where X : <caret>NotExistent
@@ -6,6 +6,7 @@
// ACTION: Create type alias 'A'
// ACTION: Convert to block body
// ACTION: Remove explicit type specification
// ACTION: Create type parameter 'A' in function 'foo'
// ERROR: Unresolved reference: A
package p
@@ -0,0 +1,13 @@
// "Create type parameter 'X' in class 'Foo'" "true"
open class Foo(x: <caret>X)
class Bar : Foo(1)
fun test() {
Foo(1)
Foo("2")
object : Foo("2") {
}
}
@@ -0,0 +1,13 @@
// "Create type parameter 'X' in class 'Foo'" "true"
open class Foo<X>(x: X)
class Bar : Foo<Any?>(1)
fun test() {
Foo(1)
Foo("2")
object : Foo<Any?>("2") {
}
}
@@ -0,0 +1,16 @@
// "Create type parameter 'X' in class 'Foo'" "true"
// ERROR: Type mismatch: inferred type is A<Int> but A<Any?> was expected
class A<T>
open class Foo(x: A<<caret>X>)
class Bar : Foo(A())
fun test() {
Foo(A())
Foo(A<Int>())
object : Foo(A<Int>()) {
}
}
@@ -0,0 +1,16 @@
// "Create type parameter 'X' in class 'Foo'" "true"
// ERROR: Type mismatch: inferred type is A<Int> but A<Any?> was expected
class A<T>
open class Foo<X>(x: A<X>)
class Bar : Foo<Any?>(A())
fun test() {
Foo<Any?>(A())
Foo(A<Int>())
object : Foo<Any?>(A<Int>()) {
}
}
@@ -0,0 +1,21 @@
// "Create type parameter 'X' in class 'Foo'" "true"
// ERROR: Unresolved reference: _
// ERROR: Unresolved reference: _
// ERROR: Unresolved reference: _
// ERROR: Type mismatch: inferred type is A<I> but A<List<[ERROR : _]>> was expected
class A<T : List<T>>
interface I : List<I>
open class Foo(x: A<<caret>X>)
class Bar : Foo(A())
fun test() {
Foo(A())
Foo(A<I>())
object : Foo(A<I>()) {
}
}
@@ -0,0 +1,21 @@
// "Create type parameter 'X' in class 'Foo'" "true"
// ERROR: Unresolved reference: _
// ERROR: Unresolved reference: _
// ERROR: Unresolved reference: _
// ERROR: Type mismatch: inferred type is A<I> but A<List<[ERROR : _]>> was expected
class A<T : List<T>>
interface I : List<I>
open class Foo<X : List<X>>(x: A<X>)
class Bar : Foo<List<_>>(A())
fun test() {
Foo<List<_>>(A())
Foo(A<I>())
object : Foo<List<_>>(A<I>()) {
}
}
@@ -0,0 +1,15 @@
// "Create type parameter 'X' in class 'Foo'" "true"
class A<T : List<Int>>
open class Foo(x: A<<caret>X>)
class Bar : Foo(A())
fun test() {
Foo(A())
Foo(A<List<Int>>())
object : Foo(A<List<Int>>()) {
}
}
@@ -0,0 +1,15 @@
// "Create type parameter 'X' in class 'Foo'" "true"
class A<T : List<Int>>
open class Foo<X : List<Int>>(x: A<X>)
class Bar : Foo<List<Int>>(A())
fun test() {
Foo<List<Int>>(A())
Foo(A<List<Int>>())
object : Foo<List<Int>>(A<List<Int>>()) {
}
}
@@ -0,0 +1,9 @@
// "Create type parameter 'X' in function 'foo'" "true"
fun foo(x: <caret>X) {
}
fun test() {
foo(1)
foo("2")
}
@@ -0,0 +1,9 @@
// "Create type parameter 'X' in function 'foo'" "true"
fun <X> foo(x: X) {
}
fun test() {
foo(1)
foo("2")
}
@@ -0,0 +1,11 @@
// "Create type parameter 'X' in function 'foo'" "true"
class A<T>
fun foo(x: A<<caret>X>) {
}
fun test() {
foo(A())
foo(A<Int>())
}
@@ -0,0 +1,11 @@
// "Create type parameter 'X' in function 'foo'" "true"
class A<T>
fun <X> foo(x: A<X>) {
}
fun test() {
foo<Any?>(A())
foo(A<Int>())
}
@@ -0,0 +1,14 @@
// "Create type parameter 'X' in function 'foo'" "true"
// ERROR: Unresolved reference: _
class A<T : List<T>>
interface I : List<I>
fun foo(x: A<<caret>X>) {
}
fun test() {
foo(A())
foo(A<I>())
}
@@ -0,0 +1,14 @@
// "Create type parameter 'X' in function 'foo'" "true"
// ERROR: Unresolved reference: _
class A<T : List<T>>
interface I : List<I>
fun <X : List<X>> foo(x: A<X>) {
}
fun test() {
foo<List<_>>(A())
foo(A<I>())
}
@@ -0,0 +1,11 @@
// "Create type parameter 'X' in function 'foo'" "true"
class A<T : List<Int>>
fun foo(x: A<<caret>X>) {
}
fun test() {
foo(A())
foo(A<List<Int>>())
}
@@ -0,0 +1,11 @@
// "Create type parameter 'X' in function 'foo'" "true"
class A<T : List<Int>>
fun <X : List<Int>> foo(x: A<X>) {
}
fun test() {
foo<List<Int>>(A())
foo(A<List<Int>>())
}
@@ -0,0 +1,13 @@
// "Create type parameter 'X'" "false"
// ACTION: Create annotation 'X'
// ACTION: Create class 'X'
// ACTION: Create enum 'X'
// ACTION: Create interface 'X'
// ACTION: Create type alias 'X'
// ERROR: Unresolved reference: X
class A
fun foo(x: A.<caret>X) {
}
@@ -0,0 +1,12 @@
// "Create type parameter 'X'" "false"
// ACTION: Create class 'X'
// ACTION: Create enum 'X'
// ACTION: Create interface 'X'
// ACTION: Create object 'X'
// ERROR: Unresolved reference: X
class A
fun foo(x: <caret>X.Y) {
}
@@ -0,0 +1,11 @@
// "Create type parameter 'X'" "false"
// ACTION: Create class 'X'
// ACTION: Create interface 'X'
// ACTION: Create type alias 'X'
// ERROR: Unresolved reference: X
class A
fun foo(x: <caret>X<Int>) {
}