Create From Usage: Use supplied type arguments to infer function type parameters

This commit is contained in:
Alexey Sedunov
2014-10-22 20:32:21 +04:00
parent a13f334df2
commit abbbd198fd
27 changed files with 393 additions and 38 deletions
@@ -0,0 +1,14 @@
// "Create function 'foo' from usage" "true"
class B<T>(val t: T) {
fun <T1, T2> foo(arg: T1, arg1: T2): T1 {
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
}
}
class A<T>(val b: B<T>) {
fun test(): Int {
return b.foo<Int, String>(2, "2")
}
}
@@ -0,0 +1,14 @@
// "Create function 'foo' from usage" "true"
class B<T>(val t: T) {
fun <T1> foo(i: Int, arg: T1): Int {
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
}
}
class A<T>(val b: B<T>) {
fun test(): Int {
return b.foo<String>(2, "2")
}
}
@@ -0,0 +1,14 @@
// "Create function 'foo' from usage" "true"
class B<T>(val t: T) {
fun <T1, T2> foo(arg: T1, arg1: T2): T1 {
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
}
}
class A<T>(val b: B<T>) {
fun test(): Int {
return b.foo<Int, String>(2, "2")
}
}
@@ -0,0 +1,11 @@
// "Create function 'foo' from usage" "true"
class A<T>(val items: List<T>) {
fun test(): Int {
return items.foo<T, Int, String>(2, "2")
}
}
fun <E, T, T1> List<E>.foo(arg: T, arg1: T1): T {
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
}
@@ -0,0 +1,11 @@
// "Create function 'foo' from usage" "true"
class A<T>(val items: List<T>) {
fun test(): Int {
return items.foo<T, Int>(2, "2")
}
}
fun <E, T> List<E>.foo(arg: T, s: String): T {
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
}
@@ -0,0 +1,11 @@
// "Create function 'foo' from usage" "true"
class A<T>(val items: List<T>) {
fun test(): Int {
return items.foo<T, Int, String>(2, "2")
}
}
fun <E, T, T1> List<E>.foo(arg: T, arg1: T1): T {
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
}
@@ -0,0 +1,9 @@
// "Create function 'foo' from usage" "true"
fun test(): Int {
return foo<String, Int>(2, "2")
}
fun <T, T1> foo(arg: T1, arg1: T): T1 {
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
}
@@ -0,0 +1,9 @@
// "Create function 'foo' from usage" "true"
fun test(): Int {
return foo<String, Int>(2, "2")
}
fun <T, T1> foo(arg: T1, arg1: T): T1 {
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
}
@@ -0,0 +1,9 @@
// "Create function 'foo' from usage" "true"
fun test(): Int {
return foo<String, Int>(2, "2")
}
fun <T, T1> foo(arg: T1, arg1: T): T1 {
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
}
@@ -0,0 +1,9 @@
// "Create function 'foo' from usage" "true"
fun test(): Int {
return foo<Int>(2, "2")
}
fun <T> foo(arg: T, s: String): T {
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
}
@@ -0,0 +1,11 @@
// "Create function 'foo' from usage" "true"
class B<T>(val t: T) {
}
class A<T>(val b: B<T>) {
fun test(): Int {
return b.<caret>foo<Int, String>(2, "2")
}
}
@@ -0,0 +1,11 @@
// "Create function 'foo' from usage" "true"
class B<T>(val t: T) {
}
class A<T>(val b: B<T>) {
fun test(): Int {
return b.<caret>foo<String>(2, "2")
}
}
@@ -0,0 +1,11 @@
// "Create function 'foo' from usage" "true"
class B<T>(val t: T) {
}
class A<T>(val b: B<T>) {
fun test(): Int {
return b.<caret>foo<T, Int, String>(2, "2")
}
}
@@ -0,0 +1,7 @@
// "Create function 'foo' from usage" "true"
class A<T>(val items: List<T>) {
fun test(): Int {
return items.<caret>foo<Int, String>(2, "2")
}
}
@@ -0,0 +1,7 @@
// "Create function 'foo' from usage" "true"
class A<T>(val items: List<T>) {
fun test(): Int {
return items.<caret>foo<Int>(2, "2")
}
}
@@ -0,0 +1,7 @@
// "Create function 'foo' from usage" "true"
class A<T>(val items: List<T>) {
fun test(): Int {
return items.<caret>foo<T, Int, String>(2, "2")
}
}
@@ -0,0 +1,5 @@
// "Create function 'foo' from usage" "true"
fun test(): Int {
return <caret>foo<String, Int>(2, "2")
}
@@ -0,0 +1,5 @@
// "Create function 'foo' from usage" "true"
fun test(): Int {
return <caret>foo<String, Int, Boolean>(2, "2")
}
@@ -0,0 +1,5 @@
// "Create function 'foo' from usage" "true"
fun test(): Int {
return <caret>foo<kotlin.String, Int>(2, "2")
}
@@ -0,0 +1,5 @@
// "Create function 'foo' from usage" "true"
fun test(): Int {
return <caret>foo<Int>(2, "2")
}