Extract Function: Infer parameter type candidates

#KT-4940 Fixed
This commit is contained in:
Alexey Sedunov
2014-06-20 17:33:57 +04:00
parent 96557e6d3f
commit ca16f4231f
143 changed files with 759 additions and 78 deletions
@@ -0,0 +1,14 @@
// PARAM_TYPES: kotlin.String, Comparable<String>, CharSequence, kotlin.Any
// PARAM_TYPES: X<kotlin.Any>
class X<T> {
fun add(t: T) {
}
}
// SIBLING:
fun foo(s: String?, x: X<Any>) {
when {
s != null -> <selection>x.add(s)</selection>
}
}
@@ -0,0 +1,18 @@
// PARAM_TYPES: kotlin.String, Comparable<String>, CharSequence, kotlin.Any
// PARAM_TYPES: X<kotlin.Any>
class X<T> {
fun add(t: T) {
}
}
// SIBLING:
fun foo(s: String?, x: X<Any>) {
when {
s != null -> unit(s, x)
}
}
fun unit(s: String, x: X<Any>) {
x.add(s)
}
@@ -0,0 +1,14 @@
// PARAM_TYPES: kotlin.String?, kotlin.Comparable<String>?, kotlin.CharSequence?, kotlin.Any?
// PARAM_TYPES: X<kotlin.Any?>
class X<T> {
fun add(t: T) {
}
}
// SIBLING:
fun foo(s: String?, x: X<Any?>) {
when {
s != null -> <selection>x.add(s)</selection>
}
}
@@ -0,0 +1,18 @@
// PARAM_TYPES: kotlin.String?, kotlin.Comparable<String>?, kotlin.CharSequence?, kotlin.Any?
// PARAM_TYPES: X<kotlin.Any?>
class X<T> {
fun add(t: T) {
}
}
// SIBLING:
fun foo(s: String?, x: X<Any?>) {
when {
s != null -> unit(s, x)
}
}
fun unit(s: String?, x: X<Any?>) {
x.add(s)
}
@@ -0,0 +1,35 @@
//PARAM_TYPES: C, AImpl, A
trait A {
fun doA()
}
open class AImpl: A {
override fun doA() {
throw UnsupportedOperationException()
}
}
trait B {
fun doB()
}
class C: AImpl(), B {
override fun doA() {
throw UnsupportedOperationException()
}
override fun doB() {
throw UnsupportedOperationException()
}
fun doC() {
throw UnsupportedOperationException()
}
}
// SIBLING:
fun foo(c: C) {
<selection>c.doA()</selection>
c.doB()
c.doC()
}
@@ -0,0 +1,39 @@
//PARAM_TYPES: C, AImpl, A
trait A {
fun doA()
}
open class AImpl: A {
override fun doA() {
throw UnsupportedOperationException()
}
}
trait B {
fun doB()
}
class C: AImpl(), B {
override fun doA() {
throw UnsupportedOperationException()
}
override fun doB() {
throw UnsupportedOperationException()
}
fun doC() {
throw UnsupportedOperationException()
}
}
// SIBLING:
fun foo(c: C) {
unit(c)
c.doB()
c.doC()
}
fun unit(c: C) {
c.doA()
}
@@ -0,0 +1,35 @@
//PARAM_TYPES: C, B
trait A {
fun doA()
}
open class AImpl: A {
override fun doA() {
throw UnsupportedOperationException()
}
}
trait B {
fun doB()
}
class C: AImpl(), B {
override fun doA() {
throw UnsupportedOperationException()
}
override fun doB() {
throw UnsupportedOperationException()
}
fun doC() {
throw UnsupportedOperationException()
}
}
// SIBLING:
fun foo(c: C) {
c.doA()
<selection>c.doB()</selection>
c.doC()
}
@@ -0,0 +1,39 @@
//PARAM_TYPES: C, B
trait A {
fun doA()
}
open class AImpl: A {
override fun doA() {
throw UnsupportedOperationException()
}
}
trait B {
fun doB()
}
class C: AImpl(), B {
override fun doA() {
throw UnsupportedOperationException()
}
override fun doB() {
throw UnsupportedOperationException()
}
fun doC() {
throw UnsupportedOperationException()
}
}
// SIBLING:
fun foo(c: C) {
c.doA()
unit(c)
c.doC()
}
fun unit(c: C) {
c.doB()
}
@@ -0,0 +1,35 @@
//PARAM_TYPES: C
trait A {
fun doA()
}
open class AImpl: A {
override fun doA() {
throw UnsupportedOperationException()
}
}
trait B {
fun doB()
}
class C: AImpl(), B {
override fun doA() {
throw UnsupportedOperationException()
}
override fun doB() {
throw UnsupportedOperationException()
}
fun doC() {
throw UnsupportedOperationException()
}
}
// SIBLING:
fun foo(c: C) {
c.doA()
c.doB()
<selection>c.doC()</selection>
}
@@ -0,0 +1,39 @@
//PARAM_TYPES: C
trait A {
fun doA()
}
open class AImpl: A {
override fun doA() {
throw UnsupportedOperationException()
}
}
trait B {
fun doB()
}
class C: AImpl(), B {
override fun doA() {
throw UnsupportedOperationException()
}
override fun doB() {
throw UnsupportedOperationException()
}
fun doC() {
throw UnsupportedOperationException()
}
}
// SIBLING:
fun foo(c: C) {
c.doA()
c.doB()
unit(c)
}
fun unit(c: C) {
c.doC()
}
@@ -0,0 +1,35 @@
//PARAM_TYPES: C
trait A {
fun doA()
}
open class AImpl: A {
override fun doA() {
throw UnsupportedOperationException()
}
}
trait B {
fun doB()
}
class C: AImpl(), B {
override fun doA() {
throw UnsupportedOperationException()
}
override fun doB() {
throw UnsupportedOperationException()
}
fun doC() {
throw UnsupportedOperationException()
}
}
// SIBLING:
fun foo(c: C) {
<selection>c.doA()
c.doB()</selection>
c.doC()
}
@@ -0,0 +1,39 @@
//PARAM_TYPES: C
trait A {
fun doA()
}
open class AImpl: A {
override fun doA() {
throw UnsupportedOperationException()
}
}
trait B {
fun doB()
}
class C: AImpl(), B {
override fun doA() {
throw UnsupportedOperationException()
}
override fun doB() {
throw UnsupportedOperationException()
}
fun doC() {
throw UnsupportedOperationException()
}
}
// SIBLING:
fun foo(c: C) {
unit(c)
c.doC()
}
fun unit(c: C) {
c.doA()
c.doB()
}
@@ -1,3 +1,5 @@
// PARAM_TYPES: A
// PARAM_TYPES: A.B
public open class Z {
val z: Int = 0
}
@@ -1,3 +1,5 @@
// PARAM_TYPES: A
// PARAM_TYPES: A.B
public open class Z {
val z: Int = 0
}
@@ -1,3 +1,4 @@
// PARAM_TYPES: Z
class Z(val a: Int)
// SIBLING:
@@ -1,3 +1,4 @@
// PARAM_TYPES: Z
class Z(val a: Int)
// SIBLING:
@@ -1,3 +1,5 @@
// PARAM_TYPES: A
// PARAM_TYPES: A.B
public open class Z {
val z: Int = 0
}
@@ -1,3 +1,5 @@
// PARAM_TYPES: A
// PARAM_TYPES: A.B
public open class Z {
val z: Int = 0
}
@@ -1,3 +1,5 @@
// PARAM_TYPES: A
// PARAM_TYPES: A.B
public open class Z {
val z: Int = 0
}
@@ -1,3 +1,5 @@
// PARAM_TYPES: A
// PARAM_TYPES: A.B
public open class Z {
val z: Int = 0
}
@@ -1,3 +1,4 @@
// PARAM_TYPES: Z
class Z(val a: Int)
// SIBLING:
@@ -1,3 +1,4 @@
// PARAM_TYPES: Z
class Z(val a: Int)
// SIBLING:
@@ -1,3 +1,4 @@
// PARAM_TYPES: Z
class Z(val a: Int)
// SIBLING:
@@ -1,3 +1,4 @@
// PARAM_TYPES: Z
class Z(val a: Int)
// SIBLING:
@@ -1,3 +1,5 @@
// PARAM_TYPES: A
// PARAM_TYPES: A.B
public open class Z {
val z: Int = 0
}
@@ -1,3 +1,5 @@
// PARAM_TYPES: A
// PARAM_TYPES: A.B
public open class Z {
val z: Int = 0
}
@@ -1,3 +1,4 @@
// PARAM_TYPES: kotlin.Int, Number, Comparable<Int>, Any
// SIBLING:
fun main(args: Array<String>) {
val (a, b) = Data(1, 2)
@@ -1,3 +1,4 @@
// PARAM_TYPES: kotlin.Int, Number, Comparable<Int>, Any
// SIBLING:
fun main(args: Array<String>) {
val (a, b) = Data(1, 2)
@@ -1,3 +1,6 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int, b: Int, c: Int): Int {
return <selection>(a + b*a - c) + b*c</selection>
@@ -1,3 +1,6 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int, b: Int, c: Int): Int {
return i(a, b, c)
@@ -1,3 +1,7 @@
// PARAM_TYPES: A
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
public class A() {
fun bar(a: Int, b: Int): Int {
@@ -1,3 +1,7 @@
// PARAM_TYPES: A
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
public class A() {
fun bar(a: Int, b: Int): Int {