[NI] Add resolution applicability for resolved candidates with error

New resolution applicability is needed in cases when error is found,
but candidate still should be selected. Currently there are two cases,
when this behaviour is required:
- unstable smartcast (choose candidate with non-nullable parameter)
- unknown lambda parameter type (against non-functional expected type)

KT-36264
This commit is contained in:
Pavel Kirpichenkov
2020-02-04 17:26:28 +03:00
parent 4fa87d2caa
commit e40ba73950
16 changed files with 188 additions and 86 deletions
@@ -0,0 +1,19 @@
// !WITH_NEW_INFERENCE
// !DIAGNOSTICS: -UNUSED_PARAMETER
interface A
class B : A
val String.ext: A
get() = TODO()
class Cls {
fun take(arg: B) {}
fun test(s: String) {
if (s.ext is B)
take(s.ext)
}
}
fun take(arg: Any) {}
+19
View File
@@ -0,0 +1,19 @@
// !WITH_NEW_INFERENCE
// !DIAGNOSTICS: -UNUSED_PARAMETER
interface A
class B : A
val String.ext: A
get() = TODO()
class Cls {
fun take(arg: B) {}
fun test(s: String) {
if (s.ext is B)
take(<!NI;SMARTCAST_IMPOSSIBLE, SMARTCAST_IMPOSSIBLE!>s.ext<!>)
}
}
fun take(arg: Any) {}
+26
View File
@@ -0,0 +1,26 @@
package
public val kotlin.String.ext: A
public fun take(/*0*/ arg: kotlin.Any): kotlin.Unit
public interface A {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class B : A {
public constructor B()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class Cls {
public constructor Cls()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final fun take(/*0*/ arg: B): kotlin.Unit
public final fun test(/*0*/ s: kotlin.String): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -1,4 +1,3 @@
// !WITH_NEW_INFERENCE
fun create(): Map<String, String> = null!!
operator fun <K, V> Map<K, V>.iterator(): Iterator<Map.Entry<K, V>> = null!!
@@ -1,4 +1,3 @@
// !WITH_NEW_INFERENCE
fun create(): Map<String, String> = null!!
operator fun <K, V> Map<K, V>.iterator(): Iterator<Map.Entry<K, V>> = null!!
@@ -14,7 +13,7 @@ class MyClass {
m = create()
// See KT-7428
for ((k, v) in <!SMARTCAST_IMPOSSIBLE!>m<!>)
res <!NI;OVERLOAD_RESOLUTION_AMBIGUITY!>+=<!> (<!NI;DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>k<!>.<!NI;DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>length<!> <!NI;DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>+<!> <!NI;DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>v<!>.<!NI;DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>length<!>)
res += (k.length + v.length)
return res
}
}