[FIR] Improve diagnostic reporting & don't use error symbol for candidate if possible

Also introduce few new diagnostics:
- NONE_APPLICABLE more many inapplicable candidates
- HIDDEN for visible candidates
This commit is contained in:
Dmitriy Novozhilov
2020-07-22 16:40:14 +03:00
committed by Mikhail Glukhikh
parent 5c0528b61e
commit f283f2db43
365 changed files with 1400 additions and 1451 deletions
@@ -33,6 +33,6 @@ fun test() {
x.baz(1).checkType { _<Unit>() }
x.<!INAPPLICABLE_CANDIDATE!>baz<!>(1, 2)
x.<!UNRESOLVED_REFERENCE!>foobar<!>().<!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String>() }
x.<!UNRESOLVED_REFERENCE!>foobar<!>().<!INAPPLICABLE_CANDIDATE!>checkType<!> { <!INAPPLICABLE_CANDIDATE!>_<!><String>() }
}
}
@@ -16,7 +16,7 @@ fun foo(): Int {
k.run()
val d: Int = c
// a is not null because of k constructor, but we do not know it
return a <!INAPPLICABLE_CANDIDATE!>+<!> d
return a <!NONE_APPLICABLE!>+<!> d
}
else return -1
}
@@ -11,7 +11,7 @@ fun foo(): Int {
}
k.run()
val d: Int = c
return a <!INAPPLICABLE_CANDIDATE!>+<!> d
return a <!NONE_APPLICABLE!>+<!> d
}
else return -1
}
@@ -15,7 +15,7 @@ fun foo(): Int {
}
k.run()
val d: Int = c
return a <!INAPPLICABLE_CANDIDATE!>+<!> d
return a <!NONE_APPLICABLE!>+<!> d
}
else return -1
}
@@ -6,8 +6,8 @@ fun test(foo: Foo?) {
// Error, foo?.bar is nullable
it.<!INAPPLICABLE_CANDIDATE!>length<!>
// Error, foo is nullable
foo.<!INAPPLICABLE_CANDIDATE!>bar<!>.<!UNRESOLVED_REFERENCE!>length<!>
foo.<!INAPPLICABLE_CANDIDATE!>bar<!>.length
// Correct
foo?.bar?.length
}
}
}
@@ -13,13 +13,13 @@ fun test(foo: Foo?) {
// Error, foo?.bar?.gav is nullable
it.<!INAPPLICABLE_CANDIDATE!>length<!>
// Error, foo is nullable
foo.<!INAPPLICABLE_CANDIDATE!>bar<!>.<!UNRESOLVED_REFERENCE!>gav<!>.<!UNRESOLVED_REFERENCE!>length<!>
foo.<!INAPPLICABLE_CANDIDATE!>bar<!>.gav.length
// Correct
foo?.bar?.gav?.length
}
foo?.bar?.gav.call { it }?.notNullLet {
foo.<!INAPPLICABLE_CANDIDATE!>hashCode<!>()
foo.<!INAPPLICABLE_CANDIDATE!>bar<!>.<!UNRESOLVED_REFERENCE!>hashCode<!>()
foo.<!INAPPLICABLE_CANDIDATE!>bar<!>.hashCode()
}
}
@@ -5,7 +5,7 @@ class A(val x: String?) {
fun foo(other: A) {
when {
x == null && other.x == null -> "1"
x.<!INAPPLICABLE_CANDIDATE!>length<!> <!UNRESOLVED_REFERENCE!>><!> 0 -> "2"
x.<!INAPPLICABLE_CANDIDATE!>length<!> > 0 -> "2"
}
}
}
@@ -12,10 +12,10 @@ operator fun Long?.inc() = this?.let { it + 1 }
fun bar(arg: Long?): Long {
var i = arg
if (i++ == 5L) {
return i<!INAPPLICABLE_CANDIDATE!>--<!> <!INAPPLICABLE_CANDIDATE!>+<!> i
return i<!INAPPLICABLE_CANDIDATE!>--<!> + i
}
if (i++ == 7L) {
return i++ <!INAPPLICABLE_CANDIDATE!>+<!> i
return i++ <!NONE_APPLICABLE!>+<!> i
}
return 0L
}
}
@@ -14,8 +14,8 @@ class MyClass {
var res = 0
m = create()
// See KT-7428
<!INAPPLICABLE_CANDIDATE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>for ((k, v) in m)
<!UNRESOLVED_REFERENCE!>res += (k.<!UNRESOLVED_REFERENCE!>length<!> + v.<!UNRESOLVED_REFERENCE!>length<!>)<!><!>
<!INAPPLICABLE_CANDIDATE!>for ((k, v) in m)
res += (k.length + v.length)<!>
return res
}
}
}
@@ -2,5 +2,5 @@
fun foo(): Int {
var i: Int? = 42
i = null
return i <!INAPPLICABLE_CANDIDATE!>+<!> 1
}
return i <!NONE_APPLICABLE!>+<!> 1
}