USELESS_ELVIS_RIGHT_IS_NULL is no more reported for flexible left argument #KT-13593 Fixed
This commit is contained in:
+1
-1
@@ -1284,7 +1284,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
if (leftType != null && isKnownToBeNotNull(left, leftType, context)) {
|
if (leftType != null && isKnownToBeNotNull(left, leftType, context)) {
|
||||||
context.trace.report(USELESS_ELVIS.on(expression, leftType));
|
context.trace.report(USELESS_ELVIS.on(expression, leftType));
|
||||||
}
|
}
|
||||||
else if (KtPsiUtil.isNullConstant(right)) {
|
else if (KtPsiUtil.isNullConstant(right) && leftType != null && !FlexibleTypesKt.isNullabilityFlexible(leftType)) {
|
||||||
context.trace.report(USELESS_ELVIS_RIGHT_IS_NULL.on(expression));
|
context.trace.report(USELESS_ELVIS_RIGHT_IS_NULL.on(expression));
|
||||||
}
|
}
|
||||||
KotlinTypeInfo rightTypeInfo = BindingContextUtils.getRecordedTypeInfo(right, context.trace.getBindingContext());
|
KotlinTypeInfo rightTypeInfo = BindingContextUtils.getRecordedTypeInfo(right, context.trace.getBindingContext());
|
||||||
|
|||||||
Vendored
+19
@@ -9,11 +9,30 @@ public class J {
|
|||||||
public static J staticN;
|
public static J staticN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FILE: JJ.java
|
||||||
|
|
||||||
|
public class JJ {
|
||||||
|
public static JJ staticNN;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: JJJ.java
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.*;
|
||||||
|
|
||||||
|
public class JJJ {
|
||||||
|
@NotNull
|
||||||
|
public static JJJ staticNNN;
|
||||||
|
}
|
||||||
|
|
||||||
// FILE: k.kt
|
// FILE: k.kt
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
val a = J.staticN <!USELESS_ELVIS_RIGHT_IS_NULL!>?: null<!>
|
val a = J.staticN <!USELESS_ELVIS_RIGHT_IS_NULL!>?: null<!>
|
||||||
foo(a)
|
foo(a)
|
||||||
|
val b = JJ.staticNN ?: null
|
||||||
|
foo(b)
|
||||||
|
val c = JJJ.staticNNN <!USELESS_ELVIS!>?: null<!>
|
||||||
|
foo(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun foo(a: Any?) {
|
fun foo(a: Any?) {
|
||||||
|
|||||||
Vendored
+20
@@ -12,3 +12,23 @@ public open class J {
|
|||||||
// Static members
|
// Static members
|
||||||
@org.jetbrains.annotations.Nullable public final var staticN: J?
|
@org.jetbrains.annotations.Nullable public final var staticN: J?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public open class JJ {
|
||||||
|
public constructor JJ()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
// Static members
|
||||||
|
public final var staticNN: JJ!
|
||||||
|
}
|
||||||
|
|
||||||
|
public open class JJJ {
|
||||||
|
public constructor JJJ()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
// Static members
|
||||||
|
@org.jetbrains.annotations.NotNull public final var staticNNN: JJJ
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user