Add "Redundant nullable return type" inspection
^KT-19321 Fixed
This commit is contained in:
committed by
Vladimir Dolzhenko
parent
d703284d01
commit
8420c0b7c7
@@ -0,0 +1 @@
|
||||
org.jetbrains.kotlin.idea.inspections.RedundantNullableReturnTypeInspection
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// PROBLEM: 'foo' always returns non-null type
|
||||
// WITH_RUNTIME
|
||||
fun foo(xs: List<Int>): Int?<caret> {
|
||||
return xs.first()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// PROBLEM: 'foo' always returns non-null type
|
||||
// WITH_RUNTIME
|
||||
fun foo(xs: List<Int>): Int {
|
||||
return xs.first()
|
||||
}
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
fun foo(xs: List<Int>, b: Boolean): Int?<caret> {
|
||||
if (b) {
|
||||
return xs.first()
|
||||
} else {
|
||||
return xs.lastOrNull()
|
||||
}
|
||||
}
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: 'foo' always returns non-null type
|
||||
fun foo(i: Int?): Int?<caret> {
|
||||
if (i != null) {
|
||||
return i
|
||||
} else {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: 'foo' always returns non-null type
|
||||
fun foo(i: Int?): Int {
|
||||
if (i != null) {
|
||||
return i
|
||||
} else {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
// PROBLEM: none
|
||||
fun foo(): String<caret> = ""
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// PROBLEM: none
|
||||
abstract class Foo {
|
||||
open fun foo(): String?<caret> = ""
|
||||
}
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
// PROBLEM: 'foo' always returns non-null type
|
||||
// WITH_RUNTIME
|
||||
fun foo(xs: List<Int>): Int?<caret> = xs.first()
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
// PROBLEM: 'foo' always returns non-null type
|
||||
// WITH_RUNTIME
|
||||
fun foo(xs: List<Int>): Int = xs.first()
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
fun foo(xs: List<Int>, b: Boolean): Int?<caret> = if (b) xs.first() else xs.lastOrNull()
|
||||
@@ -0,0 +1,3 @@
|
||||
// PROBLEM: 'foo' is always non-null type
|
||||
val foo: Int?<caret>
|
||||
get() = 1
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
// PROBLEM: 'foo' is always non-null type
|
||||
val foo: Int
|
||||
get() = 1
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// PROBLEM: 'foo' is always non-null type
|
||||
val foo: Int?<caret>
|
||||
get() {
|
||||
return 1
|
||||
}
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
// PROBLEM: 'foo' is always non-null type
|
||||
val foo: Int
|
||||
get() {
|
||||
return 1
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
// PROBLEM: 'foo' is always non-null type
|
||||
val foo: String?<caret> = ""
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
// PROBLEM: 'foo' is always non-null type
|
||||
val foo: String = ""
|
||||
@@ -0,0 +1,2 @@
|
||||
// PROBLEM: none
|
||||
var foo: String?<caret> = ""
|
||||
Reference in New Issue
Block a user