Don't issue compatibility warning for the candidates in the same group

This commit is contained in:
Mikhail Zarechenskiy
2020-06-01 09:39:52 +03:00
parent f922e454f9
commit 569b6eaff2
2 changed files with 5 additions and 3 deletions
@@ -313,6 +313,7 @@ class TowerResolver {
override fun getSuccessfulCandidates(): Collection<C>? {
if (!isSuccessful) return null
var compatibilityCandidate: C? = null
var compatibilityGroup: Collection<C>? = null
var firstGroupWithResolved: Collection<C>? = null
outer@ for (group in candidateGroups) {
for (candidate in group) {
@@ -322,13 +323,14 @@ class TowerResolver {
}
if (compatibilityCandidate == null && isSuccessfulPreserveCompatibility(candidate)) {
compatibilityGroup = group
compatibilityCandidate = candidate
}
}
}
if (firstGroupWithResolved == null) return null
if (compatibilityCandidate != null) {
if (compatibilityCandidate != null && compatibilityGroup !== firstGroupWithResolved) {
firstGroupWithResolved.forEach { it.addCompatibilityWarning(compatibilityCandidate) }
}
@@ -40,7 +40,7 @@ object Test3 {
fun foo(n: Number, f: () -> Unit): String = ""
fun test(f: () -> Unit) {
val result = <!COMPATIBILITY_WARNING!>foo(1, f)<!>
val result = foo(1, f)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>result<!>
}
}
@@ -52,7 +52,7 @@ object Test4 {
fun bar() {}
fun test() {
val result = <!COMPATIBILITY_WARNING!>foo(1, ::bar)<!>
val result = foo(1, ::bar)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>result<!>
}
}