File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed
kotlin-checks-test-sources/src/main/kotlin/checks
sonar-kotlin-checks/src/main/java/org/sonarsource/kotlin/checks Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -127,3 +127,10 @@ private fun <E : Throwable> moo(exception: E) =
127
127
cachedCtor(exception) as E ?
128
128
}
129
129
130
+ private class FooBar (
131
+ something : Any
132
+ ) {
133
+ private val someString: String? = something as ? String
134
+ val isString: Boolean
135
+ get() = someString != null // Compliant
136
+ }
Original file line number Diff line number Diff line change @@ -113,12 +113,12 @@ class UselessNullCheckCheck : AbstractCheck() {
113
113
}
114
114
115
115
private fun KtBinaryExpression.operandComparedToNull (bc : BindingContext ): KtExpression ? {
116
- val left = left?.predictRuntimeValueExpression(bc) ? : return null
117
- val right = right?.predictRuntimeValueExpression(bc) ? : return null
116
+ val leftResolved = left?.predictRuntimeValueExpression(bc) ? : return null
117
+ val rightResolved = right?.predictRuntimeValueExpression(bc) ? : return null
118
118
119
119
return when {
120
- left .isNull() -> right
121
- right .isNull() -> left
120
+ leftResolved .isNull() -> right
121
+ rightResolved .isNull() -> left
122
122
else -> null
123
123
}
124
124
}
You can’t perform that action at this time.
0 commit comments