Fix resolution of callable references

When there is unsuccessful (e.g invisible) result of one kind (static/non-static)
and there is a successful candidate for another kind, choose the latter one.

Note, that we have to postpone commiting trace until we choose one of the results,
otherwise errors of unsuccessful results are reported

TODO: Maybe it makes sense to report all results when all of them are
unsuccessful (NONE_APPLICABLE or something like this)

 #KT-16278 Fixed
This commit is contained in:
Denis Zharkov
2017-02-10 15:29:57 +03:00
parent dd61a5b2c6
commit b5a8ffaddc
4 changed files with 93 additions and 47 deletions
@@ -17,6 +17,7 @@
package org.jetbrains.kotlin.utils
import java.util.*
import kotlin.coroutines.experimental.SequenceBuilder
fun <K, V> Iterable<K>.keysToMap(value: (K) -> V): Map<K, V> {
return associateBy({ it }, value)
@@ -63,6 +64,8 @@ fun <T: Any> MutableCollection<T>.addIfNotNull(t: T?) {
if (t != null) add(t)
}
suspend fun <T: Any> SequenceBuilder<in T>.yieldIfNotNull(t: T?) = if (t != null) yield(t) else Unit
fun <K, V> newHashMapWithExpectedSize(expectedSize: Int): HashMap<K, V> =
HashMap(capacity(expectedSize))