Single factory for TYPE_MISMATCH error

This commit is contained in:
Wojciech Lopata
2013-05-09 22:07:31 +02:00
parent 6c8096138a
commit ed6e734c14
20 changed files with 227 additions and 91 deletions
@@ -0,0 +1,7 @@
// "Change function literal return type to 'String'" "true"
fun foo(f: (String) -> Any) {
foo {
(s: String): String ->
s<caret>
}
}
@@ -0,0 +1,7 @@
// "Change function literal return type to 'String'" "true"
fun foo() {
val f: (String) -> String = {
(s: Any): String ->
""<caret>
}
}
@@ -0,0 +1,4 @@
// "Change 'foo' function return type to '() -> Any'" "true"
fun foo(x: Any): () -> Any {
return {x<caret>}
}
@@ -0,0 +1,6 @@
// "Change parameter 'f' type of function 'foo' to '() -> String'" "true"
fun foo(f: () -> String) {
foo {
""<caret>
}
}
@@ -0,0 +1,7 @@
// "Change 'boo' function return type to 'String'" "true"
fun boo(): String {
return ((if (true) {
val a = ""
<caret>a
} else ""))
}
@@ -0,0 +1,12 @@
// "Change 'f' type to '(Int, Int) -> (String) -> Int'" "true"
fun foo() {
val f: (Int, Int) -> (String) -> Int = {
(a: Int, b: Int): (String) -> Int ->
val x = {(s: String) -> 42}
if (true) x
else if (true) x else {
var y = 42
if (true) x<caret> else x
}
}
}
@@ -0,0 +1,7 @@
// "Change function literal return type to 'String'" "true"
fun foo(f: (String) -> Any) {
foo {
(s: String): Int ->
s<caret>
}
}
@@ -0,0 +1,7 @@
// "Change function literal return type to 'String'" "true"
fun foo() {
val f: (String) -> String = {
(s: Any): Int ->
""<caret>
}
}
@@ -0,0 +1,4 @@
// "Change 'foo' function return type to '() -> Any'" "true"
fun foo(x: Any): () -> Int {
return {x<caret>}
}
@@ -0,0 +1,6 @@
// "Change function 'foo' return type to 'String'" "false"
// ERROR: <html>Type mismatch.<table><tr><td>Required:</td><td>jet.Int</td></tr><tr><td>Found:</td><td>jet.String</td></tr></table></html>
// ACTION: Disable 'Replace 'if' with 'when''
// ACTION: Edit intention settings
// ACTION: Replace 'if' with 'when'
fun foo(): Int = if (true) ""<caret>: Int else 4
@@ -0,0 +1,6 @@
// "Change parameter 'f' type of function 'foo' to '() -> String'" "true"
fun foo(f: () -> Int) {
foo {
""<caret>
}
}
@@ -0,0 +1,7 @@
// "Change 'boo' function return type to 'String'" "true"
fun boo(): Int {
return ((if (true) {
val a = ""
<caret>a
} else ""))
}
@@ -0,0 +1,12 @@
// "Change 'f' type to '(Int, Int) -> (String) -> Int'" "true"
fun foo() {
val f: () -> Long = {
(a: Int, b: Int): Long ->
val x = {(s: String) -> 42}
if (true) x
else if (true) x else {
var y = 42
if (true) x<caret> else x
}
}
}