Suggest to add !! as a quick-fix for type mistmach

This commit is contained in:
Nikolay Krasko
2015-10-26 18:08:18 +03:00
parent f3e6fab68e
commit b8c72ec4e9
10 changed files with 102 additions and 2 deletions
@@ -0,0 +1,7 @@
// "Add non-null asserted (!!) call" "true"
fun test() {
val s: String? = null
other(<caret>s)
}
fun other(s: String) {}
@@ -0,0 +1,7 @@
// "Add non-null asserted (!!) call" "true"
fun test() {
val s: String? = null
other(<caret>s!!)
}
fun other(s: String) {}
@@ -0,0 +1,9 @@
// "Add non-null asserted (!!) call" "false"
// ACTION: Change parameter 's' type of function 'other' to 'String?'
// ERROR: <html>ype mismatch.<table><tr><td>Required:</td><td>kotlin.Int</td></tr><tr><td>Found:</td><td>kotlin.String?</td></tr></table></html>
fun test() {
val s: String? = ""
other(<caret>s)
}
fun other(s: Int) {}
@@ -0,0 +1,8 @@
// "Add non-null asserted (!!) call" "true"
interface Some
fun <T: Some?> test(t: T) {
other(<caret>t)
}
fun other(s: Any) {}
@@ -0,0 +1,8 @@
// "Add non-null asserted (!!) call" "true"
interface Some
fun <T: Some?> test(t: T) {
other(t!!)
}
fun other(s: Any) {}
@@ -0,0 +1,14 @@
// "Add non-null asserted (!!) call" "true"
interface A<out T>
class B<out T>: A<T>
open class C
open class D: C()
fun test() {
val s: B<D>? = B()
other(<caret>s)
}
fun other(s: A<C>) {}
@@ -0,0 +1,14 @@
// "Add non-null asserted (!!) call" "true"
interface A<out T>
class B<out T>: A<T>
open class C
open class D: C()
fun test() {
val s: B<D>? = B()
other(<caret>s!!)
}
fun other(s: A<C>) {}