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
@@ -1,3 +1,4 @@
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
<selection>// test
@@ -1,3 +1,4 @@
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
if (b(a)) return a
@@ -1,3 +1,4 @@
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
<selection>/*
@@ -1,3 +1,4 @@
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
if (b(a)) return a
@@ -1,3 +1,4 @@
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
<selection>println(a)
@@ -1,3 +1,4 @@
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
if (b(a)) return a
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int, Comparable<Int>
// PARAM_TYPES: kotlin.Int, Number, Comparable<Int>, Any
// SIBLING:
fun foo(a: Int) {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int, Comparable<Int>
// PARAM_TYPES: kotlin.Int, Number, Comparable<Int>, Any
// SIBLING:
fun foo(a: Int) {
val b: Int = 1
@@ -1,3 +1,4 @@
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int) {
val b: Int = 1
@@ -1,3 +1,4 @@
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int) {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int, Number, Comparable<Int>, Any
fun bar(a: Int): Int {
println(a)
return a + 10
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int, Number, Comparable<Int>, Any
fun bar(a: Int): Int {
println(a)
return a + 10
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int, Number, Comparable<Int>, Any
fun bar(a: Int): Int {
println(a)
return a + 10
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int, Number, Comparable<Int>, Any
fun bar(a: Int): Int {
println(a)
return a + 10
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int, Number, Comparable<Int>, Any
fun bar(a: Int): Int {
println(a)
return a + 10
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int, Number, Comparable<Int>, Any
fun bar(a: Int): Int {
println(a)
return a + 10
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int, Number, Comparable<Int>, Any
fun bar(a: Int): Int {
println(a)
return a + 10
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int, Number, Comparable<Int>, Any
fun bar(a: Int): Int {
println(a)
return a + 10
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,4 @@
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,4 @@
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,2 +1,4 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int, b: Int): Int = <selection>a + b</selection>
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int, b: Int): Int = i(a, b)
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
var b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
var b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int, Comparable<Int>
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
var b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int, Comparable<Int>
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
var b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
var b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
var b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int, Comparable<Int>
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
var b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int, Comparable<Int>
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
var b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
var b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
var b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int) {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int) {
val b: Int = 1
@@ -1,3 +1,4 @@
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
var b: Int = 1
@@ -1,3 +1,4 @@
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
var b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
class A {
class B {
fun foo(a: Int, b: Int): Int {
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
class A {
class B {
fun foo(a: Int, b: Int): Int {
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
fun foo(a: Int, b: Int): Int {
return <selection>a + b - 1</selection>
}
@@ -1,3 +1,5 @@
// PARAM_TYPES: kotlin.Int
// PARAM_TYPES: kotlin.Int
fun foo(a: Int, b: Int): Int {
return i(a, b)
}
@@ -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:

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