Files
kotlin-fork/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ExclExcl.kt
T
Mikhail Zarechenskiy c458393e2f [NI] Do not avoid trivial constraints if they aren't from upper bounds
Since we skipped trivial constraint with `Any?` from parameter type of
 function `equals`, the compiler thought that there is no proper
 constraints (upper bounds do not matter here) and marked resolved
 call as a failed one, then diagnostic about missing equals was added

 Also, tune `TrivialConstraintTypeInferenceOracle` for `Any?`-like
 constraints

 #KT-30724 Fixed
2019-04-02 12:21:14 +03:00

25 lines
660 B
Kotlin
Vendored

// !WITH_NEW_INFERENCE
fun bar(x: Int) = x + 1
fun f1(x: Int?) {
bar(<!TYPE_MISMATCH!>x<!>)
if (x != null) bar(x<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>)
if (x == null) <!UNREACHABLE_CODE!>bar(<!><!ALWAYS_NULL!>x<!>!!<!UNREACHABLE_CODE!>)<!>
}
fun f2(x: Int?) {
if (x != null) else <!ALWAYS_NULL!>x<!>!!
}
fun f3(x: Int?) {
if (x != null) bar(x<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>) else <!ALWAYS_NULL!>x<!>!!
}
fun f4(x: Int?) {
if (x == null) <!ALWAYS_NULL!>x<!>!! else bar(x<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>)
}
fun f5(x: Int?) {
if (x == null) else bar(x<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>)
}