FIR checker: SENSELESS_(COMPARISON|NULL_IN_WHEN)

Currently DFA does not set "definitely equal to null" for access to variables that got assigned `null`. For example, FIR should mark the following line as SENSELESS_COMPARISON due to `s = null` above.
 https://github.com/JetBrains/kotlin/blob/d1531f9cdd5852352c0133198706125dc63b6007/compiler/testData/diagnostics/tests/smartCasts/alwaysNull.fir.kt#L6

The problem is at https://github.com/JetBrains/kotlin/blob/7e9f27436a77de1c76e3705da7aa1fbe8938336b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzer.kt#L1104

For null assignment, ideally the type should be `Nothing?`. This is
addressed in a followup commit instead.
This commit is contained in:
Tianyu Geng
2021-07-20 09:46:18 -07:00
committed by teamcityserver
parent 4726dcce40
commit c7272f6986
108 changed files with 1410 additions and 1485 deletions
@@ -137,7 +137,7 @@ fun main(args: Array<String?>) {
<!ASSIGNED_VALUE_IS_NEVER_READ!>a<!> = args[0]
} else {
a = args.toString()
if (a != null && a.equals("cde")) return
if (<!SENSELESS_COMPARISON!>a != null<!> && a.equals("cde")) return
}
}
@@ -107,7 +107,7 @@ fun test_7() {
y<!UNSAFE_CALL!>.<!>length // Bad
z.length // OK
}
if (y != null) {
if (<!SENSELESS_COMPARISON!>y != null<!>) {
x<!UNSAFE_CALL!>.<!>length // Bad
y.length // OK
z<!UNSAFE_CALL!>.<!>length // Bad
@@ -14,7 +14,7 @@ var Any?.isNotNull: Boolean
set(value) {
contract {
returns() implies (this@isNotNull != null)
<!ERROR_IN_CONTRACT_DESCRIPTION!>require(this != null)<!>
<!ERROR_IN_CONTRACT_DESCRIPTION!>require(<!SENSELESS_COMPARISON!>this != null<!>)<!>
}
}
@@ -944,11 +944,15 @@ object DIAGNOSTICS_LIST : DiagnosticList("FirErrors") {
val INITIALIZATION_BEFORE_DECLARATION by error<KtExpression>() {
parameter<Symbol>("property")
}
val UNREACHABLE_CODE by warning<KtElement>(PositioningStrategy.UNREACHABLE_CODE) {
parameter<Set<FirSourceElement>>("reachable")
parameter<Set<FirSourceElement>>("unreachable")
}
val SENSELESS_COMPARISON by warning<KtBinaryExpression> {
parameter<FirExpression>("expression")
parameter<Boolean>("compareResult")
}
val SENSELESS_NULL_IN_WHEN by warning<KtElement>()
}
val NULLABILITY by object : DiagnosticGroup("Nullability") {
@@ -507,6 +507,8 @@ object FirErrors {
val VARIABLE_WITH_NO_TYPE_NO_INITIALIZER by error0<KtVariableDeclaration>(SourceElementPositioningStrategies.DECLARATION_NAME)
val INITIALIZATION_BEFORE_DECLARATION by error1<KtExpression, FirBasedSymbol<*>>()
val UNREACHABLE_CODE by warning2<KtElement, Set<FirSourceElement>, Set<FirSourceElement>>(SourceElementPositioningStrategies.UNREACHABLE_CODE)
val SENSELESS_COMPARISON by warning2<KtBinaryExpression, FirExpression, Boolean>()
val SENSELESS_NULL_IN_WHEN by warning0<KtElement>()
// Nullability
val UNSAFE_CALL by error2<PsiElement, ConeKotlinType, FirExpression?>(SourceElementPositioningStrategies.DOT_BY_QUALIFIED)
@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.fir.analysis.checkers.expression
import org.jetbrains.kotlin.KtNodeTypes
import org.jetbrains.kotlin.fir.FirRealSourceElementKind
import org.jetbrains.kotlin.fir.analysis.checkers.ConeTypeCompatibilityChecker
import org.jetbrains.kotlin.fir.analysis.checkers.ConeTypeCompatibilityChecker.isCompatible
@@ -15,17 +16,34 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.reportOn
import org.jetbrains.kotlin.fir.declarations.FirFile
import org.jetbrains.kotlin.fir.declarations.utils.isEnumClass
import org.jetbrains.kotlin.fir.expressions.FirEqualityOperatorCall
import org.jetbrains.kotlin.fir.expressions.FirExpression
import org.jetbrains.kotlin.fir.expressions.FirExpressionWithSmartcastToNull
import org.jetbrains.kotlin.fir.expressions.FirOperation
import org.jetbrains.kotlin.fir.render
import org.jetbrains.kotlin.fir.resolve.inference.inferenceComponents
import org.jetbrains.kotlin.fir.resolve.toFirRegularClass
import org.jetbrains.kotlin.fir.typeContext
import org.jetbrains.kotlin.fir.types.*
object FirEqualityCompatibilityChecker : FirEqualityOperatorCallChecker() {
override fun check(expression: FirEqualityOperatorCall, context: CheckerContext, reporter: DiagnosticReporter) {
val arguments = expression.argumentList.arguments
if (arguments.size != 2) return
val lType = arguments[0].typeRef.coneType
val rType = arguments[1].typeRef.coneType
val lExpr = arguments[0]
val rExpr = arguments[1]
checkCompatibility(lExpr, rExpr, context, expression, reporter)
checkSensibleness(lExpr, rExpr, context, expression, reporter)
}
private fun checkCompatibility(
lExpr: FirExpression,
rExpr: FirExpression,
context: CheckerContext,
expression: FirEqualityOperatorCall,
reporter: DiagnosticReporter
) {
val lType = lExpr.typeRef.coneType
val rType = rExpr.typeRef.coneType
// If one of the type is already `Nothing?`, we skip reporting further comparison. This is to allow comparing with `null`, which has
// type `Nothing?`
if (lType.isNullableNothing || rType.isNullableNothing) return
@@ -95,4 +113,34 @@ object FirEqualityCompatibilityChecker : FirEqualityOperatorCallChecker() {
val firRegularClass = (this as? ConeClassLikeType)?.lookupTag?.toFirRegularClass(context.session) ?: return false
return firRegularClass.isEnumClass
}
private fun checkSensibleness(
lExpr: FirExpression,
rExpr: FirExpression,
context: CheckerContext,
expression: FirEqualityOperatorCall,
reporter: DiagnosticReporter
) {
val expressionComparedWithNull = when {
lExpr.isNullLiteral -> rExpr
rExpr.isNullLiteral -> lExpr
else -> return
}
val type = expressionComparedWithNull.typeRef.coneType
if (type is ConeKotlinErrorType) return
val isPositiveCompare = expression.operation == FirOperation.EQ || expression.operation == FirOperation.IDENTITY
val compareResult = with(context.session.typeContext) {
when {
// `null` literal has type `Nothing?`
type.isNullableNothing || (expressionComparedWithNull is FirExpressionWithSmartcastToNull && expressionComparedWithNull.isStable) -> isPositiveCompare
!type.isNullableType() -> !isPositiveCompare
else -> return
}
}
if (expression.source?.elementType == KtNodeTypes.BINARY_EXPRESSION) {
reporter.reportOn(expression.source, FirErrors.SENSELESS_COMPARISON, expression, compareResult, context)
} else {
reporter.reportOn(expression.source, FirErrors.SENSELESS_NULL_IN_WHEN, context)
}
}
}
@@ -363,6 +363,8 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.SEALED_CLASS_CONS
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.SEALED_SUPERTYPE
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.SEALED_SUPERTYPE_IN_LOCAL_CLASS
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.SECONDARY_CONSTRUCTOR_WITH_BODY_INSIDE_INLINE_CLASS
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.SENSELESS_COMPARISON
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.SENSELESS_NULL_IN_WHEN
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.SETTER_PROJECTED_OUT
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.SETTER_VISIBILITY_INCONSISTENT_WITH_PROPERTY_VISIBILITY
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.SINGLETON_IN_SUPERTYPE
@@ -1308,6 +1310,8 @@ class FirDefaultErrorMessages {
map.put(LEAKED_IN_PLACE_LAMBDA, "Leaked in-place lambda: {2}", SYMBOL)
map.put(FirErrors.WRONG_IMPLIES_CONDITION, "Wrong implies condition")
map.put(UNREACHABLE_CODE, "Unreachable code", NOT_RENDERED, NOT_RENDERED)
map.put(SENSELESS_COMPARISON, "Condition ''{0}'' is always ''{1}''", FIR, TO_STRING)
map.put(SENSELESS_NULL_IN_WHEN, "Expression under 'when' is never equal to null")
// Nullability
map.put(
@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.fir.analysis.diagnostics
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.descriptors.Visibility
import org.jetbrains.kotlin.diagnostics.WhenMissingCase
@@ -6,24 +6,24 @@ fun foo() {
if (x != null) {
bar(x)
if (x != null) {
if (<!SENSELESS_COMPARISON!>x != null<!>) {
bar(x)
if (1 < 2) bar(x)
if (1 > 2) bar(x)
}
if (x == null) {
if (<!SENSELESS_COMPARISON!>x == null<!>) {
bar(x)
}
if (x == null) bar(x) else bar(x)
if (<!SENSELESS_COMPARISON!>x == null<!>) bar(x) else bar(x)
bar(bar(x))
} else if (x == null) {
} else if (<!SENSELESS_COMPARISON!>x == null<!>) {
bar(<!ARGUMENT_TYPE_MISMATCH!>x<!>)
if (x != null) {
if (<!SENSELESS_COMPARISON!>x != null<!>) {
bar(x)
if (x == null) bar(x)
if (x == null) bar(x) else bar(x)
if (<!SENSELESS_COMPARISON!>x == null<!>) bar(x)
if (<!SENSELESS_COMPARISON!>x == null<!>) bar(x) else bar(x)
bar(bar(x) + bar(x))
} else if (x == null) {
} else if (<!SENSELESS_COMPARISON!>x == null<!>) {
bar(<!ARGUMENT_TYPE_MISMATCH!>x<!>)
}
}
@@ -10,7 +10,7 @@ fun foo() {
bar(x)
for (q in a) {
bar(x)
if (x == null) bar(x)
if (<!SENSELESS_COMPARISON!>x == null<!>) bar(x)
}
}
@@ -26,5 +26,5 @@ fun foo() {
if (z != null) bar(z)
bar(<!ARGUMENT_TYPE_MISMATCH!>z<!>)
bar(z!!)
if (z != null) bar(z<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>)
if (<!SENSELESS_COMPARISON!>z != null<!>) bar(z<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>)
}
@@ -9,7 +9,7 @@ fun foo() {
2<!OVERLOAD_RESOLUTION_AMBIGUITY!>+<!><!SYNTAX!><!>
}
else {
if (x == null) return
if (<!SENSELESS_COMPARISON!>x == null<!>) return
2<!OVERLOAD_RESOLUTION_AMBIGUITY!>+<!><!SYNTAX!><!>
}
bar(x)
@@ -8,10 +8,10 @@ fun foo(): Int {
if (x != null) return x
val y: Int? = null
if (y == null) return <!RETURN_TYPE_MISMATCH!>if (y != null) y else y<!>
if (y == null) return <!RETURN_TYPE_MISMATCH!>if (<!SENSELESS_COMPARISON!>y != null<!>) y else y<!>
val z: Int? = null
if (z != null) return if (z == null) z else z
if (z != null) return if (<!SENSELESS_COMPARISON!>z == null<!>) z else z
return <!RETURN_TYPE_MISMATCH!>z<!>
}
@@ -11,7 +11,7 @@ fun foo() {
}
when (x) {
0 -> { if (x == null) return }
0 -> { if (<!SENSELESS_COMPARISON!>x == null<!>) return }
else -> { if (x == null) return }
}
bar(x)
@@ -85,8 +85,8 @@ fun foo5(i: MyInterface, a: Any) {
}
fun foo6(e1: E1?, e2: E2) {
E1.A == null
null == E1.A
<!SENSELESS_COMPARISON!>E1.A == null<!>
<!SENSELESS_COMPARISON!>null == E1.A<!>
e1 == null
null == e1
@@ -95,10 +95,10 @@ fun foo6(e1: E1?, e2: E2) {
<!EQUALITY_NOT_APPLICABLE_WARNING!>e1 == e2<!>
<!EQUALITY_NOT_APPLICABLE_WARNING!>e2 == e1<!>
e2 == null
null == e2
E1.A == null
null == E1.A
<!SENSELESS_COMPARISON!>e2 == null<!>
<!SENSELESS_COMPARISON!>null == e2<!>
<!SENSELESS_COMPARISON!>E1.A == null<!>
<!SENSELESS_COMPARISON!>null == E1.A<!>
}
fun foo7(e1: E1?, e2: E2?) {
@@ -85,8 +85,8 @@ fun foo5(i: MyInterface, a: Any) {
}
fun foo6(e1: E1?, e2: E2) {
E1.A == null
null == E1.A
<!SENSELESS_COMPARISON!>E1.A == null<!>
<!SENSELESS_COMPARISON!>null == E1.A<!>
e1 == null
null == e1
@@ -95,10 +95,10 @@ fun foo6(e1: E1?, e2: E2) {
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>e1 == e2<!>
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>e2 == e1<!>
e2 == null
null == e2
E1.A == null
null == E1.A
<!SENSELESS_COMPARISON!>e2 == null<!>
<!SENSELESS_COMPARISON!>null == e2<!>
<!SENSELESS_COMPARISON!>E1.A == null<!>
<!SENSELESS_COMPARISON!>null == E1.A<!>
}
fun foo7(e1: E1?, e2: E2?) {
@@ -9,7 +9,7 @@ fun CharSequence.bar4() {}
fun <T : CharSequence?> foo(x: T) {
if (x != null) {
if (x != null) {}
if (<!SENSELESS_COMPARISON!>x != null<!>) {}
x.length
x<!UNNECESSARY_SAFE_CALL!>?.<!>length
@@ -8,7 +8,7 @@ fun CharSequence.bar4() {}
fun <T : String?> T.foo() {
if (this != null) {
if (this != null) {}
if (<!SENSELESS_COMPARISON!>this != null<!>) {}
length
this<!UNNECESSARY_SAFE_CALL!>?.<!>length
@@ -8,7 +8,7 @@ fun <T : CharSequence?> foo(x: T) {
var y1: CharSequence = ""
var y2: String = ""
if (x != null) {
if (x != null) {}
if (<!SENSELESS_COMPARISON!>x != null<!>) {}
y1 = x
y2 = <!ASSIGNMENT_TYPE_MISMATCH!>x<!>
@@ -1,10 +0,0 @@
//KT-2457 Verify error when comparing not null value with null in when
package kt2457
fun foo(i: Int) : Int =
when (i) {
1 -> 1
null -> 1
else -> 1
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
//KT-2457 Verify error when comparing not null value with null in when
package kt2457
@@ -1,14 +0,0 @@
//KT-1680 Warn if non-null variable is compared to null
package kt1680
fun foo() {
val x = 1
if (x != null) {} // <-- need a warning here!
if (x == null) {}
if (null != x) {}
if (null == x) {}
val y : Int? = 1
if (y != null) {}
if (y == null) {}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
//KT-1680 Warn if non-null variable is compared to null
package kt1680
@@ -13,7 +13,7 @@ fun A?.bar() {
}
fun A.baz() {
if (this == null) {
if (<!SENSELESS_COMPARISON!>this == null<!>) {
return
}
foo()
@@ -1,8 +0,0 @@
//KT-2223 Comparing non-null value with null might produce helpful warning
package kt2223
fun foo() {
val x: Int? = null
if (x == null) return
if (x == null) return
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
//KT-2223 Comparing non-null value with null might produce helpful warning
package kt2223
@@ -1,16 +0,0 @@
// The type checker used to think that T is not null no matter what the upper bound
fun <T, INDIRECT: T> nullableUpperBound(t: T, ind: INDIRECT) {
if (t == null) {} // was a warning
if (t != null) {} // was a warning
if (ind == null) {} // was a warning
if (ind != null) {} // was a warning
}
fun <T: Any, INDIRECT: T> notNullUpperBound(t: T, ind: INDIRECT) {
if (t == null) {} // still a warning
if (t != null) {} // still a warning
if (ind == null) {} // still a warning
if (ind != null) {} // still a warning
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// The type checker used to think that T is not null no matter what the upper bound
fun <T, INDIRECT: T> nullableUpperBound(t: T, ind: INDIRECT) {
@@ -1,17 +0,0 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION
fun <D> makeDefinitelyNotNull(arg: D?): D = TODO()
fun <N : Number?> test(arg: N) {
makeDefinitelyNotNull(arg) <!USELESS_ELVIS!>?: 1<!>
makeDefinitelyNotNull(arg)<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
makeDefinitelyNotNull(arg)<!UNNECESSARY_SAFE_CALL!>?.<!>toInt()
val nullImposible = when (val dnn = makeDefinitelyNotNull(arg)) {
null -> false
else -> true
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION
@@ -1,22 +0,0 @@
// FILE: J.java
import org.jetbrains.annotations.*;
import java.util.*;
public class J {
@Nullable
public List<String> n() { return null; }
}
// FILE: k.kt
fun list(j: J): Any {
val a = j.n()!!
a<!UNNECESSARY_SAFE_CALL!>?.<!>get(0)
if (a == null) {}
a<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
a.get(0)
return a
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// FILE: J.java
import org.jetbrains.annotations.*;
@@ -24,10 +24,10 @@ fun test() {
val a: Any? = null
if (platformNN != null) {}
if (null != platformNN) {}
if (platformNN == null) {}
if (null == platformNN) {}
if (<!SENSELESS_COMPARISON!>platformNN != null<!>) {}
if (<!SENSELESS_COMPARISON!>null != platformNN<!>) {}
if (<!SENSELESS_COMPARISON!>platformNN == null<!>) {}
if (<!SENSELESS_COMPARISON!>null == platformNN<!>) {}
if (a != null && platformNN != a) {}
@@ -24,10 +24,10 @@ fun test() {
val a: Any? = null
if (platformNN !== null) {}
if (null !== platformNN) {}
if (platformNN === null) {}
if (null === platformNN) {}
if (<!SENSELESS_COMPARISON!>platformNN !== null<!>) {}
if (<!SENSELESS_COMPARISON!>null !== platformNN<!>) {}
if (<!SENSELESS_COMPARISON!>platformNN === null<!>) {}
if (<!SENSELESS_COMPARISON!>null === platformNN<!>) {}
if (platformN !== null) {}
if (platformN === null) {}
@@ -1,15 +0,0 @@
fun readLine() = "x"
fun foo() {
var line = ""
while (line != null) {
line = readLine()
if (line != null) {
bar()
}
}
}
fun bar() {}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
fun readLine() = "x"
fun foo() {
@@ -1,23 +1,23 @@
fun testEquals(x: Int) {
if (x == null) {}
if (x == (null)) {}
if (x == foo@ null) {}
if (<!SENSELESS_COMPARISON!>x == null<!>) {}
if (<!SENSELESS_COMPARISON!>x == (null)<!>) {}
if (<!SENSELESS_COMPARISON!>x == foo@ null<!>) {}
}
fun testEqualsFlipped(x: Int) {
if (null == x) {}
if ((null) == x) {}
if (foo@ null == x) {}
if (<!SENSELESS_COMPARISON!>null == x<!>) {}
if (<!SENSELESS_COMPARISON!>(null) == x<!>) {}
if (<!SENSELESS_COMPARISON!>foo@ null == x<!>) {}
}
fun testNotEquals(x: Int) {
if (x != null) {}
if (x != (null)) {}
if (x != foo@ null) {}
if (<!SENSELESS_COMPARISON!>x != null<!>) {}
if (<!SENSELESS_COMPARISON!>x != (null)<!>) {}
if (<!SENSELESS_COMPARISON!>x != foo@ null<!>) {}
}
fun testNotEqualsFlipped(x: Int) {
if (null != x) {}
if ((null) != x) {}
if (foo@ null != x) {}
}
if (<!SENSELESS_COMPARISON!>null != x<!>) {}
if (<!SENSELESS_COMPARISON!>(null) != x<!>) {}
if (<!SENSELESS_COMPARISON!>foo@ null != x<!>) {}
}
@@ -3,7 +3,7 @@ fun foo(): String {
s = null
s?.length
s<!UNSAFE_CALL!>.<!>length
if (s == null) return s!!
if (<!SENSELESS_COMPARISON!>s == null<!>) return s!!
var t: String? = "y"
if (t == null) t = "x"
var x: Int? = null
@@ -15,7 +15,7 @@ object Impl : SomeSubClass {
fun g(a: SomeClass?) {
var b = (a as? SomeSubClass)?.foo
b = "Hello"
if (b != null) {
if (<!SENSELESS_COMPARISON!>b != null<!>) {
// 'a' cannot be cast to SomeSubClass!
a<!UNSAFE_CALL!>.<!>hashCode()
a.<!UNRESOLVED_REFERENCE!>foo<!>
@@ -24,7 +24,7 @@ fun g(a: SomeClass?) {
}
var c = a as? SomeSubClass
c = Impl
if (c != null) {
if (<!SENSELESS_COMPARISON!>c != null<!>) {
// 'a' cannot be cast to SomeSubClass
a<!UNSAFE_CALL!>.<!>hashCode()
a.<!UNRESOLVED_REFERENCE!>foo<!>
@@ -1,6 +1,6 @@
fun bar(x: Int?): Int {
if (x != null) return -1
if (x == null) return -2
if (<!SENSELESS_COMPARISON!>x == null<!>) return -2
// Should be unreachable
return 2 + 2
}
}
@@ -7,7 +7,7 @@ fun foo(arg: Int?) {
x.hashCode()
x = null
}
if (x != null) x = 42
if (<!SENSELESS_COMPARISON!>x != null<!>) x = 42
// Unsafe because of lambda
x<!UNSAFE_CALL!>.<!>hashCode()
}
@@ -4,7 +4,7 @@ fun String.next(): String {
fun list(start: String) {
var e: Any? = start
if (e==null) return
if (<!SENSELESS_COMPARISON!>e==null<!>) return
while (e is String) {
// Smart cast due to the loop condition
if (e.length == 0)
@@ -3,7 +3,7 @@ fun f() {
var s: String?
s = "a"
var s1 = "" // String ?
if (s != null) { // Redundant
if (<!SENSELESS_COMPARISON!>s != null<!>) { // Redundant
s1.length
// We can do smartcast here and below
s1 = s.toString() // return String?
@@ -18,4 +18,4 @@ fun f() {
val s3 = s.toString()
s3.length
}
}
}
@@ -11,9 +11,9 @@ public fun foo(qq: String?): Int {
// p = r, r = q and q is not null
p.length
} while (!x())
} while (r == null) // r = q and q is not null
} while (<!SENSELESS_COMPARISON!>r == null<!>) // r = q and q is not null
if (!x()) break
}
// Smart cast is possible
return q.length
}
}
@@ -6,7 +6,7 @@ abstract class KotlinClass : JavaInterface1, JavaInterface2 {
fun foo(k: KotlinClass) {
useString(k.getSomething())
useString(k.something)
if (k.something == null) return
if (<!SENSELESS_COMPARISON!>k.something == null<!>) return
k.setSomething(1)
k.something = <!ASSIGNMENT_TYPE_MISMATCH!>1<!>
@@ -1,25 +0,0 @@
// FILE: KotlinFile.kt
abstract class KotlinClass : JavaInterface1, JavaInterface2 {
override fun getSomething(): String = ""
}
fun foo(k: KotlinClass) {
useString(k.getSomething())
useString(k.something)
if (k.something == null) return
k.setSomething("")
k.something = ""
}
fun useString(i: String) {}
// FILE: JavaInterface1.java
public interface JavaInterface1 {
String getSomething();
}
// FILE: JavaInterface2.java
public interface JavaInterface2 {
void setSomething(String value);
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// FILE: KotlinFile.kt
abstract class KotlinClass : JavaInterface1, JavaInterface2 {
override fun getSomething(): String = ""
@@ -1,28 +0,0 @@
// FILE: KotlinFile.kt
abstract class KotlinClass : JavaInterface3 {
override fun getSomething(): String = ""
}
fun foo(k: KotlinClass) {
useString(k.getSomething())
useString(k.something)
if (k.something == null) return
k.setSomething("")
k.something = ""
}
fun useString(i: String) {}
// FILE: JavaInterface1.java
public interface JavaInterface1 {
String getSomething();
}
// FILE: JavaInterface2.java
public interface JavaInterface2 {
void setSomething(String value);
}
// FILE: JavaInterface3.java
public interface JavaInterface3 extends JavaInterface1, JavaInterface2 {}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// FILE: KotlinFile.kt
abstract class KotlinClass : JavaInterface3 {
override fun getSomething(): String = ""
@@ -1,29 +0,0 @@
// FILE: KotlinFile.kt
abstract class KotlinClass : JavaInterface3 {
override fun getSomething(): String = ""
}
fun foo(k: KotlinClass) {
useString(k.getSomething())
useString(k.something)
if (k.something == null) return
k.setSomething("")
k.something = ""
}
fun useString(i: String) {}
// FILE: JavaInterface1.java
public interface JavaInterface1 {
String getSomething();
}
// FILE: JavaInterface2.java
public interface JavaInterface2 {
String getSomething();
void setSomething(String value);
}
// FILE: JavaInterface3.java
public interface JavaInterface3 extends JavaInterface1, JavaInterface2 {}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// FILE: KotlinFile.kt
abstract class KotlinClass : JavaInterface3 {
override fun getSomething(): String = ""
@@ -3,7 +3,7 @@
// exhaustive
fun test1(n: Nothing) = when (n) { }
fun test2(n: Nothing?) = when (n) {
null -> {}
<!SENSELESS_NULL_IN_WHEN!>null<!> -> {}
}
// not exhaustive
@@ -18,7 +18,7 @@ fun identityEqualsWithVariables(x: Any?, y: Any?) {
fun equalConstants() {
contract {
<!ERROR_IN_CONTRACT_DESCRIPTION!>returns() implies (null == null)<!>
<!ERROR_IN_CONTRACT_DESCRIPTION!>returns() implies (<!SENSELESS_COMPARISON!>null == null<!>)<!>
}
}
@@ -27,4 +27,4 @@ fun equalNullWithCall() {
contract {
<!ERROR_IN_CONTRACT_DESCRIPTION!>returns() implies (get() == null)<!>
}
}
}
@@ -6,7 +6,7 @@ import kotlin.contracts.*
fun Any?.foo(): Boolean {
contract {
<!ERROR_IN_CONTRACT_DESCRIPTION!>returns(true) implies (this != null)<!>
<!ERROR_IN_CONTRACT_DESCRIPTION!>returns(true) implies (<!SENSELESS_COMPARISON!>this != null<!>)<!>
}
return this != null
}
}
@@ -39,7 +39,7 @@ fun notNullWhenNotNull (x: Int?): Int? {
fun testNotNullWhenNotNull (x: Int?) {
if (notNullWhenNotNull(x) == null) {
x == null
<!SENSELESS_COMPARISON!>x == null<!>
}
else {
x<!UNSAFE_CALL!>.<!>dec()
@@ -49,7 +49,7 @@ fun testNotNullWhenNotNull (x: Int?) {
x<!UNSAFE_CALL!>.<!>dec()
}
else {
x == null
<!SENSELESS_COMPARISON!>x == null<!>
}
x<!UNSAFE_CALL!>.<!>dec()
@@ -60,7 +60,7 @@ fun testAtLeastOnceFlow(x: Any?) {
do {
myAssert(x is String)
x.length
} while (x != null)
} while (<!SENSELESS_COMPARISON!>x != null<!>)
x.length
}
@@ -5,7 +5,7 @@ fun main(x1: Double?, range: ClosedRange<Double>) {
}
when {
x1 == null -> throw Exception()
<!SENSELESS_COMPARISON!>x1 == null<!> -> throw Exception()
x1 in range -> {}
}
}
@@ -226,7 +226,7 @@ fun case_23(value_1: Nothing) {
// TESTCASE NUMBER: 24
fun case_24(value_1: Nothing?) = when (value_1) {
throw Exception(), <!RETURN_IN_FUNCTION_WITH_EXPRESSION_BODY!>return<!> "" -> ""
null, <!RETURN_IN_FUNCTION_WITH_EXPRESSION_BODY!>return<!> <!RETURN_IN_FUNCTION_WITH_EXPRESSION_BODY!>return<!> <!RETURN_IN_FUNCTION_WITH_EXPRESSION_BODY!>return<!> "", throw throw throw Exception() -> ""
<!SENSELESS_NULL_IN_WHEN!>null<!>, <!RETURN_IN_FUNCTION_WITH_EXPRESSION_BODY!>return<!> <!RETURN_IN_FUNCTION_WITH_EXPRESSION_BODY!>return<!> <!RETURN_IN_FUNCTION_WITH_EXPRESSION_BODY!>return<!> "", throw throw throw Exception() -> ""
else -> ""
}
@@ -157,29 +157,29 @@ fun <T> T?.case_22_3(): Boolean? {
// TESTCASE NUMBER: 23
fun <T : Number?> T.case_23_1(): Boolean {
contract { returns(false) implies (this@case_23_1 !is Int || this@case_23_1 == null) }
return !(this@case_23_1 !is Int || this@case_23_1 == null)
return !(this@case_23_1 !is Int || <!SENSELESS_COMPARISON!>this@case_23_1 == null<!>)
}
fun <T : Number?> T.case_23_2(): Boolean? {
contract { returnsNotNull() implies (this@case_23_2 !is Int || this@case_23_2 == null) }
return if (this@case_23_2 !is Int || this@case_23_2 == null) true else null
return if (this@case_23_2 !is Int || <!SENSELESS_COMPARISON!>this@case_23_2 == null<!>) true else null
}
fun <T : Number?> T.case_23_3(): Boolean? {
contract { returns(null) implies (this@case_23_3 !is Int || this@case_23_3 == null) }
return if (this@case_23_3 !is Int || this@case_23_3 == null) null else true
return if (this@case_23_3 !is Int || <!SENSELESS_COMPARISON!>this@case_23_3 == null<!>) null else true
}
// TESTCASE NUMBER: 24
inline fun <reified T : Any?> T?.case_24_1(): Boolean {
contract { returns(false) implies (this@case_24_1 !is Number || this@case_24_1 !is Int || this@case_24_1 == null) }
return !(this@case_24_1 !is Number || this@case_24_1 !is Int || this@case_24_1 == null)
return !(this@case_24_1 !is Number || this@case_24_1 !is Int || <!SENSELESS_COMPARISON!>this@case_24_1 == null<!>)
}
inline fun <reified T : Any?> T?.case_24_2(): Boolean? {
contract { returnsNotNull() implies (this@case_24_2 !is Number || this@case_24_2 !is Int || this@case_24_2 == null) }
return if (this@case_24_2 !is Number || this@case_24_2 !is Int || this@case_24_2 == null) true else null
return if (this@case_24_2 !is Number || this@case_24_2 !is Int || <!SENSELESS_COMPARISON!>this@case_24_2 == null<!>) true else null
}
inline fun <reified T : Any?> T?.case_24_3(): Boolean? {
contract { returns(null) implies (this@case_24_3 !is Number || this@case_24_3 !is Int || this@case_24_3 == null) }
return if (this@case_24_3 !is Number || this@case_24_3 !is Int || this@case_24_3 == null) null else true
return if (this@case_24_3 !is Number || this@case_24_3 !is Int || <!SENSELESS_COMPARISON!>this@case_24_3 == null<!>) null else true
}
// TESTCASE NUMBER: 25
@@ -15,13 +15,13 @@ fun <T> T?.case_1() {
// TESTCASE NUMBER: 2
fun <T : Number?> T.case_2() {
contract { returns() implies (this@case_2 !is Int || this@case_2 == null) }
if (!(this@case_2 !is Int || this@case_2 == null)) throw Exception()
if (!(this@case_2 !is Int || <!SENSELESS_COMPARISON!>this@case_2 == null<!>)) throw Exception()
}
// TESTCASE NUMBER: 3
inline fun <reified T : Any?> T?.case_3() {
contract { returns() implies (this@case_3 !is Number || this@case_3 !is Int || this@case_3 == null) }
if (!(this@case_3 !is Number || this@case_3 !is Int || this@case_3 == null)) throw Exception()
if (!(this@case_3 !is Number || this@case_3 !is Int || <!SENSELESS_COMPARISON!>this@case_3 == null<!>)) throw Exception()
}
// TESTCASE NUMBER: 4
@@ -45,37 +45,37 @@ fun <T> T?.case_4_4(): Boolean? {
// TESTCASE NUMBER: 5
fun <T : Number?> T.case_5_1(): Boolean {
contract { returns(true) implies (this@case_5_1 !is Int || this@case_5_1 == null) }
return this@case_5_1 !is Int || this@case_5_1 == null
return this@case_5_1 !is Int || <!SENSELESS_COMPARISON!>this@case_5_1 == null<!>
}
fun <T : Number?> T.case_5_2(): Boolean {
contract { returns(false) implies (this@case_5_2 !is Int || this@case_5_2 == null) }
return !(this@case_5_2 !is Int || this@case_5_2 == null)
return !(this@case_5_2 !is Int || <!SENSELESS_COMPARISON!>this@case_5_2 == null<!>)
}
fun <T : Number?> T.case_5_3(): Boolean? {
contract { returnsNotNull() implies (this@case_5_3 !is Int || this@case_5_3 == null) }
return if (this@case_5_3 !is Int || this@case_5_3 == null) true else null
return if (this@case_5_3 !is Int || <!SENSELESS_COMPARISON!>this@case_5_3 == null<!>) true else null
}
fun <T : Number?> T.case_5_4(): Boolean? {
contract { returns(null) implies (this@case_5_4 !is Int || this@case_5_4 == null) }
return if (this@case_5_4 !is Int || this@case_5_4 == null) null else true
return if (this@case_5_4 !is Int || <!SENSELESS_COMPARISON!>this@case_5_4 == null<!>) null else true
}
// TESTCASE NUMBER: 6
inline fun <reified T : Any?> T?.case_6_1(): Boolean {
contract { returns(true) implies (this@case_6_1 !is Number || this@case_6_1 !is Int || this@case_6_1 == null) }
return this@case_6_1 !is Number || this@case_6_1 !is Int || this@case_6_1 == null
return this@case_6_1 !is Number || this@case_6_1 !is Int || <!SENSELESS_COMPARISON!>this@case_6_1 == null<!>
}
inline fun <reified T : Any?> T?.case_6_2(): Boolean {
contract { returns(false) implies (this@case_6_2 !is Number || this@case_6_2 !is Int || this@case_6_2 == null) }
return !(this@case_6_2 !is Number || this@case_6_2 !is Int || this@case_6_2 == null)
return !(this@case_6_2 !is Number || this@case_6_2 !is Int || <!SENSELESS_COMPARISON!>this@case_6_2 == null<!>)
}
inline fun <reified T : Any?> T?.case_6_3(): Boolean? {
contract { returnsNotNull() implies (this@case_6_3 is Number && this@case_6_3 is Int && this@case_6_3 != null) }
return if (this@case_6_3 is Number && this@case_6_3 is Int && this@case_6_3 != null) true else null
return if (this@case_6_3 is Number && this@case_6_3 is Int && <!SENSELESS_COMPARISON!>this@case_6_3 != null<!>) true else null
}
inline fun <reified T : Any?> T?.case_6_4(): Boolean? {
contract { returns(null) implies (this@case_6_4 is Number && this@case_6_4 is Int && this@case_6_4 != null) }
return if (this@case_6_4 is Number && this@case_6_4 is Int && this@case_6_4 != null) null else true
return if (this@case_6_4 is Number && this@case_6_4 is Int && <!SENSELESS_COMPARISON!>this@case_6_4 != null<!>) null else true
}
// FILE: main.kt
@@ -15,13 +15,13 @@ fun <T> T?.case_1(value_1: Int?) {
// TESTCASE NUMBER: 2
fun <T : Number?> T.case_2(value_2: Any?) {
contract { returns() implies (this@case_2 !is Int || this@case_2 == null || value_2 !is Number || value_2 == null) }
if (!(this@case_2 !is Int || this@case_2 == null || value_2 !is Number || value_2 == null)) throw Exception()
if (!(this@case_2 !is Int || <!SENSELESS_COMPARISON!>this@case_2 == null<!> || value_2 !is Number || <!SENSELESS_COMPARISON!>value_2 == null<!>)) throw Exception()
}
// TESTCASE NUMBER: 3
fun <T : Any?> T?.case_3(value_2: Any?) {
contract { returns() implies (this@case_3 !is Number || this@case_3 !is Int || this@case_3 == null || value_2 == null) }
if (!(this@case_3 !is Number || this@case_3 !is Int || this@case_3 == null || value_2 == null)) throw Exception()
if (!(this@case_3 !is Number || this@case_3 !is Int || <!SENSELESS_COMPARISON!>this@case_3 == null<!> || value_2 == null)) throw Exception()
}
// TESTCASE NUMBER: 4
@@ -51,37 +51,37 @@ fun <T> T?.case_5_4(value_1: Int?): Boolean? {
// TESTCASE NUMBER: 6
fun <T : Number?> T.case_6_1(value_2: Any?): Boolean {
contract { returns(true) implies (this@case_6_1 !is Int || this@case_6_1 == null || value_2 !is Number || value_2 == null) }
return this@case_6_1 !is Int || this@case_6_1 == null || value_2 !is Number || value_2 == null
return this@case_6_1 !is Int || <!SENSELESS_COMPARISON!>this@case_6_1 == null<!> || value_2 !is Number || <!SENSELESS_COMPARISON!>value_2 == null<!>
}
fun <T : Number?> T.case_6_2(value_2: Any?): Boolean {
contract { returns(false) implies (this@case_6_2 !is Int || this@case_6_2 == null || value_2 !is Number || value_2 == null) }
return !(this@case_6_2 !is Int || this@case_6_2 == null || value_2 !is Number || value_2 == null)
return !(this@case_6_2 !is Int || <!SENSELESS_COMPARISON!>this@case_6_2 == null<!> || value_2 !is Number || <!SENSELESS_COMPARISON!>value_2 == null<!>)
}
fun <T : Number?> T.case_6_3(value_2: Any?): Boolean? {
contract { returnsNotNull() implies (this@case_6_3 !is Int || this@case_6_3 == null || value_2 !is Number || value_2 == null) }
return if (this@case_6_3 !is Int || this@case_6_3 == null || value_2 !is Number || value_2 == null) true else null
return if (this@case_6_3 !is Int || <!SENSELESS_COMPARISON!>this@case_6_3 == null<!> || value_2 !is Number || <!SENSELESS_COMPARISON!>value_2 == null<!>) true else null
}
fun <T : Number?> T.case_6_4(value_2: Any?): Boolean? {
contract { returns(null) implies (this@case_6_4 !is Int || this@case_6_4 == null || value_2 !is Number || value_2 == null) }
return if (this@case_6_4 !is Int || this@case_6_4 == null || value_2 !is Number || value_2 == null) null else true
return if (this@case_6_4 !is Int || <!SENSELESS_COMPARISON!>this@case_6_4 == null<!> || value_2 !is Number || <!SENSELESS_COMPARISON!>value_2 == null<!>) null else true
}
// TESTCASE NUMBER: 7
fun <T : Any?> T?.case_7_1(value_2: Any?): Boolean {
contract { returns(true) implies (this@case_7_1 !is Number || this@case_7_1 !is Int || this@case_7_1 == null || value_2 == null) }
return this@case_7_1 !is Number || this@case_7_1 !is Int || this@case_7_1 == null || value_2 == null
return this@case_7_1 !is Number || this@case_7_1 !is Int || <!SENSELESS_COMPARISON!>this@case_7_1 == null<!> || value_2 == null
}
fun <T : Any?> T?.case_7_2(value_2: Any?): Boolean {
contract { returns(false) implies (this@case_7_2 !is Number || this@case_7_2 !is Int || this@case_7_2 == null || value_2 == null) }
return !(this@case_7_2 !is Number || this@case_7_2 !is Int || this@case_7_2 == null || value_2 == null)
return !(this@case_7_2 !is Number || this@case_7_2 !is Int || <!SENSELESS_COMPARISON!>this@case_7_2 == null<!> || value_2 == null)
}
fun <T : Any?> T?.case_7_3(value_2: Any?): Boolean? {
contract { returnsNotNull() implies (this@case_7_3 !is Number || this@case_7_3 !is Int || this@case_7_3 == null || value_2 == null) }
return if (this@case_7_3 !is Number || this@case_7_3 !is Int || this@case_7_3 == null || value_2 == null) true else null
return if (this@case_7_3 !is Number || this@case_7_3 !is Int || <!SENSELESS_COMPARISON!>this@case_7_3 == null<!> || value_2 == null) true else null
}
fun <T : Any?> T?.case_7_4(value_2: Any?): Boolean? {
contract { returns(null) implies (this@case_7_4 !is Number || this@case_7_4 !is Int || this@case_7_4 == null || value_2 == null) }
return if (this@case_7_4 !is Number || this@case_7_4 !is Int || this@case_7_4 == null || value_2 == null) null else true
return if (this@case_7_4 !is Number || this@case_7_4 !is Int || <!SENSELESS_COMPARISON!>this@case_7_4 == null<!> || value_2 == null) null else true
}
// TESTCASE NUMBER: 8
@@ -25,7 +25,7 @@ fun case_4(value_1: Number, block: (() -> Unit)?): Boolean? {
returns(null) implies (block == null)
}<!>
return value_1 == null
return <!SENSELESS_COMPARISON!>value_1 == null<!>
}
// TESTCASE NUMBER: 5
@@ -48,7 +48,7 @@ fun <T> T?.case_6(value_1: Number, value_2: String?): Boolean? {
returnsNotNull() implies (value_2 == null)
}<!>
return value_1 == null
return <!SENSELESS_COMPARISON!>value_1 == null<!>
}
// FILE: main.kt
@@ -69,7 +69,7 @@ fun case_3(value_1: Int?) {
// TESTCASE NUMBER: 4
fun case_4(value_1: Any?) {
if (contracts.case_4(value_1) != null) {
if (<!SENSELESS_COMPARISON!>contracts.case_4(value_1) != null<!>) {
value_1.toByte()
}
}
@@ -15,13 +15,13 @@ fun <T> T?.case_1() {
// TESTCASE NUMBER: 2
fun <T : Number?> T.case_2() {
contract { returns() implies (this@case_2 is Int && this@case_2 != null) }
if (!(this@case_2 is Int && this@case_2 != null)) throw Exception()
if (!(this@case_2 is Int && <!SENSELESS_COMPARISON!>this@case_2 != null<!>)) throw Exception()
}
// TESTCASE NUMBER: 3
inline fun <reified T : Any?> T?.case_3() {
contract { returns() implies (this@case_3 is Number && this@case_3 is Int && this@case_3 != null) }
if (!(this@case_3 is Number && this@case_3 is Int && this@case_3 != null)) throw Exception()
if (!(this@case_3 is Number && this@case_3 is Int && <!SENSELESS_COMPARISON!>this@case_3 != null<!>)) throw Exception()
}
// TESTCASE NUMBER: 4
@@ -45,37 +45,37 @@ fun <T> T?.case_4_4(): Boolean? {
// TESTCASE NUMBER: 5
fun <T : Number?> T.case_5_1(): Boolean {
contract { returns(true) implies (this@case_5_1 is Int && this@case_5_1 != null) }
return this@case_5_1 is Int && this@case_5_1 != null
return this@case_5_1 is Int && <!SENSELESS_COMPARISON!>this@case_5_1 != null<!>
}
fun <T : Number?> T.case_5_2(): Boolean {
contract { returns(false) implies (this@case_5_2 is Int && this@case_5_2 != null) }
return !(this@case_5_2 is Int && this@case_5_2 != null)
return !(this@case_5_2 is Int && <!SENSELESS_COMPARISON!>this@case_5_2 != null<!>)
}
fun <T : Number?> T.case_5_3(): Boolean? {
contract { returnsNotNull() implies (this@case_5_3 is Int && this@case_5_3 != null) }
return if (this@case_5_3 is Int && this@case_5_3 != null) true else null
return if (this@case_5_3 is Int && <!SENSELESS_COMPARISON!>this@case_5_3 != null<!>) true else null
}
fun <T : Number?> T.case_5_4(): Boolean? {
contract { returns(null) implies (this@case_5_4 is Int && this@case_5_4 != null) }
return if (this@case_5_4 is Int && this@case_5_4 != null) null else true
return if (this@case_5_4 is Int && <!SENSELESS_COMPARISON!>this@case_5_4 != null<!>) null else true
}
// TESTCASE NUMBER: 6
inline fun <reified T : Any?> T?.case_6_1(): Boolean {
contract { returns(true) implies (this@case_6_1 is Number && this@case_6_1 is Int && this@case_6_1 != null) }
return this@case_6_1 is Number && this@case_6_1 is Int && this@case_6_1 != null
return this@case_6_1 is Number && this@case_6_1 is Int && <!SENSELESS_COMPARISON!>this@case_6_1 != null<!>
}
inline fun <reified T : Any?> T?.case_6_2(): Boolean {
contract { returns(false) implies (this@case_6_2 is Number && this@case_6_2 is Int && this@case_6_2 != null) }
return !(this@case_6_2 is Number && this@case_6_2 is Int && this@case_6_2 != null)
return !(this@case_6_2 is Number && this@case_6_2 is Int && <!SENSELESS_COMPARISON!>this@case_6_2 != null<!>)
}
inline fun <reified T : Any?> T?.case_6_3(): Boolean? {
contract { returnsNotNull() implies (this@case_6_3 is Number && this@case_6_3 is Int && this@case_6_3 != null) }
return if (this@case_6_3 is Number && this@case_6_3 is Int && this@case_6_3 != null) true else null
return if (this@case_6_3 is Number && this@case_6_3 is Int && <!SENSELESS_COMPARISON!>this@case_6_3 != null<!>) true else null
}
inline fun <reified T : Any?> T?.case_6_4(): Boolean? {
contract { returns(null) implies (this@case_6_4 is Number && this@case_6_4 is Int && this@case_6_4 != null) }
return if (this@case_6_4 is Number && this@case_6_4 is Int && this@case_6_4 != null) null else true
return if (this@case_6_4 is Number && this@case_6_4 is Int && <!SENSELESS_COMPARISON!>this@case_6_4 != null<!>) null else true
}
// FILE: main.kt
@@ -15,13 +15,13 @@ fun <T> T?.case_1(value_1: Int?) {
// TESTCASE NUMBER: 2
fun <T : Number?> T.case_2(value_2: Any?) {
contract { returns() implies (this@case_2 is Int && this@case_2 != null && value_2 is Number && value_2 != null) }
if (!(this@case_2 is Int && this@case_2 != null && value_2 is Number && value_2 != null)) throw Exception()
if (!(this@case_2 is Int && <!SENSELESS_COMPARISON!>this@case_2 != null<!> && value_2 is Number && <!SENSELESS_COMPARISON!>value_2 != null<!>)) throw Exception()
}
// TESTCASE NUMBER: 3
fun <T : Any?> T?.case_3(value_2: Any?) {
contract { returns() implies (this@case_3 is Number && this@case_3 is Int && this@case_3 != null && value_2 != null) }
if (!(this@case_3 is Number && this@case_3 is Int && this@case_3 != null && value_2 != null)) throw Exception()
if (!(this@case_3 is Number && this@case_3 is Int && <!SENSELESS_COMPARISON!>this@case_3 != null<!> && value_2 != null)) throw Exception()
}
// TESTCASE NUMBER: 4
@@ -51,37 +51,37 @@ fun <T> T?.case_5_4(value_1: Int?): Boolean? {
// TESTCASE NUMBER: 6
fun <T : Number?> T.case_6_1(value_2: Any?): Boolean {
contract { returns(true) implies (this@case_6_1 is Int && this@case_6_1 != null && value_2 is Number && value_2 != null) }
return this@case_6_1 is Int && this@case_6_1 != null && value_2 is Number && value_2 != null
return this@case_6_1 is Int && <!SENSELESS_COMPARISON!>this@case_6_1 != null<!> && value_2 is Number && <!SENSELESS_COMPARISON!>value_2 != null<!>
}
fun <T : Number?> T.case_6_2(value_2: Any?): Boolean {
contract { returns(false) implies (this@case_6_2 is Int && this@case_6_2 != null && value_2 is Number && value_2 != null) }
return !(this@case_6_2 is Int && this@case_6_2 != null && value_2 is Number && value_2 != null)
return !(this@case_6_2 is Int && <!SENSELESS_COMPARISON!>this@case_6_2 != null<!> && value_2 is Number && <!SENSELESS_COMPARISON!>value_2 != null<!>)
}
fun <T : Number?> T.case_6_3(value_2: Any?): Boolean? {
contract { returnsNotNull() implies (this@case_6_3 is Int && this@case_6_3 != null && value_2 is Number && value_2 != null) }
return if (this@case_6_3 is Int && this@case_6_3 != null && value_2 is Number && value_2 != null) true else null
return if (this@case_6_3 is Int && <!SENSELESS_COMPARISON!>this@case_6_3 != null<!> && value_2 is Number && <!SENSELESS_COMPARISON!>value_2 != null<!>) true else null
}
fun <T : Number?> T.case_6_4(value_2: Any?): Boolean? {
contract { returns(null) implies (this@case_6_4 is Int && this@case_6_4 != null && value_2 is Number && value_2 != null) }
return if (this@case_6_4 is Int && this@case_6_4 != null && value_2 is Number && value_2 != null) null else true
return if (this@case_6_4 is Int && <!SENSELESS_COMPARISON!>this@case_6_4 != null<!> && value_2 is Number && <!SENSELESS_COMPARISON!>value_2 != null<!>) null else true
}
// TESTCASE NUMBER: 7
fun <T : Any?> T?.case_7_1(value_2: Any?): Boolean {
contract { returns(true) implies (this@case_7_1 is Number && this@case_7_1 is Int && this@case_7_1 != null && value_2 != null) }
return this@case_7_1 is Number && this@case_7_1 is Int && this@case_7_1 != null && value_2 != null
return this@case_7_1 is Number && this@case_7_1 is Int && <!SENSELESS_COMPARISON!>this@case_7_1 != null<!> && value_2 != null
}
fun <T : Any?> T?.case_7_2(value_2: Any?): Boolean {
contract { returns(true) implies (this@case_7_2 is Number && this@case_7_2 is Int && this@case_7_2 != null && value_2 != null) }
return this@case_7_2 is Number && this@case_7_2 is Int && this@case_7_2 != null && value_2 != null
return this@case_7_2 is Number && this@case_7_2 is Int && <!SENSELESS_COMPARISON!>this@case_7_2 != null<!> && value_2 != null
}
fun <T : Any?> T?.case_7_3(value_2: Any?): Boolean? {
contract { returnsNotNull() implies (this@case_7_3 is Number && this@case_7_3 is Int && this@case_7_3 != null && value_2 != null) }
return if (this@case_7_3 is Number && this@case_7_3 is Int && this@case_7_3 != null && value_2 != null) true else null
return if (this@case_7_3 is Number && this@case_7_3 is Int && <!SENSELESS_COMPARISON!>this@case_7_3 != null<!> && value_2 != null) true else null
}
fun <T : Any?> T?.case_7_4(value_2: Any?): Boolean? {
contract { returns(null) implies (this@case_7_4 is Number && this@case_7_4 is Int && this@case_7_4 != null && value_2 != null) }
return if (this@case_7_4 is Number && this@case_7_4 is Int && this@case_7_4 != null && value_2 != null) null else true
return if (this@case_7_4 is Number && this@case_7_4 is Int && <!SENSELESS_COMPARISON!>this@case_7_4 != null<!> && value_2 != null) null else true
}
// TESTCASE NUMBER: 8
@@ -26,7 +26,7 @@ fun case_4(value_1: Number, block: (() -> Unit)?): Boolean? {
returns(null) implies (block != null)
}
return value_1 == null
return <!SENSELESS_COMPARISON!>value_1 == null<!>
}
// TESTCASE NUMBER: 5
@@ -49,7 +49,7 @@ fun <T> T?.case_6(value_1: Number, value_2: String?): Boolean? {
returnsNotNull() implies (value_2 != null)
}<!>
return value_1 == null
return <!SENSELESS_COMPARISON!>value_1 == null<!>
}
// FILE: main.kt
@@ -23,8 +23,8 @@ fun case_3(value_1: String?, value_2: Boolean): Boolean {
// TESTCASE NUMBER: 4
fun case_4(value_1: Nothing?, value_2: Boolean?): Boolean? {
contract { <!ERROR_IN_CONTRACT_DESCRIPTION!>returns(null) implies (value_1 == null || value_2 != null || value_2 == false)<!> }
return if (value_1 == null || value_2 != null || value_2 == false) null else true
contract { <!ERROR_IN_CONTRACT_DESCRIPTION!>returns(null) implies (<!SENSELESS_COMPARISON!>value_1 == null<!> || value_2 != null || value_2 == false)<!> }
return if (<!SENSELESS_COMPARISON!>value_1 == null<!> || value_2 != null || value_2 == false) null else true
}
// TESTCASE NUMBER: 5
@@ -5,7 +5,7 @@ import kotlin.contracts.*
// TESTCASE NUMBER: 1
fun Any?.case_1(): Boolean {
contract {
<!ERROR_IN_CONTRACT_DESCRIPTION!>returns(true) implies (this != null)<!>
<!ERROR_IN_CONTRACT_DESCRIPTION!>returns(true) implies (<!SENSELESS_COMPARISON!>this != null<!>)<!>
}
return this != null
}
@@ -21,7 +21,7 @@ fun Any?.case_2(): Boolean {
// TESTCASE NUMBER: 3
fun <T> T?.case_3(): Boolean {
contract {
<!ERROR_IN_CONTRACT_DESCRIPTION!>returnsNotNull() implies (this != null)<!>
<!ERROR_IN_CONTRACT_DESCRIPTION!>returnsNotNull() implies (<!SENSELESS_COMPARISON!>this != null<!>)<!>
}
return this != null
}
@@ -66,7 +66,7 @@ fun case_11(value_1: Any?): Boolean? {
// TESTCASE NUMBER: 12
fun Char.case_12() {
contract { returns() implies (this@case_12 == null) }
if (this@case_12 != null) throw Exception()
if (<!SENSELESS_COMPARISON!>this@case_12 != null<!>) throw Exception()
}
// TESTCASE NUMBER: 13
@@ -61,12 +61,12 @@ class case_5<T> : ClassLevel5() {
inner class case_5_1 {
fun <K : Number?>K.case_5_1_1() {
contract { <!ERROR_IN_CONTRACT_DESCRIPTION!>returns() implies (<!UNRESOLVED_LABEL!>this@case_5_1<!> !is ClassLevel1 && <!UNRESOLVED_LABEL!>this@case_5_1<!> != null || <!UNRESOLVED_LABEL!>this@case_5<!> is ClassLevel1 && this@case_5_1_1 is Float)<!> }
if (!(this@case_5_1 !is ClassLevel1 && this@case_5_1 != null || <!USELESS_IS_CHECK!>this@case_5 is ClassLevel1<!> && this is Float)) throw Exception()
if (!(this@case_5_1 !is ClassLevel1 && <!SENSELESS_COMPARISON!>this@case_5_1 != null<!> || <!USELESS_IS_CHECK!>this@case_5 is ClassLevel1<!> && this is Float)) throw Exception()
}
fun case_5_1_2() {
contract { <!ERROR_IN_CONTRACT_DESCRIPTION!>returns() implies (<!UNRESOLVED_LABEL!>this@case_5_1<!> !is ClassLevel1 || <!UNRESOLVED_LABEL!>this@case_5<!> is ClassLevel1 || <!UNRESOLVED_LABEL!>this@case_5_1<!> == null)<!> }
if (!(this@case_5_1 !is ClassLevel1 || <!USELESS_IS_CHECK!>this@case_5 is ClassLevel1<!> || this@case_5_1 == null)) throw Exception()
if (!(this@case_5_1 !is ClassLevel1 || <!USELESS_IS_CHECK!>this@case_5 is ClassLevel1<!> || <!SENSELESS_COMPARISON!>this@case_5_1 == null<!>)) throw Exception()
}
}
}
@@ -20,7 +20,7 @@ fun case_1(x: Any?) {
// TESTCASE NUMBER: 3
fun case_3() {
if (Object.prop_1 == null !== null)
if (<!SENSELESS_COMPARISON!>Object.prop_1 == null !== null<!>)
else {
Object.prop_1
Object.prop_1<!UNSAFE_CALL!>.<!>equals(null)
@@ -56,15 +56,15 @@ fun case_5() {
val x: Unit? = null
if (<!EQUALITY_NOT_APPLICABLE!>x !== <!USELESS_IS_CHECK!>null is Boolean?<!><!>) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit?")!>x<!>
if (x !== null == null) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit?")!>x<!><!UNSAFE_CALL!>.<!>equals(null)
if (x !== null == null) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit?")!>x<!>.propT
if (x !== null == null) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit?")!>x<!><!UNSAFE_CALL!>.<!>propAny
if (x !== null == null) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit?")!>x<!>.propNullableT
if (x !== null == null) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit?")!>x<!>.propNullableAny
if (x !== null == null) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit?")!>x<!>.funT()
if (x !== null == null) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit?")!>x<!><!UNSAFE_CALL!>.<!>funAny()
if (x !== null == null) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit?")!>x<!>.funNullableT()
if (x !== null == null) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit?")!>x<!>.funNullableAny()
if (<!SENSELESS_COMPARISON!>x !== null == null<!>) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit?")!>x<!><!UNSAFE_CALL!>.<!>equals(null)
if (<!SENSELESS_COMPARISON!>x !== null == null<!>) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit?")!>x<!>.propT
if (<!SENSELESS_COMPARISON!>x !== null == null<!>) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit?")!>x<!><!UNSAFE_CALL!>.<!>propAny
if (<!SENSELESS_COMPARISON!>x !== null == null<!>) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit?")!>x<!>.propNullableT
if (<!SENSELESS_COMPARISON!>x !== null == null<!>) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit?")!>x<!>.propNullableAny
if (<!SENSELESS_COMPARISON!>x !== null == null<!>) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit?")!>x<!>.funT()
if (<!SENSELESS_COMPARISON!>x !== null == null<!>) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit?")!>x<!><!UNSAFE_CALL!>.<!>funAny()
if (<!SENSELESS_COMPARISON!>x !== null == null<!>) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit?")!>x<!>.funNullableT()
if (<!SENSELESS_COMPARISON!>x !== null == null<!>) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit?")!>x<!>.funNullableAny()
}
// TESTCASE NUMBER: 6
@@ -103,13 +103,13 @@ fun case_7() {
// TESTCASE NUMBER: 8
fun case_8(x: TypealiasNullableString) {
if (x !== null === null && <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableString")!>x<!> != null != null) <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableString")!>x<!><!UNSAFE_CALL!>.<!>get(0)
if (x !== null != null && <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableString")!>x<!> != null === null) <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableString")!>x<!><!UNSAFE_CALL!>.<!>get(0)
if (<!SENSELESS_COMPARISON!><!SENSELESS_COMPARISON!>x !== null<!> === null<!> && <!SENSELESS_COMPARISON!><!SENSELESS_COMPARISON!><!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableString")!>x<!> != null<!> != null<!>) <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableString")!>x<!><!UNSAFE_CALL!>.<!>get(0)
if (<!SENSELESS_COMPARISON!><!SENSELESS_COMPARISON!>x !== null<!> != null<!> && <!SENSELESS_COMPARISON!><!SENSELESS_COMPARISON!><!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableString")!>x<!> != null<!> === null<!>) <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableString")!>x<!><!UNSAFE_CALL!>.<!>get(0)
}
// TESTCASE NUMBER: 9
fun case_9(x: TypealiasNullableString?) {
if (x === null === null) {
if (<!SENSELESS_COMPARISON!>x === null === null<!>) {
} else if (<!USELESS_IS_CHECK!>false is Boolean<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableString?")!>x<!>
@@ -122,7 +122,7 @@ fun case_10() {
val a = Class()
if (a.prop_4 === null || <!USELESS_IS_CHECK!>true is Boolean<!>) {
if (a.prop_4 != null !== null) {
if (<!SENSELESS_COMPARISON!>a.prop_4 != null !== null<!>) {
a.prop_4
a.prop_4<!UNSAFE_CALL!>.<!>equals(null)
a.prop_4.propT
@@ -165,17 +165,17 @@ fun case_11(x: TypealiasNullableStringIndirect?, y: TypealiasNullableStringIndir
// TESTCASE NUMBER: 12
fun case_12(x: TypealiasNullableStringIndirect, y: TypealiasNullableStringIndirect) =
if (<!USELESS_IS_CHECK!>(x == null) !is Boolean<!> === false) "1"
else if (<!USELESS_IS_CHECK!>(y === null !== null) is Boolean<!>) <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableStringIndirect")!>x<!>
else if (y === null != null) <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableStringIndirect")!>x<!>.equals(null)
else if (y === null != null) <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableStringIndirect")!>x<!>.propT
else if (y === null != null) <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableStringIndirect")!>x<!><!UNSAFE_CALL!>.<!>propAny
else if (y === null != null) <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableStringIndirect")!>x<!>.propNullableT
else if (y === null != null) <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableStringIndirect")!>x<!>.propNullableAny
else if (y === null != null) <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableStringIndirect")!>x<!>.funT()
else if (y === null != null) <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableStringIndirect")!>x<!><!UNSAFE_CALL!>.<!>funAny()
else if (y === null != null) <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableStringIndirect")!>x<!>.funNullableT()
else if (y === null != null) <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableStringIndirect")!>x<!>.funNullableAny()
if (<!USELESS_IS_CHECK!>(<!SENSELESS_COMPARISON!>x == null<!>) !is Boolean<!> === false) "1"
else if (<!USELESS_IS_CHECK!>(<!SENSELESS_COMPARISON!><!SENSELESS_COMPARISON!>y === null<!> !== null<!>) is Boolean<!>) <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableStringIndirect")!>x<!>
else if (<!SENSELESS_COMPARISON!><!SENSELESS_COMPARISON!>y === null<!> != null<!>) <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableStringIndirect")!>x<!>.equals(null)
else if (<!SENSELESS_COMPARISON!><!SENSELESS_COMPARISON!>y === null<!> != null<!>) <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableStringIndirect")!>x<!>.propT
else if (<!SENSELESS_COMPARISON!><!SENSELESS_COMPARISON!>y === null<!> != null<!>) <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableStringIndirect")!>x<!><!UNSAFE_CALL!>.<!>propAny
else if (<!SENSELESS_COMPARISON!><!SENSELESS_COMPARISON!>y === null<!> != null<!>) <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableStringIndirect")!>x<!>.propNullableT
else if (<!SENSELESS_COMPARISON!><!SENSELESS_COMPARISON!>y === null<!> != null<!>) <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableStringIndirect")!>x<!>.propNullableAny
else if (<!SENSELESS_COMPARISON!><!SENSELESS_COMPARISON!>y === null<!> != null<!>) <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableStringIndirect")!>x<!>.funT()
else if (<!SENSELESS_COMPARISON!><!SENSELESS_COMPARISON!>y === null<!> != null<!>) <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableStringIndirect")!>x<!><!UNSAFE_CALL!>.<!>funAny()
else if (<!SENSELESS_COMPARISON!><!SENSELESS_COMPARISON!>y === null<!> != null<!>) <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableStringIndirect")!>x<!>.funNullableT()
else if (<!SENSELESS_COMPARISON!><!SENSELESS_COMPARISON!>y === null<!> != null<!>) <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableStringIndirect")!>x<!>.funNullableAny()
else "-1"
// TESTCASE NUMBER: 13
@@ -200,15 +200,15 @@ fun case_14() {
if (a.x != <!USELESS_IS_CHECK!>null !is Boolean !is Boolean<!>) {
if (a.x != null == true) {
if (a.x !== null == false) {
if (a.x != null == null) {
if (a.x != null !== null) {
if (a.x != null === true) {
if (a.x !== null === <!USELESS_IS_CHECK!>true !is Boolean<!> == true) {
if (a.x != null !== false) {
if (a.x != null === false) {
if (a.x !== null === true) {
if (<!USELESS_IS_CHECK!>(a.x != null != true) !is Boolean<!>) {
if (<!SENSELESS_COMPARISON!>a.x !== null<!> == false) {
if (<!SENSELESS_COMPARISON!><!SENSELESS_COMPARISON!>a.x != null<!> == null<!>) {
if (<!SENSELESS_COMPARISON!><!SENSELESS_COMPARISON!>a.x != null<!> !== null<!>) {
if (<!SENSELESS_COMPARISON!>a.x != null<!> === true) {
if (<!SENSELESS_COMPARISON!>a.x !== null<!> === <!USELESS_IS_CHECK!>true !is Boolean<!> == true) {
if (<!SENSELESS_COMPARISON!>a.x != null<!> !== false) {
if (<!SENSELESS_COMPARISON!>a.x != null<!> === false) {
if (<!SENSELESS_COMPARISON!>a.x !== null<!> === true) {
if (<!USELESS_IS_CHECK!>(<!SENSELESS_COMPARISON!>a.x != null<!> != true) !is Boolean<!>) {
if (a.x != null is Boolean) {
if (a.x != <!USELESS_IS_CHECK!>null is Boolean is Boolean<!>) {
if (a.x !== null is Boolean) {
@@ -268,7 +268,7 @@ val case_17 = if (nullableIntProperty == null == true == false) 0 else {
//TESTCASE NUMBER: 18
fun case_18(a: DeepObject.A.B.C.D.E.F.G.J?) {
if (a != null !== null) {
if (<!SENSELESS_COMPARISON!>a != null !== null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("DeepObject.A.B.C.D.E.F.G.J?")!>a<!>
<!DEBUG_INFO_EXPRESSION_TYPE("DeepObject.A.B.C.D.E.F.G.J?")!>a<!><!UNSAFE_CALL!>.<!>equals(null)
<!DEBUG_INFO_EXPRESSION_TYPE("DeepObject.A.B.C.D.E.F.G.J?")!>a<!>.propT
@@ -302,7 +302,7 @@ fun case_19(b: Boolean) {
}
} else null
if (<!EQUALITY_NOT_APPLICABLE!>a != null !is Boolean<!> && <!EQUALITY_NOT_APPLICABLE!>a<!UNSAFE_CALL!>.<!>B19 != null is Boolean<!> && <!EQUALITY_NOT_APPLICABLE!>a<!UNSAFE_CALL!>.<!>B19<!UNSAFE_CALL!>.<!>C19 != null is Boolean<!> && a<!UNSAFE_CALL!>.<!>B19<!UNSAFE_CALL!>.<!>C19<!UNSAFE_CALL!>.<!>D19 != null == null && a<!UNSAFE_CALL!>.<!>B19<!UNSAFE_CALL!>.<!>C19<!UNSAFE_CALL!>.<!>D19<!UNSAFE_CALL!>.<!>x != null !== null) {
if (<!EQUALITY_NOT_APPLICABLE!>a != null !is Boolean<!> && <!EQUALITY_NOT_APPLICABLE!>a<!UNSAFE_CALL!>.<!>B19 != null is Boolean<!> && <!EQUALITY_NOT_APPLICABLE!>a<!UNSAFE_CALL!>.<!>B19<!UNSAFE_CALL!>.<!>C19 != null is Boolean<!> && <!SENSELESS_COMPARISON!>a<!UNSAFE_CALL!>.<!>B19<!UNSAFE_CALL!>.<!>C19<!UNSAFE_CALL!>.<!>D19 != null == null<!> && <!SENSELESS_COMPARISON!>a<!UNSAFE_CALL!>.<!>B19<!UNSAFE_CALL!>.<!>C19<!UNSAFE_CALL!>.<!>D19<!UNSAFE_CALL!>.<!>x != null !== null<!>) {
a<!UNSAFE_CALL!>.<!>B19<!UNSAFE_CALL!>.<!>C19<!UNSAFE_CALL!>.<!>D19<!UNSAFE_CALL!>.<!>x
a<!UNSAFE_CALL!>.<!>B19<!UNSAFE_CALL!>.<!>C19<!UNSAFE_CALL!>.<!>D19<!UNSAFE_CALL!>.<!>x<!UNSAFE_CALL!>.<!>equals(null)
a<!UNSAFE_CALL!>.<!>B19<!UNSAFE_CALL!>.<!>C19<!UNSAFE_CALL!>.<!>D19<!UNSAFE_CALL!>.<!>x.propT
@@ -28,7 +28,7 @@ fun case_3(x: Boolean?) {
// TESTCASE NUMBER: 4
fun case_4(x: Boolean?) {
if (if (x != null) x else x != null) {
if (if (x != null) x else <!SENSELESS_COMPARISON!>x != null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Boolean?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Boolean?")!>x<!><!UNSAFE_CALL!>.<!>not()
}
@@ -17,7 +17,7 @@ fun case_1(x: ClassWithCustomEquals) {
// TESTCASE NUMBER: 2
fun case_2(x: ClassWithCustomEquals) {
if (x == null) {
if (<!SENSELESS_COMPARISON!>x == null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("ClassWithCustomEquals & kotlin.Nothing")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("ClassWithCustomEquals & kotlin.Nothing")!>x<!>.inv()
}
@@ -75,7 +75,7 @@ fun case_6(x: ClassWithCustomEquals) {
// TESTCASE NUMBER: 7
fun case_7(x: ClassWithCustomEquals) {
if ((x != null) == false) {
if ((<!SENSELESS_COMPARISON!>x != null<!>) == false) {
<!DEBUG_INFO_EXPRESSION_TYPE("ClassWithCustomEquals & kotlin.Nothing")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("ClassWithCustomEquals & kotlin.Nothing")!>x<!>.inv()
}
@@ -32,7 +32,7 @@ class Case2 {
val x: Int
init {
val y = this
if (y.x == null) {
if (<!SENSELESS_COMPARISON!>y.x == null<!>) {
x = 11
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>x<!>
this.x
@@ -144,7 +144,7 @@ fun case_9() {
outer@ while (x != null) {
inner@ do {
x = null
} while (x != null)
} while (<!SENSELESS_COMPARISON!>x != null<!>)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String? & kotlin.Nothing?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String? & kotlin.Nothing?")!>x<!><!UNSAFE_CALL!>.<!>length
}
@@ -171,7 +171,7 @@ fun case_11() {
inner@ do {
x = null
break
} while (x == null)
} while (<!SENSELESS_COMPARISON!>x == null<!>)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String? & kotlin.Nothing?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String? & kotlin.Nothing?")!>x<!><!UNSAFE_CALL!>.<!>length
}
@@ -36,7 +36,7 @@ inline fun <reified T>case_3(x: Any?) {
// TESTCASE NUMBER: 4
inline fun <reified T : <!FINAL_UPPER_BOUND!>Boolean<!>>case_4(x: Any?) {
if (x is Int is T == null) {
if (<!SENSELESS_COMPARISON!>x is Int is T == null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>.<!UNRESOLVED_REFERENCE!>inv<!>()
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!><!UNSAFE_CALL!>.<!>propAny
@@ -46,7 +46,7 @@ inline fun <reified T : <!FINAL_UPPER_BOUND!>Boolean<!>>case_4(x: Any?) {
// TESTCASE NUMBER: 5
fun case_5(x: Any?) {
if (x is Int != null) {
if (<!SENSELESS_COMPARISON!>x is Int != null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>.<!UNRESOLVED_REFERENCE!>inv<!>()
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!><!UNSAFE_CALL!>.<!>propAny
@@ -56,7 +56,7 @@ fun case_5(x: Any?) {
// TESTCASE NUMBER: 6
fun case_6(x: Any?) {
if (x is Int == null) {
if (<!SENSELESS_COMPARISON!>x is Int == null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>.<!UNRESOLVED_REFERENCE!>inv<!>()
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!><!UNSAFE_CALL!>.<!>propAny
@@ -28,7 +28,7 @@ fun case_3(x: Boolean?) {
// TESTCASE NUMBER: 4
fun case_4(x: Boolean?) {
if (if (x != null) x else x != null) {
if (if (x != null) x else <!SENSELESS_COMPARISON!>x != null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Boolean?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Boolean?")!>x<!><!UNSAFE_CALL!>.<!>not()
}
File diff suppressed because it is too large Load Diff
@@ -183,7 +183,7 @@ fun case_6(a: Interface1?, b: Interface2, d: Boolean) {
x.apply {
this as Interface3
<!DEBUG_INFO_EXPRESSION_TYPE("Interface2? & Interface1? & Interface3 & Interface2 & Interface1")!>this<!>
if (this != null) {
if (<!SENSELESS_COMPARISON!>this != null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("Interface2? & Interface1? & Interface3 & Interface2 & Interface1")!>this<!>
<!DEBUG_INFO_EXPRESSION_TYPE("Interface2? & Interface1? & Interface3 & Interface2 & Interface1")!>this<!>.equals(null)
<!DEBUG_INFO_EXPRESSION_TYPE("Interface2? & Interface1? & Interface3 & Interface2 & Interface1")!>this<!>.propT
@@ -201,7 +201,7 @@ fun case_6(a: Interface1?, b: Interface2, d: Boolean) {
x.let {
it as Interface3
<!DEBUG_INFO_EXPRESSION_TYPE("Interface2? & Interface1? & Interface3 & Interface2 & Interface1")!>it<!>
if (it != null) {
if (<!SENSELESS_COMPARISON!>it != null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("Interface2? & Interface1? & Interface3 & Interface2 & Interface1")!>it<!>
<!DEBUG_INFO_EXPRESSION_TYPE("Interface2? & Interface1? & Interface3 & Interface2 & Interface1")!>it<!>.equals(null)
<!DEBUG_INFO_EXPRESSION_TYPE("Interface2? & Interface1? & Interface3 & Interface2 & Interface1")!>it<!>.propT
@@ -87,7 +87,7 @@ fun <T> T?.case_4() {
// TESTCASE NUMBER: 5
fun <T> T?.case_5() {
if (this is Interface1) {
if (this != null) {
if (<!SENSELESS_COMPARISON!>this != null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("T? & Interface1 & T?!!")!>this<!>
<!DEBUG_INFO_EXPRESSION_TYPE("T? & Interface1 & T?!!")!>this<!>.equals(null)
this.propT
@@ -319,7 +319,7 @@ fun <T> T.case_8() {
// TESTCASE NUMBER: 9
fun <T : Number> T.case_9() {
if (this != null) {
if (<!SENSELESS_COMPARISON!>this != null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("T")!>this<!>
<!DEBUG_INFO_EXPRESSION_TYPE("T")!>this<!>.equals(null)
<!DEBUG_INFO_EXPRESSION_TYPE("T")!>this<!>.propT
@@ -566,7 +566,7 @@ fun <T> T.case_12() where T : Number?, T: Interface1? {
* ISSUES: KT-28785
*/
fun <T> T.case_13() where T : Out<*>?, T: Comparable<T?> {
if (this != null) {
if (<!SENSELESS_COMPARISON!>this != null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("T")!>this<!>
<!DEBUG_INFO_EXPRESSION_TYPE("T")!>this<!>.equals(null)
<!DEBUG_INFO_EXPRESSION_TYPE("T")!>this<!>.propT
@@ -3493,7 +3493,7 @@ fun <T> T.case_56() where T : Number?, T: Interface1? {
* ISSUES: KT-28785
*/
fun <T> T.case_57() where T : Out<*>?, T: Comparable<T?> {
if (this != null) {
if (<!SENSELESS_COMPARISON!>this != null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("T")!>this<!>
<!DEBUG_INFO_EXPRESSION_TYPE("T")!>this<!>.equals(null)
<!DEBUG_INFO_EXPRESSION_TYPE("T")!>this<!>.propT
@@ -3798,7 +3798,7 @@ fun <T> T.case_61() where T : InterfaceWithTypeParameter1<T>?, T: Case61_3<T>?,
// TESTCASE NUMBER: 62
fun Nothing?.case_62() {
if (this != null) {
if (<!SENSELESS_COMPARISON!>this != null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing? & kotlin.Nothing")!>this<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing? & kotlin.Nothing")!>this<!>.hashCode()
@@ -3817,7 +3817,7 @@ fun Nothing?.case_62() {
// TESTCASE NUMBER: 63
fun Nothing.case_63() {
if (this != null) {
if (<!SENSELESS_COMPARISON!>this != null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing")!>this<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing")!>this<!>.hashCode()
@@ -107,7 +107,7 @@ fun <T> case_4(x: T?) {
// TESTCASE NUMBER: 5
fun <T> case_5(x: T?) {
if (x is Interface1) {
if (x != null) {
if (<!SENSELESS_COMPARISON!>x != null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("T? & Interface1 & T?!!")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("T? & Interface1 & T?!!")!>x<!>.equals(null)
x.propT
@@ -387,7 +387,7 @@ fun <T> case_8(x: T) {
// TESTCASE NUMBER: 9
fun <T : Number> case_9(x: T) {
if (x != null) {
if (<!SENSELESS_COMPARISON!>x != null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("T")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("T")!>x<!>.equals(null)
<!DEBUG_INFO_EXPRESSION_TYPE("T")!>x<!>.propT
@@ -682,7 +682,7 @@ fun <T> case_12(x: T) where T : Number?, T: Interface1? {
* ISSUES: KT-28785
*/
fun <T> case_13(x: T) where T : Out<*>?, T: Comparable<T?> {
if (x != null) {
if (<!SENSELESS_COMPARISON!>x != null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("T")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("T")!>x<!>.equals(null)
<!DEBUG_INFO_EXPRESSION_TYPE("T")!>x<!>.propT
@@ -3986,7 +3986,7 @@ fun <T> case_56(x: T) where T : Number?, T: Interface1? {
* ISSUES: KT-28785
*/
fun <T> case_57(x: T) where T : Out<*>?, T: Comparable<T?> {
if (x != null) {
if (<!SENSELESS_COMPARISON!>x != null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("T")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("T")!>x<!>.equals(null)
<!DEBUG_INFO_EXPRESSION_TYPE("T")!>x<!>.propT
@@ -4,7 +4,7 @@
// TESTCASE NUMBER: 1
fun case_1(vararg x: Int?) {
if (x != null) {
if (<!SENSELESS_COMPARISON!>x != null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Array<out kotlin.Int?>")!>x<!>
x[0]
}
@@ -29,7 +29,7 @@ fun case_2(vararg x: Int?) {
// TESTCASE NUMBER: 3
fun <T> case_3(vararg x: T?) {
if (x != null) {
if (<!SENSELESS_COMPARISON!>x != null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Array<out T?>")!>x<!>
x[0]
}
@@ -26,7 +26,7 @@ fun case_2(x: Unit?) {
// TESTCASE NUMBER: 3
fun case_3(x: Nothing?) {
if (x != null) else return
if (<!SENSELESS_COMPARISON!>x != null<!>) else return
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing? & kotlin.Nothing")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing? & kotlin.Nothing")!>x<!>.hashCode()
}
@@ -358,7 +358,7 @@ fun case_26(x: Unit?, y: List<*>) {
// TESTCASE NUMBER: 27
fun case_27(x: Nothing?) = (l@ {
if (x != null) else return@l
if (<!SENSELESS_COMPARISON!>x != null<!>) else return@l
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing? & kotlin.Nothing")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing? & kotlin.Nothing")!>x<!>.hashCode()
})()
@@ -26,7 +26,7 @@ fun case_2(x: Unit?) {
// TESTCASE NUMBER: 3
fun case_3(x: Nothing?) {
if (x != null) else throw Exception()
if (<!SENSELESS_COMPARISON!>x != null<!>) else throw Exception()
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing? & kotlin.Nothing")!>x<!>
}
@@ -31,7 +31,7 @@ fun case_2(x: Unit?) {
// TESTCASE NUMBER: 3
fun case_3(x: Nothing?, f: Boolean) {
do {
if (x != null) else break
if (<!SENSELESS_COMPARISON!>x != null<!>) else break
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing? & kotlin.Nothing")!>x<!>.hashCode()
} while (f)
}
@@ -181,21 +181,21 @@ fun case_8(b: Boolean, c: Boolean?) {
val a = Case8_16__2()
if (a.x !== null && false) {
if (false || false || false || false || a.x != null || false || false || false) {
if (a.x !== null && true) {
if (a.x != null && b) {
if (a.x != null && b && !b) {
if (a.x != null && c != null && !c) {
if (a.x !== null && c) {
if (a.x != null && b && b && b && b && b && b && b && b && b && b && b) {
if (a.x != null && !b && !b && !b && !b && !b && !b && !b && !b && !b) {
if (a.x !== null && null == null) {
if (a.x != null && null!!) {
if (a.x != null) {
if (a.x != null) {
if (a.x !== null) {
if (a.x != null) {
if (a.x !== null) {
if (false || false || false || false || <!SENSELESS_COMPARISON!>a.x != null<!> || false || false || false) {
if (<!SENSELESS_COMPARISON!>a.x !== null<!> && true) {
if (<!SENSELESS_COMPARISON!>a.x != null<!> && b) {
if (<!SENSELESS_COMPARISON!>a.x != null<!> && b && !b) {
if (<!SENSELESS_COMPARISON!>a.x != null<!> && c != null && !c) {
if (<!SENSELESS_COMPARISON!>a.x !== null<!> && c) {
if (<!SENSELESS_COMPARISON!>a.x != null<!> && b && b && b && b && b && b && b && b && b && b && b) {
if (<!SENSELESS_COMPARISON!>a.x != null<!> && !b && !b && !b && !b && !b && !b && !b && !b && !b) {
if (<!SENSELESS_COMPARISON!>a.x !== null<!> && <!SENSELESS_COMPARISON!>null == null<!>) {
if (<!SENSELESS_COMPARISON!>a.x != null<!> && null!!) {
if (<!SENSELESS_COMPARISON!>a.x != null<!>) {
if (<!SENSELESS_COMPARISON!>a.x != null<!>) {
if (<!SENSELESS_COMPARISON!>a.x !== null<!>) {
if (<!SENSELESS_COMPARISON!>a.x != null<!>) {
if (<!SENSELESS_COMPARISON!>a.x !== null<!>) {
a.x
a.x.equals(null)
a.x.propT
@@ -408,35 +408,35 @@ fun case_16(b: Boolean, c: Boolean?) {
val a = Case8_16__2()
if (a.x != null && false && false && false && false && false && false) {
if ( a.x == null || false) {
if ( <!SENSELESS_COMPARISON!>a.x == null<!> || false) {
} else {
if ( a.x === null && true) {
if ( <!SENSELESS_COMPARISON!>a.x === null<!> && true) {
} else {
if (a.x == null || !b) {
if (<!SENSELESS_COMPARISON!>a.x == null<!> || !b) {
} else {
if (a.x == null || b || !b) {
if (<!SENSELESS_COMPARISON!>a.x == null<!> || b || !b) {
} else {
if (a.x == null || c == null || !c) {
if (<!SENSELESS_COMPARISON!>a.x == null<!> || c == null || !c) {
} else {
if (a.x === null || c) {
if (<!SENSELESS_COMPARISON!>a.x === null<!> || c) {
} else {
if (a.x == null || b || b || b || b || b || b || b || b || b || b || b) {
if (<!SENSELESS_COMPARISON!>a.x == null<!> || b || b || b || b || b || b || b || b || b || b || b) {
} else {
if (a.x == null || !b || !b || !b || !b || !b || !b || !b || !b || !b) {
if (<!SENSELESS_COMPARISON!>a.x == null<!> || !b || !b || !b || !b || !b || !b || !b || !b || !b) {
} else {
if (a.x === null || null == null) {
if (<!SENSELESS_COMPARISON!>a.x === null<!> || <!SENSELESS_COMPARISON!>null == null<!>) {
} else {
if (a.x == null || null!!) {
if (<!SENSELESS_COMPARISON!>a.x == null<!> || null!!) {
} else {
if (a.x == null) {
if (<!SENSELESS_COMPARISON!>a.x == null<!>) {
} else {
if (a.x == null) {
if (<!SENSELESS_COMPARISON!>a.x == null<!>) {
} else {
if (a.x === null) {
if (<!SENSELESS_COMPARISON!>a.x === null<!>) {
} else {
if (a.x == null) {
if (<!SENSELESS_COMPARISON!>a.x == null<!>) {
} else {
if (a.x === null) {
if (<!SENSELESS_COMPARISON!>a.x === null<!>) {
} else {
a.x
a.x.equals(null)
@@ -22,7 +22,7 @@ fun case_1(x: Any?) {
// TESTCASE NUMBER: 2
fun case_2(x: Nothing?) {
if (x == null) {
if (<!SENSELESS_COMPARISON!>x == null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing?")!>x<!>
}
}
@@ -60,14 +60,14 @@ fun case_6(x: EmptyClass?) {
// TESTCASE NUMBER: 7
fun case_7() {
if (nullableStringProperty == null || <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String? & kotlin.String")!>nullableStringProperty<!> == null) {
if (nullableStringProperty == null || <!SENSELESS_COMPARISON!><!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String? & kotlin.String")!>nullableStringProperty<!> == null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String?")!>nullableStringProperty<!>
}
}
// TESTCASE NUMBER: 8
fun case_8(x: TypealiasNullableString) {
if (x == null && <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableString & kotlin.Nothing?")!>x<!> == null)
if (<!SENSELESS_COMPARISON!>x == null<!> && <!SENSELESS_COMPARISON!><!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableString & kotlin.Nothing?")!>x<!> == null<!>)
<!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableString & kotlin.Nothing?")!>x<!>
}
@@ -102,9 +102,9 @@ fun case_11(x: TypealiasNullableString?, y: TypealiasNullableString) {
if (x != null) {
} else {
if (y == null) {
if (<!SENSELESS_COMPARISON!>y == null<!>) {
if (nullableStringProperty != null) {
if (z == null) {
if (<!SENSELESS_COMPARISON!>z == null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableString? & kotlin.Nothing?")!>x<!>
}
}
@@ -113,8 +113,8 @@ fun case_11(x: TypealiasNullableString?, y: TypealiasNullableString) {
}
// TESTCASE NUMBER: 12
fun case_12(x: TypealiasNullableString, y: TypealiasNullableString) = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String?")!>if (x != null && true && true && true) "1"
else if (y != null) <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableString")!>x<!>
fun case_12(x: TypealiasNullableString, y: TypealiasNullableString) = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String?")!>if (<!SENSELESS_COMPARISON!>x != null<!> && true && true && true) "1"
else if (<!SENSELESS_COMPARISON!>y != null<!>) <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableString")!>x<!>
else "-1"<!>
// TESTCASE NUMBER: 13
@@ -135,21 +135,21 @@ fun case_14() {
val a = Case14()
if (a.x == null) {
if (a.x == null) {
if (a.x == null) {
if (a.x == null) {
if (a.x == null) {
if (a.x == null) {
if (a.x == null) {
if (a.x == null) {
if (a.x == null) {
if (a.x == null) {
if (a.x == null) {
if (a.x == null) {
if (a.x == null) {
if (a.x == null) {
if (a.x == null) {
if (a.x == null) {
if (<!SENSELESS_COMPARISON!>a.x == null<!>) {
if (<!SENSELESS_COMPARISON!>a.x == null<!>) {
if (<!SENSELESS_COMPARISON!>a.x == null<!>) {
if (<!SENSELESS_COMPARISON!>a.x == null<!>) {
if (<!SENSELESS_COMPARISON!>a.x == null<!>) {
if (<!SENSELESS_COMPARISON!>a.x == null<!>) {
if (<!SENSELESS_COMPARISON!>a.x == null<!>) {
if (<!SENSELESS_COMPARISON!>a.x == null<!>) {
if (<!SENSELESS_COMPARISON!>a.x == null<!>) {
if (<!SENSELESS_COMPARISON!>a.x == null<!>) {
if (<!SENSELESS_COMPARISON!>a.x == null<!>) {
if (<!SENSELESS_COMPARISON!>a.x == null<!>) {
if (<!SENSELESS_COMPARISON!>a.x == null<!>) {
if (<!SENSELESS_COMPARISON!>a.x == null<!>) {
if (<!SENSELESS_COMPARISON!>a.x == null<!>) {
a.x
}
}
@@ -171,7 +171,7 @@ fun case_14() {
// TESTCASE NUMBER: 15
fun case_15(x: TypealiasNullableString) {
val t = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String?")!>if (x != null) "" else {
val t = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String?")!>if (<!SENSELESS_COMPARISON!>x != null<!>) "" else {
<!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableString & kotlin.Nothing?")!>x<!>
}<!>
}
@@ -180,7 +180,7 @@ fun case_15(x: TypealiasNullableString) {
fun case_16() {
val x: TypealiasNullableNothing = null
if (x == null || false || false || false) {
if (<!SENSELESS_COMPARISON!>x == null<!> || false || false || false) {
<!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableNothing")!>x<!>
}
}
@@ -258,7 +258,7 @@ fun case_23(a: ((Float) -> Int?)?, b: Float?) {
if (a == null && b == null) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Function1<kotlin.Float, kotlin.Int?>? & kotlin.Nothing?")!>a<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Float? & kotlin.Nothing?")!>b<!>
if (a != null) {
if (<!SENSELESS_COMPARISON!>a != null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Function1<kotlin.Float, kotlin.Int?>? & kotlin.Nothing")!>a<!>
}
}
@@ -96,7 +96,7 @@ fun case_8(x: Boolean?) {
// TESTCASE NUMBER: 9
fun case_9(x: Boolean?) {
while (x ?: return)
while (x == null)
while (<!SENSELESS_COMPARISON!>x == null<!>)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Boolean? & kotlin.Nothing")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Boolean? & kotlin.Boolean")!>x<!>.equals(10)
@@ -200,7 +200,7 @@ fun case_17(x: Boolean?, y: Boolean?) {
else -> if (true) if (true) if (true) if (true) if (true) x!! else x!! else x!! else x!! else x!! else x!!
}
false -> x!!
null -> if (true) if (true) if (true) if (true) if (true) x!! else x!! else x!! else x!! else x!! else x!!
<!SENSELESS_NULL_IN_WHEN!>null<!> -> if (true) if (true) if (true) if (true) if (true) x!! else x!! else x!! else x!! else x!! else x!!
} else x!! else x!! else x!! else x!! else x!!
}
break@loop
@@ -18,21 +18,21 @@ import otherpackage.*
// TESTCASE NUMBER: 1
fun case_1(x: Any) {
if (x === null) {
if (<!SENSELESS_COMPARISON!>x === null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any & kotlin.Nothing")!>x<!>
}
}
// TESTCASE NUMBER: 2
fun case_2(x: Nothing) {
if (x == null) {
if (<!SENSELESS_COMPARISON!>x == null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing")!>x<!>
}
}
// TESTCASE NUMBER: 3
fun case_3() {
if (Object.prop_2 != null)
if (<!SENSELESS_COMPARISON!>Object.prop_2 != null<!>)
else {
Object.prop_2
}
@@ -40,7 +40,7 @@ fun case_3() {
// TESTCASE NUMBER: 4
fun case_4(x: Char) {
if (x == null && true) {
if (<!SENSELESS_COMPARISON!>x == null<!> && true) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Char & kotlin.Nothing")!>x<!>
}
}
@@ -49,33 +49,33 @@ fun case_4(x: Char) {
fun case_5() {
val x: Unit = kotlin.Unit
if (x == null) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit & kotlin.Nothing")!>x<!>
if (<!SENSELESS_COMPARISON!>x == null<!>) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit & kotlin.Nothing")!>x<!>
}
// TESTCASE NUMBER: 6
fun case_6(x: EmptyClass) {
val y = true
if (x == null && !y) {
if (<!SENSELESS_COMPARISON!>x == null<!> && !y) {
<!DEBUG_INFO_EXPRESSION_TYPE("EmptyClass & kotlin.Nothing")!>x<!>
}
}
// TESTCASE NUMBER: 7
fun case_7() {
if (anonymousTypeProperty == null || <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>anonymousTypeProperty<!> == null) {
if (<!SENSELESS_COMPARISON!>anonymousTypeProperty == null<!> || <!SENSELESS_COMPARISON!><!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>anonymousTypeProperty<!> == null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>anonymousTypeProperty<!>
}
}
// TESTCASE NUMBER: 8
fun case_8(x: TypealiasString) {
if (x == null && <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasString & kotlin.Nothing")!>x<!> == null) <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasString")!>x<!>
if (<!SENSELESS_COMPARISON!>x == null<!> && <!SENSELESS_COMPARISON!><!DEBUG_INFO_EXPRESSION_TYPE("TypealiasString & kotlin.Nothing")!>x<!> == null<!>) <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasString")!>x<!>
}
// TESTCASE NUMBER: 9
fun case_9(x: TypealiasString) {
if (x != null) {
if (<!SENSELESS_COMPARISON!>x != null<!>) {
} else if (false) {
<!DEBUG_INFO_EXPRESSION_TYPE("TypealiasString & kotlin.Nothing")!>x<!>
@@ -86,8 +86,8 @@ fun case_9(x: TypealiasString) {
fun case_10() {
val a = Class()
if (a.prop_5 != null || true) {
if (a.prop_5 == null) {
if (<!SENSELESS_COMPARISON!>a.prop_5 != null<!> || true) {
if (<!SENSELESS_COMPARISON!>a.prop_5 == null<!>) {
a.prop_5
}
}
@@ -97,12 +97,12 @@ fun case_10() {
fun case_11(x: TypealiasString, y: TypealiasString) {
val z: TypealiasString = TypealiasString()
if (x != null) {
if (<!SENSELESS_COMPARISON!>x != null<!>) {
} else {
if (y == null) {
if (stringProperty != null) {
if (false || false || false || z == null || false) {
if (<!SENSELESS_COMPARISON!>y == null<!>) {
if (<!SENSELESS_COMPARISON!>stringProperty != null<!>) {
if (false || false || false || <!SENSELESS_COMPARISON!>z == null<!> || false) {
<!DEBUG_INFO_EXPRESSION_TYPE("TypealiasString & kotlin.Nothing")!>x<!>
}
}
@@ -111,13 +111,13 @@ fun case_11(x: TypealiasString, y: TypealiasString) {
}
// TESTCASE NUMBER: 12
fun case_12(x: TypealiasString, y: TypealiasString) = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>if (x != null) "1"
else if (y !== null) <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasString & kotlin.Nothing")!>x<!>
fun case_12(x: TypealiasString, y: TypealiasString) = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>if (<!SENSELESS_COMPARISON!>x != null<!>) "1"
else if (<!SENSELESS_COMPARISON!>y !== null<!>) <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasString & kotlin.Nothing")!>x<!>
else "-1"<!>
// TESTCASE NUMBER: 13
fun case_13(x: otherpackage.EmptyClass13) =
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>if (x != null) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>if (<!SENSELESS_COMPARISON!>x != null<!>) {
1
} else <!DEBUG_INFO_EXPRESSION_TYPE("otherpackage.EmptyClass13 & kotlin.Nothing")!>x<!><!>
@@ -132,22 +132,22 @@ class A14 {
fun case_14() {
val a = A14()
if (a.x == null) {
if (a.x == null) {
if (a.x == null) {
if (a.x === null) {
if (a.x == null) {
if (a.x == null) {
if (a.x == null) {
if (a.x == null) {
if (a.x === null) {
if (a.x == null) {
if (a.x == null) {
if (a.x == null) {
if (a.x == null) {
if (a.x == null) {
if (a.x == null) {
if (a.x === null) {
if (<!SENSELESS_COMPARISON!>a.x == null<!>) {
if (<!SENSELESS_COMPARISON!>a.x == null<!>) {
if (<!SENSELESS_COMPARISON!>a.x == null<!>) {
if (<!SENSELESS_COMPARISON!>a.x === null<!>) {
if (<!SENSELESS_COMPARISON!>a.x == null<!>) {
if (<!SENSELESS_COMPARISON!>a.x == null<!>) {
if (<!SENSELESS_COMPARISON!>a.x == null<!>) {
if (<!SENSELESS_COMPARISON!>a.x == null<!>) {
if (<!SENSELESS_COMPARISON!>a.x === null<!>) {
if (<!SENSELESS_COMPARISON!>a.x == null<!>) {
if (<!SENSELESS_COMPARISON!>a.x == null<!>) {
if (<!SENSELESS_COMPARISON!>a.x == null<!>) {
if (<!SENSELESS_COMPARISON!>a.x == null<!>) {
if (<!SENSELESS_COMPARISON!>a.x == null<!>) {
if (<!SENSELESS_COMPARISON!>a.x == null<!>) {
if (<!SENSELESS_COMPARISON!>a.x === null<!>) {
a.x
}
}
@@ -169,7 +169,7 @@ fun case_14() {
// TESTCASE NUMBER: 15
fun case_15(x: TypealiasString) {
val t = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>if (true && x != null) "" else {
val t = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>if (true && <!SENSELESS_COMPARISON!>x != null<!>) "" else {
<!DEBUG_INFO_EXPRESSION_TYPE("TypealiasString")!>x<!>
}<!>
}
@@ -178,7 +178,7 @@ fun case_15(x: TypealiasString) {
fun case_16() {
val x: TypealiasNothing = return
if (x == null) {
if (<!SENSELESS_COMPARISON!>x == null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNothing")!>x<!>
}
}
@@ -188,13 +188,13 @@ fun case_16() {
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-28329
*/
val case_17 = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>if (true && true && intProperty != null) 0 else {
val case_17 = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>if (true && true && <!SENSELESS_COMPARISON!>intProperty != null<!>) 0 else {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>intProperty<!>
}<!>
//TESTCASE NUMBER: 18
fun case_18(a: DeepObject.A.B.C.D.E.F.G.J) {
if (a == null) {
if (<!SENSELESS_COMPARISON!>a == null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("DeepObject.A.B.C.D.E.F.G.J & kotlin.Nothing")!>a<!>
}
}
@@ -219,7 +219,7 @@ fun case_19(b: Boolean) {
}
} else null
if (a != null && a.B19 != null && a.B19.C19 != null && a.B19.C19.D19 != null && a.B19.C19.D19.x == null) {
if (a != null && a.B19 != null && a.B19.C19 != null && a.B19.C19.D19 != null && <!SENSELESS_COMPARISON!>a.B19.C19.D19.x == null<!>) {
a.B19.C19.D19.x
}
}
@@ -234,30 +234,30 @@ fun case_20() {
}
}
if (a.B19.C19.D19 === null) {
if (<!SENSELESS_COMPARISON!>a.B19.C19.D19 === null<!>) {
a.B19.C19.D19
}
}
// TESTCASE NUMBER: 21
fun case_21() {
if (EnumClassWithProperty.B.prop_1 == null || false || false || false || false || false || false || false) {
if (<!SENSELESS_COMPARISON!>EnumClassWithProperty.B.prop_1 == null<!> || false || false || false || false || false || false || false) {
EnumClassWithProperty.B.prop_1
}
}
// TESTCASE NUMBER: 22
fun case_22(a: (() -> Unit)) {
if (a == null) {
if (<!SENSELESS_COMPARISON!>a == null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit")!>a()<!>
}
}
// TESTCASE NUMBER: 23
fun case_23(a: ((Float) -> Int), b: Float) {
if (a == null && b == null) {
if (<!SENSELESS_COMPARISON!>a == null<!> && <!SENSELESS_COMPARISON!>b == null<!>) {
val x = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>a(<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Float & kotlin.Nothing")!>b<!>)<!>
if (x !== null) {
if (<!SENSELESS_COMPARISON!>x !== null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>x<!>
}
}
@@ -269,20 +269,20 @@ fun case_23(a: ((Float) -> Int), b: Float) {
* ISSUES: KT-28329
*/
fun case_24(a: ((() -> Unit) -> Unit), b: (() -> Unit)) {
if (false || false || a == null && b === null) {
if (false || false || <!SENSELESS_COMPARISON!>a == null<!> && <!SENSELESS_COMPARISON!>b === null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Function1<kotlin.Function0<kotlin.Unit>, kotlin.Unit>")!>a<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Function0<kotlin.Unit>")!>b<!>
}
}
// TESTCASE NUMBER: 25
fun case_25(a: (() -> Unit) -> Unit, b: (() -> Unit) -> Unit = if (a == null) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Function1<kotlin.Function0<kotlin.Unit>, kotlin.Unit> & kotlin.Nothing")!>a<!> else {{}}) {
fun case_25(a: (() -> Unit) -> Unit, b: (() -> Unit) -> Unit = if (<!SENSELESS_COMPARISON!>a == null<!>) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Function1<kotlin.Function0<kotlin.Unit>, kotlin.Unit> & kotlin.Nothing")!>a<!> else {{}}) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Function1<kotlin.Function0<kotlin.Unit>, kotlin.Unit>")!>a<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Function1<kotlin.Function0<kotlin.Unit>, kotlin.Unit>")!>b<!>
}
// TESTCASE NUMBER: 26
fun case_26(a: Int, b: Int = if (a === null) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int & kotlin.Nothing")!>a<!> else 0) {
fun case_26(a: Int, b: Int = if (<!SENSELESS_COMPARISON!>a === null<!>) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int & kotlin.Nothing")!>a<!> else 0) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>a<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>b<!>
}
@@ -65,7 +65,7 @@ fun case_5() {
val x: Int?
val y: Int?
x = 10;y = x
if (y != null) {
if (<!SENSELESS_COMPARISON!>y != null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int? & kotlin.Int")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int? & kotlin.Int")!>x<!>.inv()
}
@@ -76,7 +76,7 @@ fun case_6() {
var x: Int?
val y: Int?
x = 10;y = x
if (y != null) {
if (<!SENSELESS_COMPARISON!>y != null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int? & kotlin.Int")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int? & kotlin.Int")!>x<!>.inv()
}
@@ -87,7 +87,7 @@ fun case_7() {
val x: Int?
var y: Int?
x = 10;y = x
if (y != null) {
if (<!SENSELESS_COMPARISON!>y != null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int? & kotlin.Int")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int? & kotlin.Int")!>x<!>.inv()
}
@@ -98,7 +98,7 @@ fun case_8() {
var x: Int?
var y: Int?
x = 10;y = x
if (y != null) {
if (<!SENSELESS_COMPARISON!>y != null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int? & kotlin.Int")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int? & kotlin.Int")!>x<!>.inv()
}
@@ -19,7 +19,7 @@ fun case_2(x: Int?) = 10
fun case_2() {
var x: Int? = 10
var y = { x = null }
if (x != null) {
if (<!SENSELESS_COMPARISON!>x != null<!>) {
val z = case_2(<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int? & kotlin.Nothing")!>x<!>)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>z<!>
}
@@ -13,7 +13,7 @@ fun case_1() {
do {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>
x = x<!UNSAFE_CALL!>.<!>equals(10)
} while (x != null)
} while (<!SENSELESS_COMPARISON!>x != null<!>)
}
/*
@@ -27,7 +27,7 @@ fun case_2() {
do {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>
x = x<!UNSAFE_CALL!>.<!>equals(10)
} while (x !== null)
} while (<!SENSELESS_COMPARISON!>x !== null<!>)
}
// TESTCASE NUMBER: 3
@@ -59,7 +59,7 @@ fun case_5() {
do {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>
x = x<!UNSAFE_CALL!>.<!>equals(10)
} while (x !== null)
} while (<!SENSELESS_COMPARISON!>x !== null<!>)
}
/*
@@ -73,7 +73,7 @@ fun case_6() {
do {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>
x = x<!UNSAFE_CALL!>.<!>equals(10)
} while (x != null)
} while (<!SENSELESS_COMPARISON!>x != null<!>)
}
/*
@@ -87,7 +87,7 @@ fun case_7() {
do {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>
x = x<!UNSAFE_CALL!>.<!>equals(10)
} while (x !== null)
} while (<!SENSELESS_COMPARISON!>x !== null<!>)
}
/*
@@ -101,7 +101,7 @@ fun case_8() {
do {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>
x = x<!UNSAFE_CALL!>.<!>equals(10)
} while (x != null)
} while (<!SENSELESS_COMPARISON!>x != null<!>)
}
/*
@@ -115,7 +115,7 @@ fun case_9() {
do {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>
x = x<!UNSAFE_CALL!>.<!>equals(10)
} while (x !== null)
} while (<!SENSELESS_COMPARISON!>x !== null<!>)
}
/*
@@ -129,7 +129,7 @@ fun case_10() {
do {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>
x = x<!UNSAFE_CALL!>.<!>equals(10)
} while (x != null)
} while (<!SENSELESS_COMPARISON!>x != null<!>)
}
/*
@@ -143,7 +143,7 @@ fun case_11() {
do {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>
x = x<!UNSAFE_CALL!>.<!>equals(10)
} while (x != null)
} while (<!SENSELESS_COMPARISON!>x != null<!>)
}
/*
@@ -157,7 +157,7 @@ fun case_12() {
do {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>
x = x <!UNSAFE_CALL!>.<!>equals(10)
} while (x != null)
} while (<!SENSELESS_COMPARISON!>x != null<!>)
}
}
@@ -172,7 +172,7 @@ fun case_13() {
do {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>
x = x <!UNSAFE_CALL!>.<!>equals(10)
} while (x != null)
} while (<!SENSELESS_COMPARISON!>x != null<!>)
}
}
@@ -281,7 +281,7 @@ fun case_14() {
// TESTCASE NUMBER: 15
fun case_15(x: TypealiasNullableString) {
val y = null
val z = if (x === null || y == x && x === y || null === x) "" else {
val z = if (<!SENSELESS_COMPARISON!>x === null<!> || y == x && x === y || <!SENSELESS_COMPARISON!>null === x<!>) "" else {
<!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableString & kotlin.Any & TypealiasNullableString")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableString & kotlin.Any & TypealiasNullableString")!>x<!>.equals(null)
<!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableString & kotlin.Any & TypealiasNullableString")!>x<!>.propT
@@ -9,7 +9,7 @@ fun case_1() {
outer@ while (x != null) {
inner@ do {
x = null
} while (x == null)
} while (<!SENSELESS_COMPARISON!>x == null<!>)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String? & kotlin.Nothing")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String? & kotlin.Nothing")!>x<!>.length
}
@@ -34,7 +34,7 @@ fun case_2(x: Any) {
val y = when(x) {
true -> "true"
false -> "false"
null -> "false"
<!SENSELESS_NULL_IN_WHEN!>null<!> -> "false"
}
}
@@ -98,7 +98,7 @@ fun case_7(x: Any) {
val y = when(x) {
true -> "true"
false -> "false"
null -> "false"
<!SENSELESS_NULL_IN_WHEN!>null<!> -> "false"
}
}
}
@@ -155,7 +155,7 @@ fun case_10(x: Any): String {
fun case_11(x: Any?): String? {
if (x is Nothing?) {
return when(x) {
null -> null
<!SENSELESS_NULL_IN_WHEN!>null<!> -> null
}
}
return ""
@@ -169,7 +169,7 @@ fun case_11(x: Any?): String? {
fun case_12(x: Any?): String? {
if (x == null) {
return when(x) {
null -> null
<!SENSELESS_NULL_IN_WHEN!>null<!> -> null
}
}
return ""
@@ -183,7 +183,7 @@ fun case_12(x: Any?): String? {
fun case_13(x: Any?): String? {
if (x === null) {
return when(x) {
null -> null
<!SENSELESS_NULL_IN_WHEN!>null<!> -> null
}
}
return ""
@@ -197,7 +197,7 @@ fun case_13(x: Any?): String? {
fun case_14(x: Any?): String? {
x as Nothing?
return when(x) {
null -> null
<!SENSELESS_NULL_IN_WHEN!>null<!> -> null
}
}
@@ -220,7 +220,7 @@ fun case_16(x: Any) {
EnumClass.SOUTH -> 2
EnumClass.WEST -> 3
EnumClass.EAST -> 4
null -> 5
<!SENSELESS_NULL_IN_WHEN!>null<!> -> 5
}
}
}
@@ -256,7 +256,7 @@ fun case_19(x: Any): Int {
EnumClass.SOUTH -> 2
EnumClass.WEST -> 3
EnumClass.EAST -> 4
null -> 5
<!SENSELESS_NULL_IN_WHEN!>null<!> -> 5
}
}
return 0
@@ -323,7 +323,7 @@ fun case_25(x: Any) {
is SealedChild1 -> 1
is SealedChild2 -> 2
is SealedChild3 -> 3
null -> 5
<!SENSELESS_NULL_IN_WHEN!>null<!> -> 5
}
}
}
@@ -356,7 +356,7 @@ fun case_28(x: Any): Int {
is SealedChild1 -> 1
is SealedChild2 -> 2
is SealedChild3 -> 3
null -> 5
<!SENSELESS_NULL_IN_WHEN!>null<!> -> 5
}
}
return 0
@@ -401,7 +401,7 @@ fun case_32(x: Any) {
SealedWithObjectsChild1 -> 1
SealedWithObjectsChild2 -> 2
SealedWithObjectsChild3 -> 3
null -> 5
<!SENSELESS_NULL_IN_WHEN!>null<!> -> 5
}
}
}
@@ -434,7 +434,7 @@ fun case_35(x: Any): Int {
SealedWithObjectsChild1 -> 1
SealedWithObjectsChild2 -> 2
SealedWithObjectsChild3 -> 3
null -> 5
<!SENSELESS_NULL_IN_WHEN!>null<!> -> 5
}
}
return 0
@@ -18,7 +18,7 @@ import orherpackage.*
// TESTCASE NUMBER: 1
fun case_1(x: Any?) {
if (x != null || x != null || x != null || x != null || x != null || x != null || x != null) {
if (x != null || <!SENSELESS_COMPARISON!>x != null<!> || <!SENSELESS_COMPARISON!>x != null<!> || <!SENSELESS_COMPARISON!>x != null<!> || <!SENSELESS_COMPARISON!>x != null<!> || <!SENSELESS_COMPARISON!>x != null<!> || <!SENSELESS_COMPARISON!>x != null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & kotlin.Any")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & kotlin.Any")!>x<!>.equals(null)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & kotlin.Any")!>x<!>.propT
@@ -38,14 +38,14 @@ fun case_1(x: Any?) {
* ISSUES: KT-28159
*/
fun case_2(x: Nothing?) {
if (x !== null && x !== null) {
if (<!SENSELESS_COMPARISON!>x !== null<!> && <!SENSELESS_COMPARISON!>x !== null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing?")!>x<!>
}
}
// TESTCASE NUMBER: 3
fun case_3() {
if (Object.prop_1 == null && Object.prop_1 == null)
if (Object.prop_1 == null && <!SENSELESS_COMPARISON!>Object.prop_1 == null<!>)
else {
Object.prop_1
Object.prop_1.equals(null)
@@ -80,7 +80,7 @@ fun case_4(x: Char?) {
fun case_5() {
val x: Unit? = null
if (x !== null || x !== null && x !== null || x !== null && x !== null) {
if (x !== null || <!SENSELESS_COMPARISON!>x !== null<!> && <!SENSELESS_COMPARISON!>x !== null<!> || <!SENSELESS_COMPARISON!>x !== null<!> && <!SENSELESS_COMPARISON!>x !== null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit?")!>x<!><!UNSAFE_CALL!>.<!>equals(null)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit?")!>x<!>.propT
@@ -115,7 +115,7 @@ fun case_6(x: Class?) {
// TESTCASE NUMBER: 7
fun case_7() {
val x: EmptyObject? = null
if (x != null || x != null || <!DEBUG_INFO_EXPRESSION_TYPE("EmptyObject? & kotlin.Nothing?")!>x<!> != null) {
if (x != null || <!SENSELESS_COMPARISON!>x != null<!> || <!SENSELESS_COMPARISON!><!DEBUG_INFO_EXPRESSION_TYPE("EmptyObject? & kotlin.Nothing?")!>x<!> != null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("EmptyObject? & EmptyObject")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("EmptyObject? & EmptyObject")!>x<!>.equals(null)
<!DEBUG_INFO_EXPRESSION_TYPE("EmptyObject? & EmptyObject")!>x<!>.propT
@@ -131,7 +131,7 @@ fun case_7() {
// TESTCASE NUMBER: 8
fun case_8(x: TypealiasString) {
if (x !== null && <!DEBUG_INFO_EXPRESSION_TYPE("TypealiasString")!>x<!> != null) {
if (<!SENSELESS_COMPARISON!>x !== null<!> && <!SENSELESS_COMPARISON!><!DEBUG_INFO_EXPRESSION_TYPE("TypealiasString")!>x<!> != null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("TypealiasString")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("TypealiasString")!>x<!>.equals(null)
<!DEBUG_INFO_EXPRESSION_TYPE("TypealiasString")!>x<!>.propT
@@ -147,9 +147,9 @@ fun case_8(x: TypealiasString) {
// TESTCASE NUMBER: 9
fun case_9(x: TypealiasNullableString?) {
if (x === null && x === null || x === null) {
if (x === null && <!SENSELESS_COMPARISON!>x === null<!> || <!SENSELESS_COMPARISON!>x === null<!>) {
} else if (x === null || x === null) {
} else if (<!SENSELESS_COMPARISON!>x === null<!> || <!SENSELESS_COMPARISON!>x === null<!>) {
} else if (false) {
<!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableString? & kotlin.Any & TypealiasNullableString")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableString? & kotlin.Any & TypealiasNullableString")!>x<!>.equals(null)
@@ -168,7 +168,7 @@ fun case_9(x: TypealiasNullableString?) {
fun case_10() {
val a = Class()
if (a.prop_4 === null || a.prop_4 === null || true) {
if (a.prop_4 === null || <!SENSELESS_COMPARISON!>a.prop_4 === null<!> || true) {
if (a.prop_4 != null) {
a.prop_4
a.prop_4.equals(null)
@@ -191,10 +191,10 @@ fun case_11(x: TypealiasNullableString?, y: TypealiasNullableString) {
if (x == null) {
} else {
if (x != null) {
if (y != null || y != null) {
if (stringProperty == null && nullableNothingProperty == null) {
if (t != null || t != null) {
if (<!SENSELESS_COMPARISON!>x != null<!>) {
if (<!SENSELESS_COMPARISON!>y != null<!> || <!SENSELESS_COMPARISON!>y != null<!>) {
if (<!SENSELESS_COMPARISON!>stringProperty == null<!> && <!SENSELESS_COMPARISON!>nullableNothingProperty == null<!>) {
if (<!SENSELESS_COMPARISON!>t != null<!> || <!SENSELESS_COMPARISON!>t != null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableString? & kotlin.Any & TypealiasNullableString")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableString? & kotlin.Any & TypealiasNullableString")!>x<!>.equals(null)
<!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableString? & kotlin.Any & TypealiasNullableString")!>x<!>.propT
@@ -213,8 +213,8 @@ fun case_11(x: TypealiasNullableString?, y: TypealiasNullableString) {
}
// TESTCASE NUMBER: 12
fun case_12(x: TypealiasNullableString, y: TypealiasNullableString) = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>if (x == null) "1"
else if (y === null || y === null) {
fun case_12(x: TypealiasNullableString, y: TypealiasNullableString) = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>if (<!SENSELESS_COMPARISON!>x == null<!>) "1"
else if (<!SENSELESS_COMPARISON!>y === null<!> || <!SENSELESS_COMPARISON!>y === null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableString & kotlin.Any & TypealiasNullableString")!>x<!>.equals(null)
<!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableString & kotlin.Any & TypealiasNullableString")!>x<!>.propT
<!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableString & kotlin.Any & TypealiasNullableString")!>x<!>.propAny
@@ -56,7 +56,7 @@ fun case_2(a: Inv<Inv<Inv<Inv<Inv<Inv<Int?>?>?>?>?>?>?) {
fun case_3(a: Inv<Int>?) {
if (a != null) {
val b = a
if (a == null) {
if (<!SENSELESS_COMPARISON!>a == null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<kotlin.Int>? & kotlin.Nothing")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<kotlin.Int>? & kotlin.Nothing")!>b<!>.equals(null)
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<kotlin.Int>? & kotlin.Nothing")!>b<!>.propT
@@ -60,7 +60,7 @@ fun case_2(a: Out<<!REDUNDANT_PROJECTION!>out<!> Out<<!REDUNDANT_PROJECTION!>out
fun case_3(a: Inv<out Int>?) {
if (a != null) {
val b = a
if (a == null)
if (<!SENSELESS_COMPARISON!>a == null<!>)
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<out kotlin.Int>? & kotlin.Nothing")!>b<!>
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<out kotlin.Int>? & Inv<out kotlin.Int>")!>b<!>.equals(null)
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<out kotlin.Int>? & Inv<out kotlin.Int>")!>b<!>.propT
@@ -438,7 +438,7 @@ fun case_18(a: Inv<out Int?>) {
* ISSUES: KT-28785
*/
fun case_19(a: Inv<out Nothing?>) {
if (a.x != null) {
if (<!SENSELESS_COMPARISON!>a.x != null<!>) {
a.x
a.x.hashCode()
}
@@ -490,7 +490,7 @@ fun case_21(a: Out<<!REDUNDANT_PROJECTION!>out<!> Int?>) {
* ISSUES: KT-28785
*/
fun case_22(a: Out<<!REDUNDANT_PROJECTION!>out<!> Nothing?>) {
if (a.x != null) {
if (<!SENSELESS_COMPARISON!>a.x != null<!>) {
a.x
a.x.hashCode()
}
@@ -534,7 +534,7 @@ fun case_24(a: Out<Int?>) {
// TESTCASE NUMBER: 25
fun case_25(a: Out<Nothing?>) {
if (a.x != null) {
if (<!SENSELESS_COMPARISON!>a.x != null<!>) {
a.x
a.x.hashCode()
}
@@ -13,7 +13,7 @@ open class Foo(val prop: Int) {
}
fun box(): String? {
if (Foo(42) == null) return null
if (<!SENSELESS_COMPARISON!>Foo(42) == null<!>) return null
return "OK"
}
@@ -13,7 +13,7 @@ open class Foo(val prop: Int) {
}
fun box(): String? {
if (Foo(42) == null) return null
if (<!SENSELESS_COMPARISON!>Foo(42) == null<!>) return null
return "OK"
}

Some files were not shown because too many files have changed in this diff Show More