If t is of type T, comparison (t == null) may be true. No warning in this case

This commit is contained in:
Andrey Breslav
2012-10-19 19:42:32 +04:00
parent d58038d3ef
commit 583dd1564d
4 changed files with 23 additions and 2 deletions
@@ -0,0 +1,16 @@
// The type checker used to think that T is not null no matter what the upper bound
fun nullableUpperBound<T, INDIRECT: T>(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 notNullUpperBound<T: Any, INDIRECT: T>(t: T, ind: INDIRECT) {
if (<!SENSELESS_COMPARISON!>t == null<!>) {} // still a warning
if (<!SENSELESS_COMPARISON!>t != null<!>) {} // still a warning
if (<!SENSELESS_COMPARISON!>ind == null<!>) {} // still a warning
if (<!SENSELESS_COMPARISON!>ind != null<!>) {} // still a warning
}