use data flow info in constraint system
intersect data flow value possible types add intersection type (or exact type for the most cases) as a lower bound to constraint system always get common super type for intersection type as a result (avoid returning it, even in error messages)
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
//KT-2851 Type inference failed passing in not-null after smart-cast value in Pair
|
||||
package a
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val value: String? = ""
|
||||
if (value != null) {
|
||||
foo(Pair("val", value))
|
||||
foo(Pair("val", value<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>))
|
||||
foo(Pair<String, String>("val", value))
|
||||
}
|
||||
}
|
||||
|
||||
fun foo(<!UNUSED_PARAMETER!>map<!>: Pair<String, String>) {}
|
||||
|
||||
|
||||
//from library
|
||||
public class Pair<out A, out B> (
|
||||
public val first: A,
|
||||
public val second: B
|
||||
)
|
||||
Reference in New Issue
Block a user